Easy start with AVR EEPROM using WinAVR

AVR microcontrollers are loaded with some amount of EEPROM (Electronically Erasable Read-Only Memory ) memory. This is a handy feature allowing developers to store program parameters like service information, constants, menu strings, etc. Atmel states that AVR EEPROM memory can be rewritten over 1000000 times. Reading is unlimited. In this article, I am going to show how to store data to EEPROM by defining variables. For this, we need to include eeprom.h header from avr directory (#include “avr/eeprom.h” ). Then we can write a simple variable declaration using the simple attribute EEMEM: EEMEM keyword indicates to the compiler that variables are stored in EEPROM, and it creates a separate .eep file that has to be written to chip separately. Se what I have got after compiling the above code: You can see compiler information about compiled code sizes. The bold line is indicating the size of occupied EEPROM memory. In this particular case, we see that size is 8 bytes: one-byte variable, one word (two bytes), and a five-byte array – total 8bytes. Open .eep file located in the project folder. The compiler compiled Intel Hex File of EEPROM data: :0800000054657374005555109E :00000001FF The first line shows 8-byte data stored at…

Continue reading