<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Hello_World%21</id>
		<title>Hello World! - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.ethernut.de/nutwiki/index.php?action=history&amp;feed=atom&amp;title=Hello_World%21"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Hello_World!&amp;action=history"/>
		<updated>2026-04-18T20:04:13Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Hello_World!&amp;diff=114&amp;oldid=prev</id>
		<title>Harald: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Hello_World!&amp;diff=114&amp;oldid=prev"/>
				<updated>2016-10-27T16:02:55Z</updated>
		
		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='1' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:02, 27 October 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan='2' style='text-align: center;' lang='en'&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	<entry>
		<id>http://www.ethernut.de/nutwiki/index.php?title=Hello_World!&amp;diff=113&amp;oldid=prev</id>
		<title>Harald: /* Details */</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Hello_World!&amp;diff=113&amp;oldid=prev"/>
				<updated>2012-08-14T07:48:52Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Details&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Test Environments ==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;smalldiv&amp;quot;&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; |&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | Hardware Comments&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | '''Nut/OS&amp;lt;br&amp;gt;4.6.3'''&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | '''Nut/OS&amp;lt;br&amp;gt;4.6.4'''&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | '''Nut/OS&amp;lt;br&amp;gt;4.7.4'''&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | '''Nut/OS&amp;lt;br&amp;gt;4.8.0'''&lt;br /&gt;
