G) Output Compare Interrupt - Motorola 68HC12 User Manual

Table of Contents

Advertisement

Output Compare Interrupt:
Operation
The output compare interrupt calls an ISR every time a successful output compare is
detected.
The output compare is setup like the non- interrupt based output
compare, with the major difference being that the action which is to occur on a
successful compare does not need to be specified.
determine which channel(s) will be used to generate an interrupt(s).
_H12TMSK1 corresponds to a different output compare channel.
generated, the ISR for that channel is called and executed.
cleared by writing a one to the bit _H12TFLG1 register that corresponds to the
channel which triggered the interrupt.
_H12TMSK1:
bit 7
bit 6
C7I
C6I
_H12FLG1:
bit 7
bit 6
C7F
C6F
Sample Code
This code calls the ISR when the Output Compare 0 generates an interrupt.
_ _mod2_ _ void Timer0Int();
void _ _main()
{
DB12->SetUserVector(Timer0, Timer0Int);
_H12TIOS=0xFF;
_H12TMSK1=0x01;
_H12TC0=0x8000;
_H12TSCR=0x80;
while(1)
{
}
}
_ _mod2_ _ void Timer0Int()
{
DB12->printf("timer int");
_H12TFLG1=0x01;
}
bit 5
bit 4
C5I
C4I
bit 5
bit 4
C5F
C4F
// function prototype
// select output compare
// enable the interrupt on pin 0
// set the value to be compared against
// enable the timer
// wait
// Output Compare ISR
// clear the flag
Instead, _H12TMSK1 is used to
bit 3
bit 2
C3I
C2I
bit 3
bit 2
C3F
C2F
23
Each bit in
When the interrupt is
The flag must be
bit 1
bit 0
C1I
C0I
bit 1
bit 0
C1F
C0F

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents