AnsweredAssumed Answered

IAP and memory Jumping

Question asked by rahimi.meysam on May 25, 2015
hello
i am using an IAP program to load another program on stm32f4 device. the main program is an uCOS-II RTOS.
I have one problem:
at first there is no problem to go in to IAP program and then jump to main program. but when i return from main program to boot(IAP), at time that i want to return to main program, Hard Fault occurs.
the codes for jumping between programs is here:

JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
      Jump_To_Application = (pFunction) JumpAddress;
      /* Initialize user application's Stack Pointer */
      __set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
      Jump_To_Application();

One Point that i realize during debug operation was that the first jump from IAP to main program(that is correct) has assign new value for SP by __set_MSP() but in the second jump(not correct) SP did not changed after __Set_MSP() .

I would be thank full for your guidance.
thank you.

Outcomes