Interrupt Service Routines example code and explanations
This section includes explanations of all the different interrupts and sample code
of the function.
Real Time Interrupt:
Operation
The operation of the RTI is controlled by _H12RTICTL. Bit 7 is the Real Time
Interrupt Enable (RTIE).
at which the RTI is triggered is determined by the Real Time Interrupt Rate (RTR).
The different rates are listed in Table 6.
Table 6: RTI rate
RTR2
RTR1
RTR0
0
0
0
0
0
1
0
1
0
0
1
1
1
0
0
1
0
1
1
1
0
1
1
1
_H12RTICTL:
bit 7
bit 6
RTIE
RSWAI
After the interrupt is triggered the ISR must clear the flag.
writing a one to the Real Time Interrupt Flag (RTIF) in _H12RTIFLG register.
_H12RTIFLG:
bit 7
bit 6
RTIF
unused
Sample Code
This is a simple program to count the number of RTI interrupts that have occurred.
_ _mod2_ _ void RTIInt();
int Timecount;
void _ _main()
{
DB12->SetUserVector(RTI,RTIInt);
TimeCount = 0;
_H12RTICTL=0x87;
while(1)
{
DB12->out2hex(Timecount);
}
}
_ _mod2_ _ void RTIInt()
{
Timecount++;
_H12RTIFLG=0x80;
}
Writing a one to this bit will enable the RTI.
Period___
off
1.024ms
2.048ms
4.096ms
8.196ms
16.384ms
32.768ms
65.536ms
bit 5
bit 4
RSBCK
unused
bit 5
bit 4
unused
unused
bit 3
bit 2
RTBYP
RTR2
bit 3
bit 2
unused
unused
// function prototype
// global variable
// set up interrupt vector
// set up the RTI for 65.536ms
// interrupt service routine
// clear the flag
18
bit 1
bit 0
RTR1
RTR0
This is done by
bit 1
bit 0
unused
unused
The rate
Need help?
Do you have a question about the 68HC12 and is the answer not in the manual?
Questions and answers