C program to use real time interrupt
/* Decrement Port B using RTI interrupt */
#include "hc12.h"
main()
{
DDRB = 0xff; /* Make Port B output */
PORTB = 0x00; /* Clear Port B */
RTICTL = 0x87; /* Enable RTI interrupt; rate = 65 ms */
RTIFLG = 0x80; /* Clear RTI flag */
enable(); /* Enable interrupts (clear I bit) */
while (1)
{
_asm("wai") ; /* Do nothing - go into low power mode */
}
}
@interrupt void rti_isr(void)
{
PORTB = PORTB - 1; /* Decrement Port B */
RTIFLG = 0x80; /* Clear RTI flag */
}
vector.c file for setting interrupt vectors
/* INTERRUPT VECTORS TABLE 68HC12
*/
void toi_isr(); /* Timer overflow ISR */
void toi_isr(); /* Real Time Interrupt ISR */
/* Vectors at 0xFFD0 on standard HC12; remapped to 0x0B10 with D-Bug 12 */
void (* const _vectab[])() = {
0, /* BDLC */
0, /* ATD */
0, /* reserved */
0, /* SCI0 */
0, /* SPI */
0, /* Pulse acc input */
0, /* Pulse acc overf */
toi_isr, /* Timer overf */
0, /* Timer channel 7 */
0, /* Timer channel 6 */
0, /* Timer channel 5 */
0, /* Timer channel 4 */
0, /* Timer channel 3 */
0, /* Timer channel 2 */
0, /* Timer channel 1 */
0, /* Timer channel 0 */
rti_isr, /* Real time */
0, /* IRQ */
0, /* XIRQ */
0, /* SWI */
0, /* illegal */
0, /* cop fail */
0, /* cop clock fail */
(void *)0xff80, /* RESET */
};