Task 3a -- Timer interrupt application |
A "micro-controller" (such as the Motorola 68332) differs from a "micro-processor" (such as the Motorola 68020) in that many of the external devices on the bus of the microprocessor are actually built into the microcontroller. For many practical situations reducing the number of external components cuts down the complexity of board design, increases reliability, and decreases design cost..
One common device placed onboard a micro-controller chip is a TIMER device. Essentially this is a small "alarm clock" that is driven by the processor clock (or some sub/super harmonic of the clock). At regular intervals the clock "rings", a "timer interrupt" is produced and some useful task can then be performed.
One interesting use of the timer interrupt is the software watch dog. In many practical situations it is possible for the processor to get into an infinite loop doing one task under unexpected, special circumstances and never break out to perform other task. The "watchdog" can over come this.
In the watchdog situation, the timer interrupt service routine is designed to completely restart the processor when the "alarm rings". In each subroutine of the code is a small segment that simply "rewinds" the clock back to its original value. Provided the code keeps executing properly, each subroutine will be accessed on a regular basis and the timer value will be continually reset, so that the alarm never rings. However, if the code hangs, it is probable that the timer value will not get reset. When the alarm rings, the interrupt service routine will reset the processor, hopefully clearing the problem that was preventing normal program operation.
As the first part of Task 3, we shall make use of the on-board timer of a 68K microcontroller and the equivalent decrementer register of the PowerPC to implement a software watchdog. The ideas developed there concerning the use of interrupts can then be used to handle a normal and an interrupt driven task that is Task 3b.
![]() |
Last modified: July 22, 1996 01:30 PM by M. Smith.
Copyright -- M. R. Smith