| style=&amp;quot;background-color:#F6F9ED&amp;quot; | '''Nut/OS&amp;lt;br&amp;gt;4.8.7'''&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;Ethernut 1.3 H&amp;lt;/span&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| OK&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut13H-nutos-4.6.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut13H-nutos-4.7.4.zip '''Binaries'''] &lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut13H-nutos-4.8.0.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [[Media:Hello-world-enut13H-nutos-4.8.7.zip|'''Binaries''']]&amp;lt;br&amp;gt;'''Compiler:''' AVR-GCC 4.3.2 &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;Ethernut 2.1 B&amp;lt;/span&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| OK&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut21B-nutos-4.6.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut21B-nutos-4.7.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut21B-nutos-4.8.0.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [[Media:Hello-world-enut21B-nutos-4.8.7.zip|'''Binaries''']]&amp;lt;br&amp;gt;'''Compiler:''' AVR-GCC 4.3.2 &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;Ethernut 3.0 E&amp;lt;/span&amp;gt;&lt;br /&gt;
| &lt;br /&gt;
| OK&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut30E-nutos-4.6.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut30E-nutos-4.7.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-enut30E-nutos-4.8.0.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [[Media:Hello-world-enut30E-nutos-4.8.7.zip|'''Binaries''']]&amp;lt;br&amp;gt;'''Compiler:''' ARM-GCC 4.3.3&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;span style=&amp;quot;color:green&amp;quot;&amp;gt;EIR 1.0 C&amp;lt;/span&amp;gt;&lt;br /&gt;
| Set jumper JP1 &amp;lt;br&amp;gt;to DEBUG mode.&lt;br /&gt;
| OK&amp;lt;br&amp;gt;&lt;br /&gt;
| OK &amp;lt;br&amp;gt; [http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-EIR1C-nutos-4.6.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt;[http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-EIR1C-nutos-4.7.4.zip '''Binaries''']&lt;br /&gt;
| OK &amp;lt;br&amp;gt;[http://ethernut.de/arc/WIKI_BINARIES_ZIPPED/hello-world-EIR1C-nutos-4.8.0.zip '''Binaries''']&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| id=&amp;quot;compilertd&amp;quot; colspan=&amp;quot;5&amp;quot; |'''Compiler:''' ARM-GCC 4.2.2 ; AVR-GCC 4.3.0&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
&lt;br /&gt;
This very basic [[Nut/OS Examples|sample program]] puts out the phrase &amp;quot;Hello World&amp;quot; to the serial port.&lt;br /&gt;
&lt;br /&gt;
== Source Code ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;dev/board.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    unsigned long baud = 115200;&lt;br /&gt;
 &lt;br /&gt;
    NutRegisterDevice(&amp;amp;DEV_DEBUG, 0, 0);&lt;br /&gt;
&lt;br /&gt;
    freopen(DEV_DEBUG_NAME, &amp;quot;w&amp;quot;, stdout);&lt;br /&gt;
    _ioctl(_fileno(stdout), UART_SETSPEED, &amp;amp;baud);&lt;br /&gt;
 &lt;br /&gt;
    printf(&amp;quot;Hello World!&amp;quot;);&lt;br /&gt;
 &lt;br /&gt;
    for(;;);&lt;br /&gt;
 &lt;br /&gt;
    return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Details ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;#include &amp;lt;dev/board.h&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
Includes a header file, which contains board specific definitions. This helps to make the program portable on all supported target platforms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;#include &amp;lt;stdio.h&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
Includes another header file. You need this if your code calls standard input and output functions.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;int main(void)&amp;lt;/source&amp;gt;&lt;br /&gt;
Declares a C function named &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt;. More advanced applications will have a large number of functions, but they always must declare a &amp;lt;code&amp;gt;main&amp;lt;/code&amp;gt; function, which will be executed on startup.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
NutRegisterDevice(&amp;amp;DEV_DEBUG, 0, 0);&lt;br /&gt;
freopen(DEV_DEBUG_NAME, &amp;quot;w&amp;quot;, stdout);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Nut/OS doesn't provide a default device for standard output. If an application wants to write to the standard output via &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; for example, it must assign a registered driver to the &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt; stream. Furthermore, a device drivers must be registered before it can be used.&lt;br /&gt;
&lt;br /&gt;
The first line registers a driver for debug output and the second line assigns this driver to the &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt; stream.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;DEV_DEBUG&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;DEV_DEBUG_NAME&amp;lt;/code&amp;gt; are defined in the header file &amp;lt;code&amp;gt;dev/board.h&amp;lt;/code&amp;gt; and are available for all target boards. On the AVR this is the first USART, while DBGU is used on AT91 boards. On the Gameboy however, the LCD is used.&lt;br /&gt;
&lt;br /&gt;
One specific feature of DEV_DEBUG is, that it is a polling device. That means, that its driver is quite simple, easy to implement and you can even use it for printing data in interrupt routines.&lt;br /&gt;
&lt;br /&gt;
In most case it is write-only. You cannot use it for user input. Trying to do so will simply crash the system. If you need to read user input, then try&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
NutRegisterDevice(&amp;amp;DEV_CONSOLE, 0, 0);&lt;br /&gt;
freopen(DEV_CONSOLE_NAME, &amp;quot;w&amp;quot;, stdout);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, this is available on later Nut/OS releases only and may use a different hardware interface. Furthermore it is interrupt driven, you cannot use it within interrupt routines. However, if you enabled &amp;lt;tt&amp;gt;NUT_DEV_DEBUG_READ&amp;lt;/tt&amp;gt; in the Configurator and if the device supports input, then DEV_CONSOLE will become equal to DEV_DEBUG for most target boards.&lt;br /&gt;
&lt;br /&gt;
Whatever serial port device you may use to say &amp;quot;Hello&amp;quot;, the remaining code works with all of them.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
unsigned long baud = 115200;&lt;br /&gt;
&lt;br /&gt;
_ioctl(_fileno(stdout), UART_SETSPEED, &amp;amp;baud);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A serial port like USART or DBGU needs to be configured, specifically its transfer rate, also known as baud rate. While most embedded systems can provide much higher rates, 115,200 bits per second is still the upper limit on most desktop computers.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;_ioctl()&amp;lt;/code&amp;gt; function is typically used in C programs to configure device specific settings. It expects a file handle, not a stream. Thus the function &amp;lt;code&amp;gt;_fileno()&amp;lt;/code&amp;gt; is called to retrieve the file handle of the &amp;lt;code&amp;gt;stdout&amp;lt;/code&amp;gt; stream.&lt;br /&gt;
&lt;br /&gt;
Also note, that you can't directly pass configuration constanst to &amp;lt;code&amp;gt;_ioctl()&amp;lt;/code&amp;gt;. Instead you must assign the value to a variable and use a pointer to this variable for the function argument.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;printf(&amp;quot;Hello World!&amp;quot;);&amp;lt;/source&amp;gt;&lt;br /&gt;
Puts out the phrase &amp;quot;Hello World!&amp;quot; to standard output.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
for(;;);&lt;br /&gt;
return 0;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once started, Nut/OS applications will never return. If they do, the result is unknown, so we put an endless loop before the &amp;lt;code&amp;gt;return&amp;lt;/code&amp;gt; statement to avoid this.&lt;br /&gt;
&lt;br /&gt;
Although never reached, the &amp;lt;code&amp;gt;return 0&amp;lt;/code&amp;gt; is sometimes necessary to get rid of a compiler warning. However, other compilers may spit out a warning about unreachable code.&lt;br /&gt;
&lt;br /&gt;
== Output ==&lt;br /&gt;
&lt;br /&gt;
[[Image:teraterm-serial-port-setup.png|thumb|right|TeraTerm serial port setup]]&lt;br /&gt;
&lt;br /&gt;
On most target boards the output is sent to the first serial port and can be viewed by connecting a terminal emulator like TeraTerm on Windows or miniterm on Linux.&lt;br /&gt;
&lt;br /&gt;
 Hello World!&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* More [[Nut/OS Examples]]&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Hello_world Hello world program] A computer program that prints out &amp;quot;Hello world!&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/C_preprocessor C preprocessor] A separate program invoked by the compiler as the first part of translation.&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Standard_streams Standard streams] The three standard I/O connections are called standard input, standard output and standard error.&lt;br /&gt;
&lt;br /&gt;
[http://www.ethernut.de/api/group__xg_device.html NutRegisterDevice] Register a specific device which will be used by a Nut/OS application.&lt;br /&gt;
&lt;br /&gt;
[http://www.ethernut.de/en/documents/rs232primer.html Ethernut RS-232 Primer] explains how to connect serial communication ports.&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Ioctl ioctl] The most common use of ioctls is to control hardware devices.&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/File_descriptor File descriptor] An abstract key for accessing a file or a device.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Code Snippets]]&lt;br /&gt;
&lt;br /&gt;
{{Languages}}&lt;/div&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	</feed>