Embedded System Applications 4.8 Programming Timer0 Interrupt
In the previous chapter we use a timer to generate time delay. The delay loops will pause our program. We have to wait until the timer flag is raised when the timer rolls over. The problem with this method is that the microcontroller is tied down waiting for TMR0IF to be raised, and cannot do anything else.
Using interrupt avoids tying down the controller. The best thing about timer interrupts is that they work in the background and we donβt have to wait for them. When they finish work, they will produce an interrupt. It is like an alarm clock. In this chapter we will use hardware timer interrupt to perform multitasking and real-time application.
Figure 4.4: Timer Interrupt logic diagram
INTCON β Interrupt Control Register
Table 4.8: Interrupt Control Register
Interrupt priority for Timer0 is determined by the value contained in the interrupt priority bit, TMR0IP (INTCON2).
64