26
IRQ Interrupt:
Operation
The IRQ is used to generate external interrupts. There are two basic modes of
operation for the IRQ. One is falling edge triggered, the other is low level
detection. The mode of the IRQ is controlled by _H12INTCR. IRQEN is used to turn
on the IRQ. When this bit is set to 1 the IRQ is enabled, when it is set to zero
the IRQ is disabled. IRQE determines whether low level or edge triggered operation
will be used. When this bit is 0, the IRQ will use low level detection. When it
is 1 the IRQ will be falling edge triggered. The IRQ is automatically cleared by
the hardware in the 68HC12.
There are a few differences between the IRQ on the HC11 and the HC12. Unlike the
HC11, the IRQ is not time protected. IRQEN may be written to and read from at any
time. The value of IRQE, however, may only be written once in the program.
_H12INTCR:
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
IRQE
IRQEN
DLY
unused
unused
unused
unused
unused
Sample Code
This is sample code that triggers the IRQ every time a falling edge is detected.
This assumes there is a switch of some sort on the IRQ input to generate the
falling edge.
_
_mod2_
_ void IRQInt();
// function prototype
void _
_main()
{
DB12->SetUserVector(IRQ, IRQInt);
// set up the vector
_H12INTCR=0xC0;
// set up the IRQ for falling edge triggered
while(1)
// infinite loop
{
}
}
_
_mod2_
_ IRQInt()
// IRQ ISR
{
DB12->printf("IRQ triggered");
// display a message
}