I have two programs stored in flash memory and whish to be able to switch between the two. I have a known address for each that i wish to switch too and hence would normaly use inline assembler to create a Branch function. However in this function does not seem to be supported by the STM32 in the Keil environment. Can anyone please advise me on a method of doing this Jump? Thanks in advance Gareth
I've done something similar. I have a bootloader that checks to see if the main application is present. If it is it passes control to it. The main app is a stand-alone program, built to run by itself so it's doing all of the normal c startup stuff including having a vector table at the start. I use that to get the start address of the actual app.
Code:
/*
* Transfer control to the main application. * * We get the start address from the reset vector in the jump table. */ void launchMainApp(void) { void (*mainApplicationStart) (); long *myPtr1, *myPtr2; myPtr1 = (long*)ROM_BLOCK_HIGH_START; // Take address from the vector table myPtr1++; myPtr2 = (long*)*myPtr1; mainApplicationStart = (void(*)(void))myPtr2; mainApplicationStart(); } This works well for me. Cheers. Andy.