1 / 13

Example 14 Real-time Interrupts

Example 14 Real-time Interrupts. Lecture L6.1. Register Stacking for Interrupts. MC9S12DP256B Interrupt Vectors. 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 >> }.

epatsy
Download Presentation

Example 14 Real-time Interrupts

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Example 14 Real-time Interrupts Lecture L6.1

  2. Register Stacking for Interrupts

  3. MC9S12DP256B Interrupt Vectors

  4. 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 >> }

  5. Real-Time Interrupt Registers $0037

  6. $0038

  7. Real-time Interrupts $003B

  8. ; Real-time interrupt ; RTI_init(); RTI_init: sei ;disable interrupts ldaa #$59 staa RTICTL ;set rti to 10.24 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

  9. // 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(); }

  10. 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 half_sec_delay(); } } void half_sec_delay(void){ // delay for 0.5 seconds ticks0 = ticks; while((ticks-ticks0)<49) { } }

More Related