Skip to main content
spa
Associate II
January 16, 2009
Question

Program word in flash

  • January 16, 2009
  • 2 replies
  • 709 views
Posted on January 16, 2009 at 06:45

Program word in flash

    This topic has been closed for replies.

    2 replies

    spa
    spaAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:59

    Hi.

    I’m trying to write to the flash but every time I try to do a FLASH_ProgramWord(), it ends up in the HardFault_Handler.

    I'm using the approach that is used in ST’s Write_Portection examples.

    Code:

    /* Unlock the Flash Program Erase controller */

    FLASH_Unlock();

    FLASH_ClearFlag(FLASH_FLAG_BSY | FLASH_FLAG_EOP|FLASH_FLAG_PGERR |FLASH_FLAG_WRPRTERR);

    /* Get pages write protection status */

    WRPR_Value = FLASH_GetWriteProtectionOptionByte();

    ProtectedPages = WRPR_Value & 0xFFFFFFFF;

    if (ProtectedPages == 0x00)

    {/* Pages are write protected */

    /* Disable the write protection */

    FLASHStatus = FLASH_EraseOptionBytes();

    }

    FLASH_ErasePage(APPLICATION_ADDRESS);

    FLASHStatus = FLASH_ProgramWord(0x00001111,APPLICATION_ADDRESS);

    I hope anyone can help me.

    Søren P.

    spa
    spaAuthor
    Associate II
    May 17, 2011
    Posted on May 17, 2011 at 12:59

    Hi.

    Error located, embarrassed….

    FLASH_ProgramWord() is (Address, Data) i had (Data, Address)

    Best regards

    Søren P.

    :-]