Hello,
I'm working with LPC51u68, and I want to copy the vector table from flash to SRAM0.
Vector table is at 0x00000000 at flash and need to go to 0x20000000, from what I understand from the user manual.
I used the VTOR register, and developed the following function:
What do you think of my approach is it correct? I am having doubts on using g_pfnVectors defined in the srtatrup file, is this really my vector table?
Thank you.
Carlos Medeiros
Hello Alice!
It's me Carlos, I had to change my email.
Thank you for the reply it was very helpful.
One more question, I understand the CopyInterruptToSRAM(), but after this I need to change the content of the VTOR right?
------------------------------------------------------------------------------------------------------------------------------------------
Quote:
BTW, do you development Secondary bootloader ? If yes, are you sure remap data from 0x000 to SRAM?
---------------------------------------------------------------------------------------------------------------------------------------------
I have my bootloader in flash and my APP on SRAM, so I need the remap function when I want to do a jump to APP or jump to boot.
Thank you,
Carlos Medeiros
Hello Carlos,
Yes, you need to change the content of the VTOR , also need to configure SP before jump, the code like below:
typedef void (*pFunction)(void);
pFunction Jump_To_Application;
static uint32_t JumpAddress;
void run_to_app(void)
{
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);/* Jump to user application */
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's S4tack Pointer */__set_MSP(*(__IO uint32_t*) ApplicationAddress);
// the contents of the first address of the image, not the address itself.
SCB->VTOR = ApplicationAddress & 0x1FFFFF80;
Jump_To_Application();
}
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hello Carlos Medeiros ,
You can directly define the Destination address to 0x20000000, Source address is 0x00000000,
like this:
void CopyInterruptToSRAM(void)
{
unsigned int * flashPtr, * ramPtr;
unsigned int * uLimit = (unsigned int *) 0x100;ramPtr = (unsigned int *)0x20000000; //load RAM starting at 0x20000000,
flashPtr = (unsigned int *)0x0000; //start of interrupt vector table
while(flashPtr < uLimit)
{
*ramPtr = *flashPtr;
ramPtr++;
flashPtr++;
}
}
BTW, do you development Secondary bootloader ? If yes, are you sure remap data from 0x000 to SRAM?
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------