Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mega8535.h>
- unsigned int timecount = 0; // global counter variable
- interrupt [TIM0_OVF] void timer0_ovf_isr(void)
- {
- TCNT0 = 131; // reload value for 0.004s ticks
- if (++timecount == 250)
- {
- PORTA ^= 0x01; // toggle PORTA.0
- timecount = 0; // clear for next 500ms interval
- }
- }
- void main(void)
- {
- PORTA=0x00; // PORTA LOW
- DDRA=0x01; // PORTA.0 AS OUTPUT
- TCCR0=0x05; // set system clock/1024 for Timer 0 input
- TCNT0=0x00; // start timer with 0 in timer
- TIMSK=0x01; // unmask Timer 0 overflow interrupt
- #asm("sei") // global enable interrupts
- while (1)
- ; // Do nothing (yet)
- }
Add Comment
Please, Sign In to add comment