<?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=Documents%2FLED_Blink</id>
		<title>Documents/LED Blink - 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=Documents%2FLED_Blink"/>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Documents/LED_Blink&amp;action=history"/>
		<updated>2026-04-23T06:05:40Z</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=Documents/LED_Blink&amp;diff=503&amp;oldid=prev</id>
		<title>Harald: /* ATmega Ports */</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Documents/LED_Blink&amp;diff=503&amp;oldid=prev"/>
				<updated>2017-07-13T17:00:48Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;ATmega Ports&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 17:00, 13 July 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l16&quot; &gt;Line 16:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 16:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This register is used to configure the mode of each port pin. When the bit is set, then the port pin works in output mode.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This register is used to configure the mode of each port pin. When the bit is set, then the port pin works in output mode.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;All registers are 8 bits wide and three of them are available at the [[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;..&lt;/del&gt;/&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;hardware/expansion.html&lt;/del&gt;|Ethernut expansion port]] , named B, D and E.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;All registers are 8 bits wide and three of them are available at the [[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Hardware&lt;/ins&gt;/&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Expansion&lt;/ins&gt;|Ethernut expansion port]] , named B, D and E.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Initialization ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Initialization ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&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=Documents/LED_Blink&amp;diff=495&amp;oldid=prev</id>
		<title>Harald at 16:55, 13 July 2017</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Documents/LED_Blink&amp;diff=495&amp;oldid=prev"/>
				<updated>2017-07-13T16:55:03Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:55, 13 July 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l181&quot; &gt;Line 181:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 181:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If everything worked well, your LED should start blinking.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;If everything worked well, your LED should start blinking.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;led-hardware.html&lt;/del&gt;|Previous]] [[&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;led.html&lt;/del&gt;|Contents]] &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Documents/LED Hardware&lt;/ins&gt;|Previous]] [[&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Documents/LED Tutorial&lt;/ins&gt;|Contents]] &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/div&amp;gt;&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=Documents/LED_Blink&amp;diff=494&amp;oldid=prev</id>
		<title>Harald: /* Building the Application Code */</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Documents/LED_Blink&amp;diff=494&amp;oldid=prev"/>
				<updated>2017-07-13T16:52:29Z</updated>
		
		<summary type="html">&lt;p&gt;‎&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Building the Application Code&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 16:52, 13 July 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l158&quot; &gt;Line 158:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 158:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;As a result you'll find several new files in your application directory. The most important one is led01.hex, which contains the code to be transfered to the Ethernut Board in Intel Hex Format.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;As a result you'll find several new files in your application directory. The most important one is led01.hex, which contains the code to be transfered to the Ethernut Board in Intel Hex Format.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Building &lt;/del&gt;the Application Code ==&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Running &lt;/ins&gt;the Application Code ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;It's time to attach the programmer and power up your Ethernut.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;It's time to attach the programmer and power up your Ethernut.&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=Documents/LED_Blink&amp;diff=332&amp;oldid=prev</id>
		<title>Harald: Created page with &quot;&lt;div id=&quot;content&quot;&gt;  = Nut/OS LED Tutorial =  We will now start with our first application. It will initialize the port bit and then switch on and off the LED in an endless loo...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.ethernut.de/nutwiki/index.php?title=Documents/LED_Blink&amp;diff=332&amp;oldid=prev"/>
				<updated>2017-07-13T07:36:13Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;  = Nut/OS LED Tutorial =  We will now start with our first application. It will initialize the port bit and then switch on and off the LED in an endless loo...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div id=&amp;quot;content&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Nut/OS LED Tutorial =&lt;br /&gt;
