#include inline void init(){ avr = (struct LAYOUT * ) IO_MEMORY_OFFSET; }; inline void led_on(short value){ avr->ddrB = SET; avr->portB = value; }; //the input for the led method is the pressed //key in the input D port inline void listen(){ led_on( avr->inD ); }; inline void enable_int(){ avr->status_reg = (1<<7) ; //global interruption enable bit avr->gen_int_mask = (1<<7) ; //external INT1 enable, software interruption avr->portD = (1<<3); //enable portD int1 avr->tc_int_mask = (1<<1); //interrupt generator }; //page 34 stop the timer inline void clock_stop(){ avr->tc0_control_reg = ( 0<<2 | 0<<1 | 0<<0 ); }; //page 34 enable the timer clock as CK/1024 inline void clock_start(){ //we neet to set the overflow time avr->tc0_control_reg = ( (1<<2) | (0<<1) | (1<<0) ); }; // interruption handlers void __vector_2 (void) __attribute__((signal)); void __vector_2 (void) { clock_start(); }; unsigned int timer=0; void __vector_7 (void) __attribute__((signal)); void __vector_7 (void) { //led_on(NONE); timer++; if(timer == 81){ timer = 0; led_on(LED3); } } /* MAIN */ int main(){ init(); clock_stop(); enable_int(); while(TRUE); };