This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to specify and change interrupt vector



I'm using IAR C++ and want to give multiple interrupt vectors forTIMERA0.

I know only one can be in the interrupt table at a time, but depending on various factors I'd like to change it. 

I have two problems.  The first is the IAR won't let me define more than one

#pragma vector=TIMERA0_VECTOR
__interrupt void Timer_A0 (void)
{
 .....
}

And the second problem is I'm not sure where to write the address of the interrupt vector.  Do I just write it to

0xFFEC ?  Something like

 unsigned p = 0xFFEC;
  *(unsigned**)p = (unsigned*)Timer_A0;

?

Thanks for your help

 

  • Hi Mark,

    To keep it simple, I would maintain a state variable with state values enumerated from zero and using only even numbers.  Then the first statement in your one and only interrupt service routine would be a switch statement using the __even_in_range directive.  It will ensure that your switch statement is lightning fast -- it will be almost exactly like having multiple vectors but without the complication.

    Depending on which handler you want to run, assign the appropriate state enumeration to your state variable.

    Jeff

    [Edit: And IAR will take care of placing the interrupt vector for you.]

  • For most microcontrollers, the interrupt vector table is in flash and the vector for a particular interrupt is not (easily) changeable.  (As the micro gets bigger, it is more likely to have a way to change the base of the interrupt vector table, perhaps to a RAM location, in order to support bootloading, operating systems, and RAM-based operation.)  My MSP430 knowledge is all at the low end and I don't know whether this is the case for the higher-end MSP430s...)

    You can use a function pointer or indirect jump to achieve similar things.

  • For the first question, you can also choose one of the alternatives at compilation/link time using things like #if ... etc.

    For your second question (or problem), you do not need to do anything. When you use the #pragma vector=... the compiler will inform the linker to put a point to the ISR you declared at the right physical address.

**Attention** This is a public forum