AnsweredAssumed Answered

Problems creating a simple ISR

Question asked by b04521 b04521 Employee on Aug 18, 2006
Latest reply on Aug 20, 2006 by bigmac
Using CodeWarrior 5.7.0 with an MC9S12DT256, I'm having trouble creating a simple timer interrupt. When running the following code under all three memory models, I get ILLEGAL_BP error and execution halts before the ISR ever runs. What do I need to do to get an ISR working?


#include       /* common defines and macros */
#include      /* derivative information */
#pragma LINK_INFO DERIVATIVE "mc9s12dt256b"

void tim_init (void) {
TIE = 0x01;    // Enable Tim Ch. 0
TSCR1 = 0x80;   // Enable Timer module
TSCR2 = 0x80;
TC0 = 0x0080;
}

void main(void) {
  /* put your own code here */


  DDRA = 0xFF;
  PORTA = 0x00;

  EnableInterrupts;

  tim_init();
  for(;;) {} /* wait forever */
  /* please make sure that you never leave this function */
}

#pragma CODE_SEG __NEAR_SEG NON_BANKED
interrupt 8 void tim_ch0_vector(void) {
  PORTA = 0x55;
  TFLG2 = 0x80;
}
#pragma CODE_SEG DEFAULT

Outcomes