Relocate vector table to SRAM

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Relocate vector table to SRAM

1,253件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Albert on Mon Mar 21 20:54:19 MST 2011
Hi all,

I tried to use the function NVIC_SetVectorTable( ) but the LPCXpresso IDE point a error. Someone can explain why?

Code:
#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>

#include <NXP/LPC17xx/nvic.h>

void main ( )
{
NVIC_SetVectorTable(NVIC_VectTab_RAM,0);
...
}

Other question is,
If I use the instruction SCB->VTOR = 0x20000000; instead of NVIC_SetVectorTable(NVIC_VectTab_RAM,0);, why I don't see on 0x1000 0000 to 0x1000 0100 any change?

Thank!
0 件の賞賛
返信
3 返答(返信)

752件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Tue Mar 22 07:57:04 MST 2011
Hi Albert

Glad that you got it working :cool:

At the very least, you should provide a handler for the Hard Fault exception to stop the processor from running wild:

void HardFault_Handler()
{
    while(1)
    {
    }
}
Then, you have to consider all of the interrupts/exceptions that have been enabled by your application up to the point that you relocated the vector table.

You have configured Port 2 _ 10 as the EINT0, so the NMI [I]shouldn't[/I] be taken by the processor. But I would tend to provide a default handler for the first 8 exceptions (NMI --> SysTick), just as a precaution.

Note that there are gaps in the vector table:
    &_vStackTop, // The initial stack pointer
    ResetISR,                                // The reset handler
    NMI_Handler,                            // The NMI handler
    HardFault_Handler,                        // The hard fault handler
    MemManage_Handler,                        // The MPU fault handler
    BusFault_Handler,                        // The bus fault handler
    UsageFault_Handler,                        // The usage fault handler
    0,                                        // Reserved
    0,                                        // Reserved
    0,                                        // Reserved
    0,                                        // Reserved
    SVCall_Handler,                            // SVCall handler
    DebugMon_Handler,                        // Debug monitor handler
    0,                                        // Reserved
    PendSV_Handler,                            // The PendSV handler
    SysTick_Handler,                        // The SysTick handler

0 件の賞賛
返信

752件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Albert on Tue Mar 22 04:20:00 MST 2011
Hi jharwood,

Now my code works fine. Thanks.

I didn't know that I needed fill the new vector table area, I thought that was automaticly.

Now I can define a new position for the interrupt, for example: 0x2007c088 to the EINT0_IRQHandler handler.

Then I modify the vector table for the other position in the memory, there is some essential handlers that I can't forgot to add in the new table position?

Thanks for the help.
0 件の賞賛
返信

752件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Mon Mar 21 22:08:42 MST 2011

Quote: Albert
Hi all,

I tried to use the function NVIC_SetVectorTable( ) but the LPCXpresso IDE point a error. Someone can explain why?

Code:
#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include <cr_section_macros.h>
#include <NXP/crp.h>

#include <NXP/LPC17xx/nvic.h>

void main ( )
{
NVIC_SetVectorTable(NVIC_VectTab_RAM,0);
...
}


I'm not sure in which library  NVIC_SetVectorTable is actually implemented, so I was going to suggest using SCB->VTOR = instead. But then you edited your post...


Quote:

Other question is,
If I use the instruction SCB->VTOR = 0x20000000; instead of NVIC_SetVectorTable(NVIC_VectTab_RAM,0);, why I don't see on 0x1000 0000 to 0x1000 0100 any change?

Thank!

So now the plot thickens :)

Why would you want to set the vector table offset register to 0x20000000 :confused:  That is a reserved area in LPC17xx

Perhaps you want to move the vector table to AHB SRAM ? that starts at 0x2007c000

Why would you expect to 'see a change' (in memory at 0x10000000 ?) when you modify the VTOR ?

It's up to you, the programmer, to correctly populate the vector table in your chosen new location then modify the VTOR.
0 件の賞賛
返信