36 lines
437 B
C
36 lines
437 B
C
|
#include <avr/io.h>
|
||
|
#include <avr/interrupt.h>
|
||
|
|
||
|
volatile uint8_t state;
|
||
|
volatile uint8_t count;
|
||
|
|
||
|
|
||
|
ISR(TIMER0_OVF_vect)
|
||
|
{
|
||
|
if(++count == 100){
|
||
|
count = 0;
|
||
|
state = (state+1) % 2;
|
||
|
if(state){
|
||
|
PORTC &= ~(1<<PC0);
|
||
|
}
|
||
|
else{
|
||
|
PORTC |= (1<<PC0);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
int main(void) {
|
||
|
DDRC |= _BV(PC0);
|
||
|
PORTC &= ~_BV(PORTC0);
|
||
|
|
||
|
TCCR0A |= (1<<COM0A0);
|
||
|
TCCR0B |= _BV(CS02) | _BV(CS00);
|
||
|
|
||
|
TIMSK0 |= _BV(TOIE0);
|
||
|
|
||
|
sei();
|
||
|
|
||
|
for(;;);
|
||
|
|
||
|
return 0;
|
||
|
}
|