cancel
Showing results for 
Search instead for 
Did you mean: 

OTP Flash using STM32F4CUBE HAL Flash driver and Keil

kcobler
Associate
Posted on June 24, 2014 at 13:50

I am not having great success using the HAL Flash driver to flash OTP on the STM32439I-EVAL board. I have used the example FLASH_Erase (under examples). I am using Keil MDK.

I have added the line (around line number 126):

 HAL_FLASH_Program(TYPEPROGRAM_WORD, (uint32_t) 0x1FFF7800, 1);

This is being performed right before the programming the user flash area.

I thought that as long as I left the OTP locks to 0xFF, I could flash the OTP as much as I want. The OTP locks are 0xFF.

However, using the HAL driver, I can get 1 flash and then the OTP word cannot be flashed again. In fact, after using the HAL driver to flash the OTP, the memory location using the STM32 ST-Link GUI Utility is not able to update the OTP memory location (error writing is displayed).

Note: I can use the STM32 ST-Link GUI Utility to write into OTP memory as many times as I want. It's just not working with OTP memory touched by the HAL driver in the CUBE.

Any help?

Ken Cobler

#otp-flash-keil
1 REPLY 1
kcobler
Associate
Posted on June 24, 2014 at 17:33

It wasn't clear at first, but after reading some other posts, the OTP can hold a 1 in a bit until it is written as 0. Once OTP bit is written as 0, it cannot be re-written as 1.