Download presentation
Presentation is loading. Please wait.
1
Example 14 Real-time Interrupts
Lecture L6.1
2
Register Stacking for Interrupts
3
MC9S12DP256B Interrupt Vectors
6
void interrupt 7 handler(){ << you C code goes here >> }
Writing interrupt service routines in C and setting the interrupt vector Vector number for real-time interrupt void interrupt 7 handler(){ << you C code goes here >> }
7
Real-Time Interrupt Registers
$0037
8
$0038
9
Real-time Interrupts $003B
11
; Real-time interrupt ; RTI_init(); RTI_init: sei ;disable interrupts ldaa #$59 staa RTICTL ;set rti to ms ldaa #$80 staa CRGINT ;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 <hidef.h> /* common defines and macros */ #include <mc9s12dp256.h> /* 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(); }
13
void 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 } void half_sec_delay(void){ // delay for 0.5 seconds ticks0 = ticks; while((ticks-ticks0)<49) {
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.