Timer_A0 Up Mode: Periodic Interrupt + Square Wave
TA0 counts from 0 up to CCR0 (up mode). On every match it raises the CCR0 interrupt and OUTMOD_4 toggles the timer output, producing a square wave at half the interrupt frequency. The main loop does nothing: the timer does all the work.
What to watch as you step
- Up mode period = CCR0 + 1 timer ticks
- OUTMOD_4 (toggle) generates the wave in hardware, with no CPU involved
- CCIE enables the CCR0 interrupt; GIE (eint) enables interrupts globally
- The dedicated CCR0 vector clears its flag automatically on ISR entry