<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Tinkerlog &#187; winavr</title>
	<atom:link href="http://tinkerlog.com/category/winavr/feed/" rel="self" type="application/rss+xml" />
	<link>http://tinkerlog.com</link>
	<description>Alex' blog</description>
	<lastBuildDate>Sun, 13 May 2012 10:54:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>avrdude 5.4 for Windows</title>
		<link>http://tinkerlog.com/2007/07/15/avrdude-54-for-windows/</link>
		<comments>http://tinkerlog.com/2007/07/15/avrdude-54-for-windows/#comments</comments>
		<pubDate>Sun, 15 Jul 2007 11:13:41 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[winavr]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/2007/07/15/avrdude-54-for-windows/</guid>
		<description><![CDATA[I had some problems with the avrdude 5.3.1. It complains about reading the  fuses properly.
Verify error - unable to read lfuse properly. Programmer may not be
reliable.
A workaround is to use the -u switch to override this check. As the new version with this bug fixed is not available for windows, I tried to compile [...]]]></description>
			<content:encoded><![CDATA[<p>I had some problems with the avrdude 5.3.1. It complains about reading <span>the  fuses properly.</span></p>
<pre class="prettyprint">Verify error - unable to read lfuse properly. Programmer may not be
reliable.</pre>
<p>A workaround is to use the -u switch to override this check. As the new version with this bug fixed is not available for windows, I tried to compile it myself. I used MinGW and MSYS and it worked, at least for me. I can now even omit the -F switch, which I had to use before, as the device signature was not read properly. If you want to try it, here you go.</p>
<p>Download: <a href="http://tinkerlog.com/wp-content/uploads/2007/07/avrdude-5.4-win.zip" title="avrdude 5.4 windows">avrdude 5.4 windows</a></p>
<p>Please note, that this comes without any warranty and is not completly tested or verified.</p>
]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2007/07/15/avrdude-54-for-windows/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Using PROGMEM and EEMEM with AVRs</title>
		<link>http://tinkerlog.com/2007/06/16/using-progmem-and-eemem-with-avrs/</link>
		<comments>http://tinkerlog.com/2007/06/16/using-progmem-and-eemem-with-avrs/#comments</comments>
		<pubDate>Sat, 16 Jun 2007 12:58:31 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[avr]]></category>
		<category><![CDATA[winavr]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/2007/06/16/using-progmem-and-eemem-with-avrs/</guid>
		<description><![CDATA[This post will give you a short example how to read and write EEPROM, and how to use flash memory as storage.
When you are jumping into programming microcontrollers many things are new and uncommon. At least to me as I used to develop in Java. This snippet may save you some time when you start [...]]]></description>
			<content:encoded><![CDATA[<p>This post will give you a short example how to read and write EEPROM, and how to use flash memory as storage.</p>
<p>When you are jumping into programming microcontrollers many things are new and uncommon. At least to me as I used to develop in Java. This snippet may save you some time when you start playing with EEPROM and flash storage. Please note, that this is not a complete tutorial on this topic. You may find usefull links in the link section below.</p>
<p><span id="more-11"></span></p>
<p><strong>Motivation</strong></p>
<p>Why you want to use EEPROM storage should be clear. You will have permanent storage, even if the controller gets resetted. EEPROM can be read and written by your program at runtime or it can be written by programmer software, together with your program.</p>
<p>As you may know, or encounter in the future, RAM is an extremely tight resource. If you are dealing with strings, most of them are constant. They will be used as labels or messages with no need to change them. But the compiler will copy them from SRAM, thats where you program is stored, into RAM, thats where you variables go. The reason for that is that all library methods are dealing with strings, expect them to be pointers in RAM. But there is a way to overcome this waste of our exclusive RAM.</p>
<p><strong>Example</strong></p>
<p>Here is a short program for the ATmega8. It should be usable for a most of the AVR family.  It stores values in EEPROM and messages in flash. On startup, it increments a counter to count the reboots. This counter is saved in EEPROM. Values and messages are printed out with the UART. Then the values are modified and printed out again.</p>
<pre class="prettyprint">
/*
 * testing eeprom and flash storage
 */
#include &lt;inttypes.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;avr/io.h&gt;
#include &lt;avr/interrupt.h&gt;
#include &lt;avr/eeprom.h&gt;
#include &lt;avr/pgmspace.h&gt;
#include "uart.h"

// eeprom storage
uint16_t reboot_counter_ee EEMEM = 0;
uint8_t config_ee[15] EEMEM = "testing ...";

// string in flash
const char firm_version_P[] PROGMEM = "test v0.01 2007/06/16rn";
const char reboots_fmt_P[] PROGMEM = "reboots: %drn";

void inc_reboot(void) {
  uint16_t reboots = eeprom_read_word(&amp;reboot_counter_ee);
  reboots++;
  eeprom_write_word(&amp;reboot_counter_ee, reboots);
}

void show(void) {
  char buffer[50];
  uint16_t reboots;

  uart_puts_P(firm_version_P);

  reboots = eeprom_read_word(&amp;reboot_counter_ee);
  sprintf_P(buffer, reboots_fmt_P, reboots);
  uart_puts(buffer);

  eeprom_read_block(buffer, config_ee, 15);
  uart_puts(buffer);
  uart_puts("rn");
}

void modify(void) {
  char tmp[] = "123ï¿½";
  eeprom_write_block(tmp, config_ee, 4);
}

int main(void) {
  inc_reboot();
  init_uart();
  sei();

  show();
  modify();
  show();

  while (1) {}

  return 0;
}</pre>
<p><strong>Notes</strong></p>
<ul>
<li> If you want to write values to EEPROM with your programmer, be sure to generate an eeprom file. This can be achieved with:
<pre class="prettyprint">  avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 -O ihex &lt;yourfile&gt;.exe &lt;yourfile&gt;.eep</pre>
</li>
<li>If you generated your eep file, be sure to upload it. I did it with avrdude.
<pre class="prettyprint">  c:winavrbinavrdude -v -F -p ATmega8 -c avr910 -P com4 -U eeprom:w:&lt;yourfile&gt;.eep:i</pre>
</li>
<li>Be sure to write the eep <em>after</em> you have written your program, as avrdude automatically does an erase cylce which clears the eeprom as well. Otherwise you will see unprogrammed eeprom storage. You can try to suppress the erase with option -D but that does not work for me (errors in verification). If you want to preserve your eeprom while programming, you have to protect it by setting the &#8220;preserve EEPROM&#8221; fuse. That should be used if development and testing is over.</li>
</ul>
<p><strong>Links</strong></p>
<ul>
<li> A great tutorial on <a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;t=38003" title="[TUT] [C] GCC and the PROGMEM Attribute">PROGMEM</a> over at AVRFreaks. Be sure to read the complete thread as you might miss corrections otherwise.</li>
<li>Another great tutorial on <a href="http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;file=viewtopic&amp;t=38417" title="[TUT] [C] Using the EEPROM memory in AVR-GCC">EEPROM</a> written also by Dean.</li>
<li>Also very helpful was this post on <a href="http://www.scienceprog.com/easy-start-with-avr-eeprom-using-winavr/" title="Easy start with AVR EEPROM using WinAVR">EEPROM</a> at Scienceprog.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2007/06/16/using-progmem-and-eemem-with-avrs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Programming AVR with Eclipse and WinAVR</title>
		<link>http://tinkerlog.com/2007/06/03/programming-avr-with-eclipse-and-winavr/</link>
		<comments>http://tinkerlog.com/2007/06/03/programming-avr-with-eclipse-and-winavr/#comments</comments>
		<pubDate>Sun, 03 Jun 2007 06:17:02 +0000</pubDate>
		<dc:creator>Alex</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[winavr]]></category>

		<guid isPermaLink="false">http://tinkerlog.com/2007/06/03/programming-avr-with-eclipse-and-winavr/</guid>
		<description><![CDATA[This is a log of what I have done to get Eclipse running with WinAVR on Windows XP. Maybe it&#8217;s helpfull for others.
Prerequisites

Download a Java Runtime JRE or JDK, if you do not have already. Anything greater 1.4.2 should be ok.
Download Eclipse 3.2.2 here 
 Download the CDT 3.1.2 plugin for Eclipse C/C++ development here
Download [...]]]></description>
			<content:encoded><![CDATA[<p>This is a log of what I have done to get Eclipse running with WinAVR on Windows XP. Maybe it&#8217;s helpfull for others.<br />
<strong>Prerequisites</strong></p>
<ul>
<li>Download a Java Runtime JRE or JDK, if you do not have already. Anything greater 1.4.2 should be ok.</li>
<li>Download Eclipse 3.2.2 <a href="http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops/R-3.2.2-200702121330/eclipse-SDK-3.2.2-win32.zip" title="Eclipse 3.2.2">here </a></li>
<li> Download the CDT 3.1.2 plugin for Eclipse C/C++ development <a href="http://download.eclipse.org/tools/cdt/releases/callisto/dist/3.1.2" title="CDT Plugin">here</a></li>
<li>Download WinAVR  20070525 <a href="http://sourceforge.net/project/showfiles.php?group_id=68108" target="_blank" title="External link to http://sourceforge.net/project/showfiles.php?group_id=68108" class="externalLink"></a><a href="http://sourceforge.net/project/showfiles.php?group_id=68108" title="WinAVR">here</a></li>
</ul>
<p><span id="more-10"></span><br />
<strong>Install WinAVR</strong></p>
<p>Start the executable and choose a directory to install to. Mine goes to c:\winavr-20070525.</p>
<p><strong>Install Eclipse</strong></p>
<p>Extract the downloaded zip into a directory, e.g. c:\Programme\eclipse. Eclipse is now already working. You may want to create a desktop shortcut for the executable.</p>
<p><strong>Install CDT</strong></p>
<p>Extract the zip into a tmp directory. Then select the contents of the features and plugins folder and copy them to the respective folders beneath the eclipse folder.</p>
<p><strong>Startup</strong></p>
<ul>
<li>Open eclipse. It will ask for a workspace folder. If you are new to eclipse, choose a folder, where you would like to put your source code.</li>
<li>It starts with the Java perspective, but we want C/C++. Select &#8220;Open Perspective&#8221; from the upper right corner. Then select &#8220;Other&#8221;. Then select &#8220;C/C++&#8221;. Your screen should now show the perspective for C development.</li>
</ul>
<p><strong>Start a Project</strong></p>
<ul>
<li>Now select &#8220;File/New&#8221; of the menu. Then select &#8220;Managed make C project&#8221;. This creates a project with automated make. You do not have to take care of the makefile yourself.</li>
<li>Enter &#8220;test&#8221; as project name and select &#8220;next&#8221;.</li>
<li>Select &#8220;executable (gnu on windows)&#8221; as Project type. We will change this later.</li>
<li>&#8220;Debug&#8221; and &#8220;Release&#8221; are ok as targets. Release only is also ok.</li>
<li> Select &#8220;finish&#8221;.</li>
<li> Ignore the warning for now that appears in the problems tab.</li>
</ul>
<p><strong>Configuration</strong></p>
<p>Now we have to configure the settings for the WinAVR compiler and linker.</p>
<ul>
<li> Select &#8220;Project -&gt; properties&#8221;. If &#8220;properties&#8221; are greyed out, then click on the project folder &#8220;test&#8221; to select it. Now the &#8220;properties&#8221; menu should be selectable.</li>
<li> Select &#8220;C/C++ Build&#8221; on the left list.</li>
<li> Select &#8220;Release&#8221; as configuration. We will change this target only. If you want to configure the &#8220;Debug&#8221; target as well, then go through these steps again.</li>
<li>Select the &#8220;GCC C Compiler&#8221; in the tree below.</li>
<li> Change &#8220;gcc&#8221; to &#8220;avr-gcc&#8221;</li>
<li> Select &#8220;symbols&#8221; and enter a new symbol for the speed of your board,  e.g. &#8220;F_CPU=4096000&#8243;.</li>
<li> Select &#8220;Directories&#8221; and add &#8220;C:\WinAVR-20070525\avr\include&#8221; to the includes.</li>
<li> Select &#8220;Miscellaneous&#8221; and enter your type of controller, e.g. &#8220;-mmcu=atmega8&#8243;.</li>
<li> Select &#8220;GCC C Linker&#8221; and change &#8220;gcc&#8221; to &#8220;avr-gcc&#8221;.</li>
<li> Select the tab &#8220;Build Steps&#8221;.</li>
<li> To convert the executable into a hex file, we use a post build step. Enter &#8220;Post-build step&#8221; as<br />
<code>"avr-objcopy -j .text -j .data -O ihex test.exe test.hex".</code></li>
<li>Select &#8220;ok&#8221; to close the properties dialog.</li>
</ul>
<p><strong>Testing the Configuration</strong></p>
<ul>
<li>Right-click on your project folder and select &#8220;New -&gt; Source File&#8221;</li>
<li>Enter &#8220;test.c&#8221;. Now write a small test program.
<pre class="prettyprint">

/*
 * test.c
 */
#include &lt;util/delay.h&gt;
#include &lt;avr/io.h&gt;
#define LED PD4

int main(void) {
  // define pd4 as output
  DDRD |= (1 &lt;&lt; LED);

  while (1) {
    PORTD |= (1 &lt;&lt; LED);    // switch on
    _delay_ms(100);
    _delay_ms(100);
    PORTD &amp;= ~(1 &lt;&lt; LED);    // switch off
    _delay_ms(100);
    _delay_ms(100);
  }
return 0;
}</pre>
</li>
<li>Saving triggers an automated build run. The console output should look like this:
<pre class="prettyprint">
**** Build of configuration Release for project test ****
make -k all

Building file: ../test.c
Invoking: GCC C Compiler

avr-gcc -DF_CPU=4096000 -I"C:WinAVR-20070525avrinclude" -O3 -Wall -c
-fmessage-length=0 -mmcu=atmega8 -MMD -MP -MF"test.d" -MT"test.d" -o"test.o" "../test.c"
Finished building: ../test.c

Building target: test.exe

Invoking: GCC C Linker
avr-gcc  -o"test.exe"  ./test.o
Finished building target: test.exemake --no-print-directory post-build

avr-objcopy -j .text -j .data -O ihex test.exe test.hex

Build complete for project test</pre>
</li>
<li>Now open up a command line in your project folder. Create a batch file &#8220;flash.bat&#8221; to transfer the hex file to your controller. This depends on your controller, programmer, etc. Mine looks like this:<br />
<code>c:\winavr\bin\avrdude -v -F -p ATmega8 -c avr910 -P com4 -U flash:w:%1:i. </code>The -F switch is in the to force writing, even if the device signature is not recognized. Its just reversed. Omit it if you have no problems with that.</li>
<li>Now start the batch file to program your controller.
<pre class="prettyprint">
C:dataavrtest&gt;flash Releasetest.hex
C:dataavrtest&gt;c:winavrbinavrdude -v -F -p ATmega8 -c avr910 -P com4 -U flash:w:Releasetest.hex:i

avrdude: Version 5.1cvs

         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

System wide configuration file is "c:winavrbinavrdude.conf"

Using Port            : com4
         Using Programmer      : avr910
         AVR Part              : ATMEGA8
         Chip Erase delay      : 10000 us
         PAGEL                 : PD7
         BS2                   : PC2
         RESET disposition     : dedicated
         RETRY pulse           : SCK
         serial program mode   : yes
         parallel program mode : yes
         Timeout               : 200
         StabDelay             : 100
         CmdexeDelay           : 25
         SyncLoops             : 32
         ByteDelay             : 0
         PollIndex             : 3
         PollValue             : 0x53
         Memory Detail         :

Block Poll               Page
      Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  Max
W   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ---
-- ---------
           eeprom         4    10   128    0 no        512    0      0  9000  90
00 0xff 0xff
           flash         33     6    64    0 yes      8192   64    128  4500  45
00 0xff 0x00
           lfuse          0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
           lock           0     0     0    0 no          1    0      0  2000  20
00 0x00 0x00
           calibration    0     0     0    0 no          4    0      0     0
 0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0
 0 0x00 0x00
Programmer Type : avr910
         Description     : Atmel Low Cost Serial Programmer
Found programmer: Id = "AVR ISP"; type = S
    Software Version = 2.3; Hardware Version = 2.0
Programmer supports auto addr increment.
Programmer supports the following devices:
    Device code: 0x1c = (unknown)
    Device code: 0x55 = ATtiny12
    Device code: 0x01 = ATtiny13
    Device code: 0x56 = ATtiny15
    Device code: 0x13 = AT90S1200
    Device code: 0x28 = AT90S4414
    Device code: 0x20 = ATtiny84
    Device code: 0x4c = AT90S2343
    Device code: 0x30 = AT90S4433
    Device code: 0x6c = AT90S4434
    Device code: 0x38 = AT90S8515
    Device code: 0x68 = AT90S8535
    Device code: 0x41 = ATMEGA103
    Device code: 0x46 = (unknown)
    Device code: 0x44 = (unknown)
    Device code: 0x03 = (unknown)
    Device code: 0x75 = ATMEGA6490
    Device code: 0x74 = ATMEGA6450
    Device code: 0x63 = (unknown)
    Device code: 0x64 = ATMEGA163
    Device code: 0x79 = (unknown)
    Device code: 0x14 = (unknown)
    Device code: 0x15 = (unknown)
    Device code: 0x16 = (unknown)
    Device code: 0x17 = (unknown)
    Device code: 0x72 = ATMEGA32
    Device code: 0x60 = ATMEGA161
    Device code: 0x76 = ATMEGA8
    Device code: 0x77 = (unknown)
    Device code: 0x3b = (unknown)
    Device code: 0x6a = (unknown)
    Device code: 0x5e = ATTINY26
    Device code: 0x29 = (unknown)
    Device code: 0x2a = (unknown)
    Device code: 0x2b = (unknown)
    Device code: 0x06 = (unknown)
    Device code: 0x07 = (unknown)
    Device code: 0x08 = (unknown)
    Device code: 0x21 = (unknown)
    Device code: 0x09 = (unknown)
    Device code: 0x0a = (unknown)
    Device code: 0x22 = (unknown)
    Device code: 0x23 = (unknown)
    Device code: 0x24 = (unknown)
    Device code: 0x0b = (unknown)
    Device code: 0x0c = (unknown)
    Device code: 0x0d = (unknown)
    Device code: 0x18 = (unknown)
    Device code: 0x19 = (unknown)
    Device code: 0x25 = (unknown)
    Device code: 0x26 = (unknown)
    Device code: 0x27 = (unknown)
    Device code: 0x1a = (unknown)
    Device code: 0x1b = (unknown)
    Device code: 0x4b = (unknown)
    Device code: 0x4d = (unknown)
    Device code: 0x4e = (unknown)
    Device code: 0x4f = (unknown)

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.06s

avrdude: Device signature = 0x07931e

avrdude: Expected signature for ATMEGA8 is 1E 93 07

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D9

avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed

To disable this feature, specify the -D option.

avrdude: erasing chip

avrdude: reading input file "Releasetest.hex"
avrdude: writing flash (122 bytes):
Writing | ################################################## | 100% 0.53s

avrdude: 122 bytes of flash written

avrdude: verifying flash memory against Releasetest.hex:
avrdude: load data flash data from input file Releasetest.hex:
avrdude: input file Releasetest.hex contains 122 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.25s

avrdude: verifying ...
avrdude: 122 bytes of flash verified
avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as D9
avrdude: safemode: Fuses OK

avrdude done.  Thank you.

C:dataavrtest&gt;</pre>
</li>
<li>If all went well and you see an LED flashing, congratulations, you did it.</li>
</ul>
<p><strong>Notes</strong></p>
<p>If you look closely at the steps where I program the controller, you will notice, that I do not use the avr-dude  that came with the last WinAVR release. I tried it, but it refused to work, always complaining about not beeing able to verify the fuses. I went on with my old avr-dude which worked perfect.</p>
]]></content:encoded>
			<wfw:commentRss>http://tinkerlog.com/2007/06/03/programming-avr-with-eclipse-and-winavr/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
	</channel>
</rss>