&lt;br /&gt;
We will now start with our first application. It will initialize the port bit and then switch on and off the LED in an endless loop.&lt;br /&gt;
&lt;br /&gt;
== ATmega Ports ==&lt;br /&gt;
&lt;br /&gt;
Almost all digital ports of the ATmega128 can be individually configured for input or output. Three registers are used to control or monitor each port.&lt;br /&gt;
&lt;br /&gt;
* Port register&amp;lt;br /&amp;gt;&lt;br /&gt;
When the port is configured for output, we can clear each bit to drive the corresponding output low or set the bit to drive it high.&lt;br /&gt;
* Pin register&amp;lt;br /&amp;gt;&lt;br /&gt;
When the port is configured for input, then each bit reflects the status at the corresponding input pin. The bit is zero, when the input is low or set if the input is driven high.&lt;br /&gt;
* Data direction register&amp;lt;br /&amp;gt;&lt;br /&gt;
This register is used to configure the mode of each port pin. When the bit is set, then the port pin works in output mode.&lt;br /&gt;
&lt;br /&gt;
All registers are 8 bits wide and three of them are available at the [[../hardware/expansion.html|Ethernut expansion port]] , named B, D and E.&lt;br /&gt;
== Initialization ==&lt;br /&gt;
&lt;br /&gt;
Standard C does not provide functions to access port registers. But the AVR library, that comes with your compiler, offers such capabilities. Almost all AVR compilers allow to handle ports like predefined variables. To set bit 2 of data direction register of Port E, we can write&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;DDRE |= 0x04;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
In addition a bit value macro is supported as well, which often makes the code easier to read.&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;DDRE |= _BV(2);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
However, using predefined variables to access port registers makes the code less portable. With Nut/OS we prefer to use macros instead. To set bit 2 of the data direction register, we use&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;sbi(DDRE, 2);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
and&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;cbi(DDRE, 2);&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
could be used to clear it again.&lt;br /&gt;
== Blinking LED ==&lt;br /&gt;
&lt;br /&gt;
Setting and clearing the output pin can be done in a similar way:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;for {&lt;br /&gt;
    cbi(PORTE, 2);&lt;br /&gt;
    sbi(PORTE, 2);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
This loop will rapidly drive the output pin 41 of the expansion port to low and back to high. Driving the output low will lit the LED, driving it high will switch the LED off. However, the switching occurs so fast, that we would not be able to notice anything but a glowing LED. At this point Nut/OS jumps in. It offers a function named NutSleep(), which suspends the current thread for a specified number of milliseconds. You may now ask yourself: &amp;amp;quot;What thread?&amp;amp;quot;. Take it easy, we will explain this in detail later. Until then it is sufficient to understand, that our application will stop running for a given amount of time.&lt;br /&gt;
== Building the Application Code ==&lt;br /&gt;
&lt;br /&gt;
You should have created a sample application directory by following the Ethernut Software Manual. Within this directory create a new subdirectory named led01. Within this directory create a new C source file name led01.c and put in the following contents.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;/*&lt;br /&gt;
 * This header contains the Nut/OS timer function&lt;br /&gt;
 * prototypes. We need it for calling NutSleep.&lt;br /&gt;
 */&lt;br /&gt;
#include &amp;amp;lt;sys/timer.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
 * Ethernut LED example #1.&lt;br /&gt;
 */&lt;br /&gt;
int main(void)&lt;br /&gt;
{&lt;br /&gt;
    /*&lt;br /&gt;
     * Configure port E bit 2 as an output.&lt;br /&gt;
     */&lt;br /&gt;
    sbi(DDRE, 2);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * An endless loop.&lt;br /&gt;
     */&lt;br /&gt;
    for (;;) {&lt;br /&gt;
        /*&lt;br /&gt;
         * Set port E bit 2 to low. This will lit the LED.&lt;br /&gt;
         */&lt;br /&gt;
        cbi(PORTE, 2);&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Sleep 1000 milliseconds.&lt;br /&gt;
         */&lt;br /&gt;
        NutSleep(1000);&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Setting port E bit 2 to high switches off the LED.&lt;br /&gt;
         */&lt;br /&gt;
        sbi(PORTE, 2);&lt;br /&gt;
&lt;br /&gt;
        /*&lt;br /&gt;
         * Sleep for another 1000 milliseconds.&lt;br /&gt;
         */&lt;br /&gt;
        NutSleep(1000);&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
If you're using the ImageCraft IDE, then you will probably create a project. Again, check the Ethernut Software Manual for specific project settings.&lt;br /&gt;
&lt;br /&gt;
For the GCC compiler we need to create a file name Makefile in the same directory, which contains:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;PROJ = led01&lt;br /&gt;
&lt;br /&gt;
include ../Makedefs&lt;br /&gt;
&lt;br /&gt;
SRCS =  $(PROJ).c&lt;br /&gt;
OBJS =  $(SRCS:.c=.o)&lt;br /&gt;
LIBS =  $(LIBDIR)/nutinit.o -lnutos -lnutdev $(ADDLIBS)&lt;br /&gt;
TARG =  $(PROJ).hex&lt;br /&gt;
&lt;br /&gt;
all: $(OBJS) $(TARG)&lt;br /&gt;
&lt;br /&gt;
include ../Makerules&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Next open a command line shell (DOS box), change to our new directory. On Linux the PATH is usually correctly configured. On Windows you may have to execute&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;SET PATH=C:\ethernut\nut\tools\win32;C:\WinAVR\bin;C:\WinAVR\utils\bin;%PATH%&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Replace the given directories with the paths used when you installed Nut/OS and WinAVR on your machine. Now simply enter&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;make&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
on the command line. The resulting output on your environment may vary, but in general should look like&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;avr-gcc -c -mmcu=atmega128 -Os -fno-delete-null-pointer-checks&lt;br /&gt;
        -Wall -Wstrict-prototypes -Wa,-ahlms=led01.lst -D__HARVARD_ARCH__&lt;br /&gt;
        -DETHERNUT2 -IC:/ethernut-3.9.8/nutbld-21b/include&lt;br /&gt;
        -IC:/ethernut-3.9.8/nut/include  led01.c -o led01.o&lt;br /&gt;
avr-gcc led01.o -mmcu=atmega128 -Wl,--defsym=main=0,-Map=led01.map,--cref&lt;br /&gt;
        -LC:/ethernut-3.9.8/nutbld-21b/lib&lt;br /&gt;
        C:/ethernut-3.9.8/nutbld-21b/lib/nutinit.o -lnutos -lnutdev&lt;br /&gt;
        -o led01.elf&lt;br /&gt;
avr-objcopy -R .eeprom -O ihex led01.elf led01.hex&lt;br /&gt;
rm led01.elf&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Once again, the Ethernut Software Manual will be helpful with creating Nut/OS applications.&lt;br /&gt;
As a result you'll find several new files in your application directory. The most important one is led01.hex, which contains the code to be transfered to the Ethernut Board in Intel Hex Format.&lt;br /&gt;
&lt;br /&gt;
== Building the Application Code ==&lt;br /&gt;
&lt;br /&gt;
It's time to attach the programmer and power up your Ethernut.&lt;br /&gt;
&lt;br /&gt;
The ImageCraft compiler offers an integrated programming tool. With GCC you can use&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;make burn&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
Your output may vary again, but should look similar to&lt;br /&gt;
&amp;lt;div class=&amp;quot;coding&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;uisp -dprog=stk500 -dserial=/dev/ttyS0 -dspeed=115200 -dpart=atmega128&lt;br /&gt;
     --erase --upload if=led01.hex&lt;br /&gt;
Firmware Version: 49.48&lt;br /&gt;
Atmel AVR ATmega128 is found.&lt;br /&gt;
Uploading: flash&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
If everything worked well, your LED should start blinking.&lt;br /&gt;
&lt;br /&gt;
[[led-hardware.html|Previous]] [[led.html|Contents]] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Harald</name></author>	</entry>

	</feed>