#define DDRB (*(volatile unsigned char *)(0x37)) #define PORTB (*(volatile unsigned char *)(0x38)) #define TIMSK (*(volatile unsigned char *)(0x59)) #define TIFR (*(volatile unsigned char *)(0x58)) #define TCCR0 (*(volatile unsigned char *)(0x53)) #define SREG (*(volatile unsigned char *)(0x5f)) #define ENTRADA 0xff #define SAIDA 0x00 #define ACENDE 0x00 #define APAGA 0xff #define IRQ0 __vector_1 #define IRQ7 __vector_7 #define SIGNAL __attribute__ ((signal)) #define VL_PARADA 27 #define NUM_OVERFLOWS 900 void IRQ7(void) SIGNAL; int main(void) { SREG = 0x80; //habilita as interrupções TCCR0 = 0x04; //overflow para 256 TIMSK = 0x02; //interupção por overflow DDRB = ENTRADA; PORTB = APAGA; while(1) {} return 0; } void IRQ7(void) { static int num_overs = 0; num_overs++; if (num_overs == NUM_OVERFLOWS) { num_overs = 0; PORTB = ~PORTB; } }