cancel
Showing results for 
Search instead for 
Did you mean: 

A problem moving the interrupt vector table.

a2399
Associate II
Posted on April 24, 2009 at 08:01

A problem moving the interrupt vector table.

8 REPLIES 8
a2399
Associate II
Posted on May 17, 2011 at 12:46

Dear All,

I'm having a problem moving the interrupt vector table to elsewhere in internal FLASH on medium size devices.

My application works fine when I run it with the default .intvec = 0x0800000, ROM Start = 0x08000EC values. When I add 0x800 to these addresses (IAR v5.20, Linker->Config->Edit) the application fits OK, builds OK, the map file shows that the addresses are moved OK, but the application behaves nonsensically when debugging. The debugging log reports such errors as ''MMU fault: Instruction access violation!'' and ''Bus fault: Precise data bus error!''.

I've tried various other .intvec start addresses with no success. I've tried these with the ROM start address offset by the correct vector table size (0x130) with no success. Changing the ROM start address doesn't seem to cause problems - it's the .intvec start address that appears troublesome.

Can the interrupt vector table be moved?

Are there limitations to where it can be moved to?

Are there other settings or registers involved?

Thanks in advance for your help.

lanchon
Associate III
Posted on May 17, 2011 at 12:46

> Can the interrupt vector table be moved?

yes but you have to program the new vector table address in an interrupt controller register. kinda obvious, but maybe you forgot.

jgoril
Associate II
Posted on May 17, 2011 at 12:46

Interrupt controller is a piece of hardware. If interrupt event occurs, interrupt controller ensures the branch in program execution - the program counter reloads fixed address - see section 8.1.2 in RM0008 for address table (page 120 in rev.5). How do you want to force it so that it jumps somewhere else? The only way I know is memory remapping (internal flash, internal RAM, external memory...). But the address offset will be still the same.

However, I don't know IAR and the purpose of mentioned setting (try IAR's help).

a2399
Associate II
Posted on May 17, 2011 at 12:46

I've found a solution to my problem - thanks to those who investigated. Solution follows below. Note that it only works with IAR EWARM 5.X:

Step 1: Set .intvec start in the linker to the desired address:

Options->Linker->Config->Edit->Vector Table

Step 2: The interrupt table start address needs to be exported in the .icf file. Manually edit the project .icf file to add the following line, taking care to add it after the ''/**** End of ICF editor section. ###ICF###*/'' section:

export symbol __ICFEDIT_intvec_start__;

Step 3: Expose the symbol in a global area of the .c file:

extern u32 __ICFEDIT_intvec_start__;

Step 4: In the .c file, load the SCB_VTOR register using the library function 'NVIC_SetVectorTable' in the following way:

{

u32 offset;

offset = (u32)&__ICFEDIT_intvec_start__;

offset &= SCB_VTOR_TBLOFF;

NVIC_SetVectorTable(NVIC_VectTab_FLASH, offset );

}

ps. Unlike this method, the ST 'Vector Table Relocation' example doesn't auto synchronise the linker with code, probably because it needs to be linker agnostic.

a2399
Associate II
Posted on May 17, 2011 at 12:46

This only seems to work when connected to the emulator (IAR EWARM 5.20 J-Link).

The micro appears to hang when not connected to the emulator.

Cheers

ivanov-i
Associate II
Posted on May 17, 2011 at 12:46

Dear a.kleinert,

In any case you should have some table starting from address 0x00000000. It should contain at least the initial value of the stack pointer and the starting address of the program (__iar_program_start, for example). When you boot from FLASH the address 0x08000000 is relocated there, that's why your table should be in fact located there.

When the application starts you can assign a different address in the VTOR register, so it will point to a different table, but still the table at 0x08000000 should exists.

okelly2
Associate II
Posted on May 17, 2011 at 12:46

a.kleinert,

You wrote

Quote:

This only seems to work when connected to the emulator (IAR EWARM 5.20 J-Link).

The micro appears to hang when not connected to the emulator.

Cheers

I also have a problem that appears similar

http://null

Maybe any answers that come there will help you. I'm hoping :D

Regards,

Owen

psantofe
Associate II
Posted on May 17, 2011 at 12:46

Quote:

On 25-09-2008 at 13:01, Anonymous wrote:

I've found a solution to my problem - thanks to those who investigated. Solution follows below. Note that it only works with IAR EWARM 5.X:

Step 1: Set .intvec start in the linker to the desired address:

Options->Linker->Config->Edit->Vector Table

Step 2: The interrupt table start address needs to be exported in the .icf file. Manually edit the project .icf file to add the following line, taking care to add it after the ''/**** End of ICF editor section. ###ICF###*/'' section:

export symbol __ICFEDIT_intvec_start__;

Step 3: Expose the symbol in a global area of the .c file:

extern u32 __ICFEDIT_intvec_start__;

Step 4: In the .c file, load the SCB_VTOR register using the library function 'NVIC_SetVectorTable' in the following way:

{

u32 offset;

offset = (u32)&__ICFEDIT_intvec_start__;

offset &= SCB_VTOR_TBLOFF;

NVIC_SetVectorTable(NVIC_VectTab_FLASH, offset );

}

ps. Unlike this method, the ST 'Vector Table Relocation' example doesn't auto synchronise the linker with code, probably because it needs to be linker agnostic.

Since I'm not so expert, I need to have some explanation from you in order to solve the same problem. Could you contact me at

mailto:psantofe@libero.it

?

Thanks