/* * EEPROM.c * * Created: 5.6.2014 16:22:37 * Author: maticpi */ #include #include void Init(); int main(void) { char resetCounter; Init(); resetCounter=eeprom_read_byte( (uint8_t*) 0 ); //read the content of EEPROM address 0 (factory default equals 0xFF) resetCounter++; //increment reset counter eeprom_update_byte( (uint8_t*) 0, resetCounter); //and write the new value to the same address PORTB=resetCounter; //display reset counter on PORTB LEDs while(1) { } } void Init() { //IO port PORTA=0x08; //0000 1000 PORTB=0x00; //0000 0000 PORTC=0x3E; //0011 1110 PORTD=0x7D; //0111 1101 //1-output, 0-input DDRA=0xF0; //1111 0000 DDRB=0xFF; //1111 1111 DDRC=0xC1; //1100 0001 DDRD=0x82; //1000 0010 }