/* * TimeMgt.c * * Example program for the timer_hw module. * * Created: 22-06-2013 17:45:54 * Author: pf */ #include #include "timer_hw.h" /* Create mask for Timer0 Overflow Flag */ #define TMR0OVF (TIFR & (1 << OCF0)) int main(void) { /* Inner counter */ uint16_t j=0; /* DDRA is Port A Data Direction Register */ /* All bits in Port A are set as outputs */ DDRA = 0xFF; PORTA = 0x00; /* Set timer to f=1kHz */ set_timer(1000); while(1) { /* Test TMR0 Overflow Flag */ if(TMR0OVF){ TIFR = 0x02; /* Reset OCF0 */ j++; if(j>=500){ j=0; /* Reset j */ PORTA ^= 0x01; /* Toggle bit 0 in PORTA */ } } } }