#include /* common defines and macros */ #include /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12c32" #define NUM_TASKS 3 /* A global variable to hold the task enable flags */ unsigned char interrupt_pattern=0; /* A global variable incremented by the idle() function */ long int idle_count=0; interrupt 7 void RTI_handler(void) { /* * This function sets the task enable bits in * the 'interrupt_pattern' variable. * You probably don't need to modify this code * unless there is a problem or improvement. */ static short int countdown=3; CRGFLG_RTIF = 1; /* Set RTI flag to reset counter (MUST do this each time) */ if( countdown == 3 ) interrupt_pattern |= 3; else interrupt_pattern |= (countdown & 1); if(--countdown < 0 ) countdown = 3; } interrupt 6 void IRQ_handler(void) { /* Your IRQ button task code goes here. * Your code must set bit 2 (...bit3:bit2:bit1:bit0) of the * global variable interrupt_pattern to '1' * without altering any other bits. */ } void func0(void) { /* your code for task 0 goes here */ } void func1(void) { /* your code for task 1 goes here */ } void func2(void) { /* your code for task 2 goes here */ } void idle(void) { /* your code for the "idle" task goes here */ } void main(void) { /* For Exercise #2, Declare an array named "func_table" to contain * NUM_TASKS pointers to functions with no return and no arguments. */ /* Assign the pointers in func_table to be the function * addresses func0, func1, and func2 */ /* Do your initializations, set the RTI period to 1.024ms, enable interrupts, activate ports, etc. * Make the IRQ interrupt edge triggered */ /* Insert your task test code here. * */ } /* end of main() */