Skip to content

Instantly share code, notes, and snippets.

@avr-programmierung
Created May 14, 2019 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avr-programmierung/b19796e191674c1c79c03f44cd94271f to your computer and use it in GitHub Desktop.
Save avr-programmierung/b19796e191674c1c79c03f44cd94271f to your computer and use it in GitHub Desktop.
ATmega88 @ 1MHz EEPROM 02
/* eeprom_02.c ATmega88 @ 1MHz */
#include <avr/io.h>
#include <avr/eeprom.h>
uint8_t x; // byte (unsigned char)
uint16_t y; // word (unsigned int)
uint32_t z; // dword (unsigned long)
int main(void)
{
eeprom_write_byte((uint8_t*) 1, 4); // schreibe den Wert 4 in die Speicherzelle 1
eeprom_write_word((uint16_t*) 2, 45218); // schreibe den Wert 45218 in die Speicherzelle 2
eeprom_write_dword((uint32_t*) 4, 145218); // schreibe den Wert 145218 in die Speicherzelle 4
x = eeprom_read_byte((uint8_t*) 1); // lese den Inhalt aus Speicherzelle 1 und speichere in x
y = eeprom_read_word((uint16_t*) 2); // lese den Inhalt aus Speicherzelle 2 und speichere in y
z = eeprom_read_dword((uint32_t*) 4); // lese den Inhalt aus Speicherzelle 2 und speichere in y
while(1)
{
asm ("NOP");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment