Advertisement
avr_programmieren_rh

3 Werte EEPROM

Feb 4th, 2018
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. /*
  2. * EEPROM.c
  3. *
  4. * Created: 02.01.18 08:37:00
  5. * Author : Ron Hiestermann
  6. */
  7.  
  8. #include <avr/eeprom.h>
  9.  
  10.  
  11. #define F_CPU 16000000UL
  12. #define BAUDRATE 9600
  13. #define BAUD_PRESCALLER (((F_CPU / (BAUDRATE * 16UL))) - 1)
  14.  
  15.  
  16. uint8_t LED1 EEMEM; //Variable eeFooByte im EEPROM anlegen.
  17. uint8_t wLED1 = 9; //Variable myWByte anlegen und den Wert 1 laden. (Wird später in EEPROM geschrieben)
  18. uint8_t rLED1; //Variable für den Wert der dann aus EEPROM gelesen wird.
  19. uint8_t LED2 EEMEM; //Variable eeFooByte im EEPROM anlegen.
  20. uint8_t wLED2 = 5; //Variable myWByte anlegen und den Wert 1 laden. (Wird später in EEPROM geschrieben)
  21. uint8_t rLED2; //Variable für den Wert der dann aus EEPROM gelesen wird.
  22. uint8_t LED3 EEMEM; //Variable eeFooByte im EEPROM anlegen.
  23. uint8_t wLED3 = 2; //Variable myWByte anlegen und den Wert 1 laden. (Wird später in EEPROM geschrieben)
  24. uint8_t rLED3; //Variable für den Wert der dann aus EEPROM gelesen wird.
  25.  
  26.  
  27. int main(void)
  28. {
  29. DDRC=0xFF; //PORTC auf Output
  30. PORTC=0; //PORTC auf null stellen
  31. eeprom_write_byte(&LED1, wLED1);
  32. rLED1 = eeprom_read_byte (&LED1);
  33. eeprom_write_byte(&LED2, wLED2);
  34. rLED2 = eeprom_read_byte (&LED2);
  35. eeprom_write_byte(&LED3, wLED3);
  36. rLED3 = eeprom_read_byte (&LED3);
  37.  
  38. while (1)
  39. {
  40.  
  41. PORTC=rLED1;
  42. PORTC=rLED2;
  43. PORTC=rLED3;
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement