AnsweredAssumed Answered

How to Use Interrupts In CW for HCS12

Question asked by Mouka Zwina on Dec 8, 2009

I am trying to setup a very simple program that uses interrupts in CW, but I seem to be chasing windmills.

I keep receiving some kind of error or another.

I am absolutely new to CW. I have been using GCC for some time now but wanted to take advantage of code debugging. I installed the serial monitor program and have successfully coded some simple prpograms.

But I got extremely frustrated when I tried using some very simple interrupt programs.

The project I used is extremely simple, it consists of:

main.c => I defined myinterrupt servicer routine here prepended with "interrupt 16", as I am interested in timer overflow interrupts

start_up.c => This is where I have my interrupt vector table, all of it except a couple are unimplemented ISR. I just placed Timer_Ovf_ISR in the prope place.

When I try building my project I get the following error message:

Here are my functions:

First: main.c: Don't wast your time with syntax errors, I couldn't build it. It compiles fine

but I get the following linker error:

 

Link Error: L1119: Vector Allocated at absolute address 0xFFFE overlaps with secions placed in segment .absSeg525

 

// main.c

#include <hidef.h>      /* common defines and macros */
#include "derivative.h"      /* derivative-specific definitions */

int count = 366;
int dummy;

#pragma CODE_SEG __NEAR_SEG NON_BANKED
__interrupt void Timer_Overflow_ISR(void){
  if( count > 0) {
    count--;
  }else {
    count = 266;
    PORTB ^= 0x01;
  }
  dummy = TCNT; 
}
void main(void) {  
    EnableInterrupts;
  for(;:smileywink: {
    _FEED_COP(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}


And here's my isr_vectors.c. All I did was copy it from the examples that came with CW and modify it to add my own interrupt.

 

 // isr_vectors.c

extern void near _Startup(void);       /* Startup routine */
extern void near Timer_Overflow_ISR(void);

#pragma CODE_SEG __NEAR_SEG NON_BANKED /* Interrupt section for this module. Placement will be in NON_BANKED area. */
__interrupt void UnimplementedISR(void)
{
   /* Unimplemented ISRs trap.*/
   asm BGND;
}


typedef void (*near tIsrFunc)(void);
const tIsrFunc _vect[] @0xFF80 = {     /* Interrupt table */
        UnimplementedISR,                 /* vector 63 */
        UnimplementedISR,                 /* vector 62 */
        UnimplementedISR,                 /* vector 61 */
        UnimplementedISR,                 /* vector 60 */
        UnimplementedISR,                 /* vector 59 */
        UnimplementedISR,                 /* vector 58 */
        UnimplementedISR,                 /* vector 57 */
        UnimplementedISR,                 /* vector 56 */
        UnimplementedISR,                 /* vector 55 */
        UnimplementedISR,                 /* vector 54 */
        UnimplementedISR,                 /* vector 53 */
        UnimplementedISR,                 /* vector 52 */
        UnimplementedISR,                 /* vector 51 */
        UnimplementedISR,                 /* vector 50 */
        UnimplementedISR,                 /* vector 49 */
        UnimplementedISR,                 /* vector 48 */
        UnimplementedISR,                 /* vector 47 */
        UnimplementedISR,                 /* vector 46 */
        UnimplementedISR,                 /* vector 45 */
        UnimplementedISR,                 /* vector 44 */
        UnimplementedISR,                 /* vector 43 */
        UnimplementedISR,                 /* vector 42 */
        UnimplementedISR,                 /* vector 41 */
        UnimplementedISR,                 /* vector 40 */
        UnimplementedISR,                 /* vector 39 */
        UnimplementedISR,                 /* vector 38 */
        UnimplementedISR,                 /* vector 37 */
        UnimplementedISR,                 /* vector 36 */
        UnimplementedISR,                 /* vector 35 */
        UnimplementedISR,                 /* vector 34 */
        UnimplementedISR,                 /* vector 33 */
        UnimplementedISR,                 /* vector 32 */
        UnimplementedISR,                 /* vector 31 */
        UnimplementedISR,                 /* vector 30 */
        UnimplementedISR,                 /* vector 29 */
        UnimplementedISR,                 /* vector 28 */
        UnimplementedISR,                 /* vector 27 */
        UnimplementedISR,                 /* vector 26 */
        UnimplementedISR,                 /* vector 25 */
        UnimplementedISR,                 /* vector 24 */
        UnimplementedISR,                 /* vector 23 */
        UnimplementedISR,                 /* vector 22 */
        UnimplementedISR,                 /* vector 21 */
        UnimplementedISR,                         /* vector 20 */
        UnimplementedISR,                 /* vector 19 */
        UnimplementedISR,                 /* vector 18 */
        UnimplementedISR,                 /* vector 17 */
        Timer_Overflow_ISR,                 /* vector 16 */
        UnimplementedISR,                 /* vector 15 */
        UnimplementedISR,                 /* vector 14 */
        UnimplementedISR,                 /* vector 13 */
        UnimplementedISR,                 /* vector 12 */
        UnimplementedISR,                 /* vector 11 */
        UnimplementedISR,                 /* vector 10 */
        UnimplementedISR,                 /* vector 09 */
        UnimplementedISR,                 /* vector 08 */
        UnimplementedISR,                          /* vector 07 */
        UnimplementedISR,                 /* vector 06 */
        UnimplementedISR,                 /* vector 05 */
        UnimplementedISR,                 /* vector 04 */
        UnimplementedISR,                 /* vector 03 */
        UnimplementedISR,                 /* vector 02 */
        UnimplementedISR,                 /* vector 01 */
        _Startup                          /* Reset vector */
   };

Outcomes