To achieve your target .5sec on/off with. TMR0 you can do the following.
Set the internal oscillator to 4MHz via the OSCCON register.
Set the TMR0 Prescaler to 1:32 via the OPTION_REG register.
Then set your T0Count test to "=>61" in the interrupt handler.
When the values are plugged into the equation you get the following.
Internal instruction cycle = 1 / [Oscillator Frequency / 4] = 1 / [4000000 / 4] = 1us
Timer0 Overflow Interrupt = Internal instruction cycle * Prescaler * 2^8 = 1us * 32 * 256 = 8.192ms
Time to Toggle LED2: T0Count * Timer0 Overflow Interrupt = 61 * 8.192ms = .4997 seconds
Bookmarks