19
Timer Overflow Interrupt:
Operation
The Timer Overflow Interrupt (TOI) functions by generating an interrupt every time
the "free running" counter overflows. The free running counter is a 16 bit value
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). After this has been done the Timer can be enabled.
Whenever the interrupt is triggered the ISR will be called and executed. The ISR
must clear the flag by writing a one to the Timer Overflow Flag in the _H12TFLG2
register.
_H12TMSK2:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
TOIE
unused
TPE
TDRB
TCRE
PR2
PR1
PR0
_H12TFLG2:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
TOF
unused unused unused unused
unused
unused
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;
// enable interrupt
_H12TSCR=0x80;
// enable the timer
while(1)
// idle loop
{
}
}
_
_mod2_
_ void TimerOvfInt()
// Timer Overflow ISR
{
DB12->printf("Overflow interrupt");
_H12TFLG2=0x80;
// clear the flag
}
Summary of Contents for 68HC12
Page 31: ...31 ...