cancel
Showing results for 
Search instead for 
Did you mean: 

jump function

Snm.1
Associate III

I have jump function this like that but this method don't work. Please I need help immedietly

void jumpToAddress(uint32_t jump_address)
{
void (*jumpFunction)(void);
static constexpr uint32_t SHIFTED_JUMP_ADDRESS_DUE_TO_RESET_HANDLER = 4;
static constexpr uint8_t NVIC_REGISTER_LENGTH = 8;

SCB_DisableDCache();
SCB_DisableICache();

__disable_irq();

SysTick->CTRL = 0;

HAL_RCC_DeInit();

for (uint8_t i = 0; i < NVIC_REGISTER_LENGTH; i++)
{
NVIC->ICER[i] = 0xFFFFFFFF;
NVIC->ICPR[i] = 0xFFFFFFFF;
}

SCB->VTOR = jump_address;

__set_MSP(*((uint32_t *)jump_address + SHIFTED_JUMP_ADDRESS_DUE_TO_RESET_HANDLER));

jumpFunction = (void (*)(void))(*((uint32_t *)((jump_address + SHIFTED_JUMP_ADDRESS_DUE_TO_RESET_HANDLER))));
__enable_irq();
jumpFunction();

while (1);
}

 

1 REPLY 1
mƎALLEm
ST Employee

Hello,

Please use </> button to share your code.

See the tips on this link. I'm editing your post.

Thank you for your understanding.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.