cancel
Showing results for 
Search instead for 
Did you mean: 

writing a variable value inside the flash at an absoulte address

smart
Associate II
Posted on March 06, 2008 at 17:23

writing a variable value inside the flash at an absoulte address

5 REPLIES 5
smart
Associate II
Posted on May 17, 2011 at 12:26

Is this possible with IAR compiler for STM32 to write variable value into the flash at an absolute location.

I tried this code but only get the hard fault exception.

like this way:

#pragma location=0x80017FC // 0x80017FC is inside the flash

volatile __no_init int beta;

volatile __no_init int gamma;

int main(void)

{

beta = 0x55555555;

}

lanchon
Associate II
Posted on May 17, 2011 at 12:26

read the flash programming manual.

smart
Associate II
Posted on May 17, 2011 at 12:26

Thanks for your suggestion.

If in case I had already read that then you would like to say anything.

I have already unlocked the flah programming controller, disable the read and write protection and I already have a running bootloader code that can write to flash.

Now my problem is that I want to write my build and version number inside the flash using some variable but I am not able to write the variable at an absolute location

if you have any experience please help me.

lanchon
Associate II
Posted on May 17, 2011 at 12:26

ok, sorry, there was no way to know you had read it from your post. if you hadn't it was the right pointer.

that doc says under which conditions the access would be aborted, I copy one here:

-Any attempt to write data that are not half-word long will result in a

bus error response from the FPEC.

you're accessing a full word, so that's probably it.

also be sure to check the status flags after the programming.

lanchon
Associate II
Posted on May 17, 2011 at 12:26

maybe you want the code to be more portable, something like:

static volatile int* const beta = (int*) 0x080017FC;

static volatile short int* const beta_l = (short int*) 0x080017FC;

static volatile short int* const beta_h = (short int*) 0x080017FE;