/* DARLAN VIVIAN EDUARDO A. P. ALCHIERI THIAGO MEREGE PEREIRA */ /* I/O PORT B, DATA DIRECTION REGISTER (0 -> in, 1 -> out) */ #define DDRB (*(volatile unsigned char *)(0x17 + 0x20)) /* I/O PORT B, DATA REGISTER */ #define PORTB (*(volatile unsigned char *)(0x18 + 0x20)) /* SREG, STATUS REGISTER */ #define SREG (*(volatile unsigned char *)(0x5F)) /* TIMER/COUNTER0 CONTROL REGISTER */ #define TCCR0 (*(volatile unsigned char *)(0x53)) /* TIMSK, TIMER INTERRUPT MASK */ #define TIMSK (*(volatile unsigned char *)(0x59)) #define TIMER0 __vector_7 #define SIGNAL __attribute__ ((signal)) unsigned char count = 0x00; int main(void) { /* Enable interrupts */ SREG = 0x80; /* Select CK/1024 */ TCCR0 = 0x05; /* Enable Timer/Counter0 Interrupt */ TIMSK = 0x02; /* Set the whole port (all bits) to "output" */ DDRB = 0xff; while(1) {} return 0; } void TIMER0 (void) SIGNAL; void TIMER0 (void) { count++; /*(8000000/(2*1024*256))*16 = 244 */ if (count == 244) { /* Turns on/off all PORTB leds after 16 seconds */ PORTB = ~PORTB; count = 0; } }