24
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. The difference is that
_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 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
C7I
C6I
C5I
C4I
C3I
C2I
C1I
C0I
_H12FLG1:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
C7F
C6F
C5F
C4F
C3F
C2F
C1F
C0F
Sample Code
This code calls the ISR when the input capture generates an interrupt.
_
_mod2_
_ void Timer0Int();
// function prototype
void _
_main()
{
DB12->SetUserVector(Timer0, Timer0Int);
_H12TIOS=0x00;
// select input capture
_H12TMSK1=0x01;
// enable the interrupt on pin 0
_H12TCTL3=0x5A;
// IC7, IC6 rising edge, IC5, IC4 falling edge
_H12TCTL4=0x5F;
// IC3, IC2 rising edge, IC1, IC0 any edge
_H12TSCR=0x80;
// enable the timer
while(1)
// wait
{
}
}
_
_mod2_
_ void Timer0Int()
// Output Compare ISR
{
DB12->printf("timer int");
_H12TFLG1=0x01;
// clear the flag
}