Skip to main content
Vmish.1
Associate
March 21, 2021
Solved

NUCLEO-STM32L452REP Internal Flash Write Data

  • March 21, 2021
  • 5 replies
  • 1567 views

Hi St,

I am using NUCLEO-STM32L452REP board.

I am trying to write a DOUBLE WORD inside the internal flash.

I am writting to address 0x807D000 which is 8byte alligned.

The address i am trying to write, its contents are 0xFF.

I am calling below function:

HAL_Flash_Program(FLASH_TYPEPROGRAM_DOUBLEWORD, 0x807D000, 0x01);

I am getting an error 0xa0 which equals programming allignment error.

Please help.

This topic has been closed for replies.
Best answer by KnarfB

You're right with HAL_FLASH_Program (capital FLASH), I mixed it up. 0xa0 is a combination of two errors. One is PGSERR - Programming sequence error. Did you do HAL_FLASH_Unlock() and erase beforehand?

hth

KnarfB

5 replies

KnarfB
Super User
March 21, 2021

Check the function declaration. The last param is a pointer to the source value, not the value itself.

Vmish.1
Vmish.1Author
Associate
March 21, 2021

Hi KnarfB,

I am using STM32Cube FW_L4 V1.16.0 Hal driver version. In that, function HAL_Flash_Program() has the last parameter unsigned 64 bit integer( uint64_t Data ) variable. i.e. the programming granularity is 8 byte.

KnarfB
KnarfBBest answer
Super User
March 21, 2021

You're right with HAL_FLASH_Program (capital FLASH), I mixed it up. 0xa0 is a combination of two errors. One is PGSERR - Programming sequence error. Did you do HAL_FLASH_Unlock() and erase beforehand?

hth

KnarfB

Vmish.1
Vmish.1Author
Associate
March 21, 2021

yes HAL_FLASH_Unlock() serves the purpose.

and erasing is only needed when contents are not 0xFF.

Thanks.

Tesla DeLorean
Guru
March 21, 2021

Going to have make sure the flash is unlocked and erased. Make sure any pending errors are cleared.

Pay attention to the error/status messages you get, and perhaps instrument the code so you can follow/understand the flow without single stepping in a debugger.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Vmish.1
Vmish.1Author
Associate
March 21, 2021

Thanks. We can close the ticket.

Technical Moderator
March 24, 2021

Hello @Vmish.1​ ,

Please select the post of user which is "Best Answer".

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks