/*This program is used to test prototype board that blinks the LEDs on PORTB every second on a Mega32 MCU*/ #include #include #include #define begin { #define end } // Declare your global variables here unsigned char reload; unsigned int time0; //********************************************************** //timer 0 overflow ISR interrupt [TIM0_OVF] void timer0_overflow(void) begin //reload to force 1 mSec overflow TCNT0=reload; //clear the flag, task1 should be executed time0++; end //********************************************************** void initialize(void) { //output LED DDRB=0xff; PORTB=0xff; // Timer/Counter 0 initialization time0=0; reload=256-125; TCCR0=0x03 ; TCNT0=reload; TIMSK=1; OCR0=0x00; #asm ("sei"); } void main(void) { initialize(); while (1) { if (time0==2000) { PORTB=~PORTB; time0=0; } } }