Operácie

AVR Pamäťové priestory

Z SensorWiki

Verzia z 19:36, 6. november 2008, ktorú vytvoril Balogh (diskusia | príspevky) (Nová stránka: == EEPROM == How to access AVR microcontroller EEPROM (Electronically Erasable Read-Only memory) memory in C? This type of memory allows developers to store constants, parameters...)
(rozdiel) ← Staršia verzia | Aktuálna úprava (rozdiel) | Novšia verzia → (rozdiel)

EEPROM

How to access AVR microcontroller EEPROM (Electronically Erasable Read-Only memory) memory in C?

This type of memory allows developers to store constants, parameters, values and are stored also after the power loss.

To use this memory area just include eeprom.h header library from avr directory

#include "avr/eeprom.h"

Variable declaration (use an attribute EEMEM):

 #include "avr/io.h"
 #include "avr/eeprom.h"

  uint8_t EEMEM eeprombyte=0x10;              // Store a byte
 uint16_t EEMEM eepromword=0x5555;            // Store a word
  uint8_t EEMEM eepromstring[5]={"Test\0"};   // Store a string

int main(void)
{
  uint8_t RAMbyte;                            //Standard variable in RAM (byte)
 uint16_t RAMword;                            //Standard variable in RAM (word)
  uint8_t RAMstring[5];

//read byte from EEPROm and store to RAM

 RAMbyte = eeprom_read_byte(&eeprombyte);
 RAMword = eeprom_read_word(&eepromword);
 eeprom_read_block ((void *)&RAMstring, (const void *)&eepromstring,5);

return (0);
}

Don't forget that compiler creates separate .eep file which has to be written to chip separately!