Tutorial 10: Timer0 Infinite Interrupt Loop

Timer0 is configured as a Timer without a prescalor and with an interrupt on overflow. However, the interrupt Vector does not clear the Timer0 Interrupt flag hence when the Interrupt Handler returns the interrupt routine is immediately revectored causing an infinitly looping Interrupt Vector.

Description

When an interrupt occurs, the Global Interrupt flag is switched off during the interrupt handler. At the end of the interrupt handler it is switched back on the RETFIE instruction. However, if the condition that caused the interrupt has not been addressed then the interrupt logic will detect the same condition and re-vector to the interrupt handler immediately. In this example, the Timer0 interrupt flag <TOIF> <INTCON><0> is set by the Timer0 overflow but is not cleared by the Interrupt handler.

Download FEATURE877_Tutorial10.zip and unzip into folder <your path>\Tutorial 10

Filename Version Description
tut10.pjt 1.0 MPLAB Project
tut10.asm 1.0 PIC16F877 Assembler code
tut10.hex 1.0 Precompiled HEX
tut10.lst 1.0 Precompiled LST
tut10.vbb 1.0 Virtual Breadboard simulation

 

Demonstrates

Timer0 Timer Mode

Timer0 Interrupt

Immediate Interrupt Revectoring