Title: Example 14 Real-time Interrupts
1Example 14 Real-time Interrupts
2Register Stacking for Interrupts
3MC9S12DP256B Interrupt Vectors
4(No Transcript)
5(No Transcript)
6Writing interrupt service routines in C and
setting the interrupt vector
Vector number for real-time interrupt
void interrupt 7 handler() ltlt you C code goes
here gtgt
7Real-Time Interrupt Registers
0037
80038
9Real-time Interrupts
003B
10(No Transcript)
11 Real-time interrupt RTI_init() RTI_init
sei disable interrupts ldaa 59 staa RTIC
TL set rti to 10.24 ms ldaa 80 staa CRGI
NT enable rti cli enable interrupts rts
clear_RTI_flag() clear_RTI_flag ldaa 80
staa CRGFLG clear rti flag rts
12// Example 14 Real-time interrupt include
lthidef.hgt / common defines and macros
/ include ltmc9s12dp256.hgt / derivative
information / include "main_asm.h" /
interface to the assembly module / pragma
LINK_INFO DERIVATIVE "mc9s12dp256b" void
half_sec_delay(void) unsigned short ticks,
ticks0 // RTI interrupt counts // RTI Interrupt
Service Routine void interrupt 7 handler()
ticks clear_RTI_flag()
13void main(void) PLL_init() // set system
clock frequency to 24 MHz seg7_enable()
RTI_init() while(1) seg7dec(8)
// display 8 on 7seg display
half_sec_delay() seg7_off()
// turn off 7seg display half_sec_delay()
void half_sec_delay(void) // delay for 0.5
seconds ticks0 ticks while((ticks-ticks0)lt4
9)