#include #include #include #include #include int main(void); volatile unsigned char flash; //************************************************************************************************* ISR(TIMER2_OVF_vect) { flash++; } ISR(EE_READY_vect) { PORTC |=_BV(PC0); // We should never be here while(1); // LED off and hang } //************************************************************************************************* int main(void) { SFIOR |=_BV(PUD); // disable all pullups wdt_disable(); // disable watchdog timer // Initial port states PORTA = 0; PORTB = 0; PORTC = 0xFF; // leds off on stk500 PORTD = 0; PORTE = 0; PORTF = 0; // Setup port directions DDRA |=0xFF; // PA all outputs DDRB |=0xFF; // PB all outputs DDRC |=0xFF; // PC all outputs DDRD |=0xFF; // PD all outputs DDRE |=0xFF; // PE all outputs DDRF |=0xFF; // PF all outputs //Setup timer 0 // Setup timer 2 TCCR2 |= _BV(WGM20); // phase correct pwm TCCR2 |= _BV(COM21); TCCR2 |= _BV(CS20); // Clock at fosc // enable timer int's TIMSK |= _BV(TOIE2); // timer 2 overflow int enable sei(); // enable global interrupts // blink once PORTC &=~_BV(PC0); // LED on flash=1; while(flash); // wait a bit // read eeprom cli(); flash=eeprom_read_byte(0); sei(); // flash fast while(1) { if(flash & 0x80) PORTC |=_BV(PC0); else PORTC &=~_BV(PC0); }; return 0; }