@JohnInTX
Thanks for pointing that out;
I assumed wrongly that the tutorial was doing that for the other interrupts it discussed, not TMR0. However, on re-reading this:
Thanks for pointing that out;
I assumed wrongly that the tutorial was doing that for the other interrupts it discussed, not TMR0. However, on re-reading this:
I see the author intended it for TMR0 too in Step 7. Glad to see you agree it's not needed.Code
Below are the steps for configuring and using the Timer0 for delay generation:
- Calculate the Timer Count for the required delay.
- Set the Presaclar bits in OPTION_REG as per the delay calculations.
- Clear the PSAbit for using the prescalar.
- Select the Clock Source Internal/External using TOCS bit.
- Load the timer value into TMRO register.
- Enable the Timer0 Interrupt by setting TMR0IE bit
- Enable the Global and Peripheral interrupts by setting GIE and PIE bits