Skip to main content
smart
Associate III
March 6, 2008
Question

writing a variable value inside the flash at an absoulte address

  • March 6, 2008
  • 5 replies
  • 825 views
Posted on March 06, 2008 at 17:23

writing a variable value inside the flash at an absoulte address

    This topic has been closed for replies.

    5 replies

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

    read the flash programming manual.

    smart
    smartAuthor
    Associate III
    May 17, 2011
    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 III
    May 17, 2011
    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;

    lanchon
    Associate III
    May 17, 2011
    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.

    smart
    smartAuthor
    Associate III
    May 17, 2011
    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.