Relocate the INTERRUPT VECTOR

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Relocate the INTERRUPT VECTOR

Jump to solution
1,519 Views
dan78
Contributor I

Dear all Hello,

 

I'm using CodeWarrior 5.9.0 for my application with MC9S12P128.

In my application I need to relocate the interrupt vector address.
For example: I need to put the Timer Overflow Interrupt in the location 0x7FDE.
I've done this by this entry in the .prm file:

VECTOR ADDRESS 0x7FDE TOV_Interrupt

My applicatin runs correctly, even if I reset it by the debugger.
But if i do an hardware reset turning off the power supply, the application doesn't handle the interrupt correctly and it enters in a infinite loop.

 

Is corretc to use the entry in the .prm file or do I have to use another method?

Thank you.

Labels (1)
0 Kudos
1 Solution
597 Views
Sten
Contributor IV

Hi DAN78

 

I assume you are using a bootloader? I am using the same approach: a bootloader in protected flash occupying the address range 0xF800..FFFF. Because the standard vector area is in protected flash, I have relocated my applications vectors to 0xF7xx. In my applications I set the IVBR to 0xF7 before enabling interrupts. But!!! All the Reset-vectors you must handle with your bootloader in the way Lundin suggests. For example the Bootloaders Reset-ISR must, depending of if the bootloader is running or not, either do bootloader-stuff or jump to the address pointed toby the aplications reset-vector (in my case at 0xF7FE).

 

Hope this helps you to find your problem.

 

Sten

 

View solution in original post

0 Kudos
4 Replies
598 Views
Sten
Contributor IV

Hi DAN78

 

I assume you are using a bootloader? I am using the same approach: a bootloader in protected flash occupying the address range 0xF800..FFFF. Because the standard vector area is in protected flash, I have relocated my applications vectors to 0xF7xx. In my applications I set the IVBR to 0xF7 before enabling interrupts. But!!! All the Reset-vectors you must handle with your bootloader in the way Lundin suggests. For example the Bootloaders Reset-ISR must, depending of if the bootloader is running or not, either do bootloader-stuff or jump to the address pointed toby the aplications reset-vector (in my case at 0xF7FE).

 

Hope this helps you to find your problem.

 

Sten

 

0 Kudos
597 Views
dan78
Contributor I

Hi Sten,

I've just done an example like the way you suggested to me and it works.

Thanks a lot!

0 Kudos
597 Views
Lundin
Senior Contributor IV

Why on earth would you need to move the vector table? This seems like needless obfuscation to me. Even if you are make some mysterious bootloader, I still don't see the need to move the vector table. Flash the vector table when you switch from bootloader to live application.

 

Or simpler still:

 

// prm

VECTOR ADDRESS 0xFFDE TOV_Interrupt

 

#pragma TRAP_PROC

void TOV_Interrupt (void)

{

  if(something)

   {

    execute_this();

  }

  else

  {

    execute_that();

  }

}

 

 

0 Kudos
597 Views
dan78
Contributor I

Hi Ludlin,

Yes I've have to use a bootloader.

But I can't flash the vector table when I'm in my main program (bootloader and reset vector are in the same flash bank,

 so i want to flash the vector table I have to erase the whole bolck, erasing the bootloader... )

 

Thanks

0 Kudos