I have written a bootloader code which have to jump to the Application code reside at the address 0x20000 .but boot code not able to jump to desired location . i have used the code to jump is :
pFunction = function pointer;
*******************************************************************************/
void NVIC_SetVectorTable(uint32_t NVIC_VectTab, uint32_t Offset)
{
__disable_irq();
SCB->VTOR = NVIC_VectTab | (Offset & 0x1FFFFF80);
__enable_irq();
}
/*** Jump to application ******************************************************/
void JumpToAddress(uint32_t Address)
{
uint32_t JumpAddress = *(__IO uint32_t*)(Address + 4);
pFunction Jump = (pFunction)JumpAddress;
NVIC_SetVectorTable(0x00000000 , Address);
__set_MSP(*(__IO uint32_t*) Address);
Jump();
while(1);
}
Hi Lakhbir Singh,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
Please give below code a try.
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);
SCB->VTOR = ApplicationAddress & 0x1FFFFF80;
Jump_To_Application();
}
Have a great day,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------