D) Timer Overflow Interrupt - Motorola 68HC12 User Manual

Table of Contents

Advertisement

Timer Overflow Interrupt:
Operation
The Timer Overflow Interrupt (TOI) functions by generating an interrupt every time
the "free running" counter overflows.
and is constantly running in the background when the timer is enabled.
The TOI is set up in the _H12TMSK2 register by writing a one to Timer Overflow
Interrupt Enable (TOIE).
Whenever the interrupt is triggered the ISR will be called and executed.
must clear the flag by writing a one to the Timer Overflow Flag in the _H12TFLG2
register.
_H12TMSK2:
bit 7
bit 6
TOIE
unused
_H12TFLG2:
bit 7
bit 6
TOF
unused
Sample Code
This code calls an interrupt every time the Timer Overflow Interrupt occurs.
_ _mod2_ _ void TimerOvfInt(); // function prototype
void _ _main()
{
DB12->SetUserVector(TimerOvf, TimerOvfInt);
_H12TMSK2=0x80;
_H12TSCR=0x80;
while(1)
{
}
}
_ _mod2_ _ void TimerOvfInt()
{
DB12->printf("Overflow interrupt");
_H12TFLG2=0x80;
}
After this has been done the Timer can be enabled.
bit 5
bit 4
TPE
TDRB
bit 5
bit 4
unused
unused
The free running counter is a 16 bit value
bit 3
bit 2
TCRE
PR2
bit 3
bit 2
unused
unused
// enable interrupt
// enable the timer
// idle loop
// Timer Overflow ISR
// clear the flag
19
bit 1
bit 0
PR1
PR0
bit 1
bit 0
unused
unused
The ISR

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents