This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Changing an Interrupt Vector

I have an application that uses CAPCOM Timer 0, and want to change the interrupt vector address during runtime to vector to another function. However, the CAPCOM Interrupt Vector Location is at 80h, which is in Flash. Is there any way to easily change the interrupt vector address for CAPCOM Timer 0?

Parents
  • Hi Don,

    Obviously, you don't want to erase and reprogram Flash on the fly. So the interrupt vector table entry will always be pointing to the same location.
    Why can't you just use a switch statement inside the interrupt service routine to call the different functions? Is it the overhead? If it is, then you can reduce the overhead by having the interrupt vector point to a location in RAM and overwrite that location with appropriate JMPS instruction at runtime. I wouldn't call it easy, but it's definitely possible. Keil's linker has a feature which allows you to do that:

    http://www.keil.com/support/man/docs/l166/l166_sections.htm

    - mike

Reply
  • Hi Don,

    Obviously, you don't want to erase and reprogram Flash on the fly. So the interrupt vector table entry will always be pointing to the same location.
    Why can't you just use a switch statement inside the interrupt service routine to call the different functions? Is it the overhead? If it is, then you can reduce the overhead by having the interrupt vector point to a location in RAM and overwrite that location with appropriate JMPS instruction at runtime. I wouldn't call it easy, but it's definitely possible. Keil's linker has a feature which allows you to do that:

    http://www.keil.com/support/man/docs/l166/l166_sections.htm

    - mike

Children
  • Mike

    Thanks for the reply. The problem is that the interrupt routine is also in flash, and the location of the new interrupt routine is in downloaded RAM, and will change as updates change. I could modify the flash code to jump to a RAM location, and then change the RAM code as needed, but the flash code is already programmed into an existing product, and I'm trying to change the updated application code that is downloaded into RAM. I was somewhat suprised to find that the interrupt vector table was located in flash, since changing interrupt vectors is fairly common. Is there a way to move the entire interrupt table to RAM, and force the CPU to use that table? I know there is a VECTAB linker command, but I don't know if there is a way to implement something like a VECTAB function in C. Thanks.

  • Is there a way to move the entire interrupt table to RAM, and force the CPU to use that table?

    No, not with the C16x (ST10) family of microcontrollers. If you can't change code in flash, then I can see no way out for you. Unless you have loads of RAM and it's possible to copy the code from flash to RAM and remap RAM to replace flash, including interrupt vector table.

    - mike

  • Mike

    Thanks again for the reply. Actually, I do have lots of RAM available. In fact, I have much more RAM than flash, and the RAM program is basically an update of the flash code. So I have enough RAM, and more, to duplicate all the flash code, including the interrupt table. With this configuration, is there a way to startup the whole application from a non-zero memory location which is in RAM? Thanks.

  • I don't know what particular microcontroller it is and whether the flash memory is internal or external. There is a catch: if it's internal flash memory, then there is no way to remap it at run-time (after the EINIT instruction has been executed.) If it is external flash memory, then remapping RAM in its place should be fairly straightforward.

    - mike