Topic : Jumping to a changable address

Forum : ARM

Original Post
Post Information Post
April 30, 2013 - 7:43pm
Guest

Hi,

I'm trying to create some start-up code. I used it on a previous product, but now I want to change it. Depending on a switch, it would either jump to Bootloader, or the main program. The problem is that when I updated Ride7, it changed the Reset Vectors in my code when compiled. So what I decided was to put an address in that contains the Reset Vector. That way when the code is upgraded, it will reflect the new Reset Vector. The trouble is I'm not sure how to jump to an address that is in a FLASH register. I'll include the code below, and that should make things a little more clear. What it seems to be doing is jumping to the addresses that contain the Reset Vectors. I'm just not sure what command to use. We're using an STM32F103VBT6

Thanks,
Timothy

#define BootSwitch (*(__IO bool*) 0x08001400) // BOOL: False for Main boot. True for Bootloader boot
#define BootVector (*(__IO uint32_t*) 0x08005FE0)
#define ProgramVector (*(__IO uint32_t*) 0x0801FFE0)

int main(void)
{
temp = BootSwitch;
if(temp == 0x00)
{
goto *BootVector; // This jumps to the address for BootVector (0x08005FE0), not the address at BootVector
}
else
{
goto *ProgramVector; // This jumps to the address for ProgramVector (0x0801FFE0), not the address at ProgramVector
}
}

And for my Bootloader I have the address defined: (I know this is getting written correctly)
.long 0x08002205

And for my Main Program I have the address defined: (I know this is getting written correctly)
.long 0x08006205