H) Input Capture Interrupt - Motorola 68HC12 User Manual

Table of Contents

Advertisement

Input Capture Interrupt:
Operation
Like the output compare interrupt, the input capture interrupt is very similar to
the non-interrupt based input capture. The _H12TIOS and _H12TCTL3 and _H12TCTL4 are
set up the same as for the non-interrupt input capture.
_H12TMSK1 is used to determine which channel(s) will be used to generate an
interrupt(s).
Each bit in _H12TMSK1 corresponds to a different input capture
channel.
When the interrupt is generated, the ISR for that channel is called and
executed.
The flag must be cleared by writing a one to the bit in the _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 input capture generates an interrupt.
_ _mod2_ _ void Timer0Int();
void _ _main()
{
DB12->SetUserVector(Timer0, Timer0Int);
_H12TIOS=0x00;
_H12TMSK1=0x01;
_H12TCTL3=0x5A;
_H12TCTL4=0x5F;
_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 input capture
// enable the interrupt on pin 0
// IC7, IC6 rising edge, IC5, IC4 falling edge
// IC3, IC2 rising edge, IC1, IC0 any edge
// enable the timer
// wait
// Output Compare ISR
// clear the flag
bit 3
bit 2
C3I
C2I
bit 3
bit 2
C3F
C2F
24
The difference is that
bit 1
bit 0
C1I
C0I
bit 1
bit 0
C1F
C0F

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents