Library 49- One-Time programmable (OTP) bytes on STM32F4

STm32F4xx devices have OTP (One-Time-Programmable) bytes. They can be used for permanent store of configuration data for your device. Bytes are structured in 16 data blocks where each block has 32 data bytes of available memory.

There is also 17th block with 16 bytes of data. His “work” is to store information about states of data block, because you can lock each block forever even if it is totally empty.

Important notes:

  • When you write data to specific OTP location which is empty, and if you try to write data there again, you can expect broken data after write,
  • If you lock your block, you are unable to unblock it back and you are unable to write data to block even if it is completelly empty,
  • You don’t need to write entire block at a time!



  • Operate with OTP memory
  • Write data┬áto specific block and byte
  • Read data from specific block and byte
  • Lock block permanently
  • Check if block is locked


    • STM32F4xx
    • STM32F4xx RCC
    • STM32F4xx FLASH
  • TM
    • defines.h

Functions and enumerations


  • If GREEN┬áLED is on, then byte is written OK to OTP memory
  • If RED LED is on, then read byte is the same as byte we write before

Project is available on Github, download library below.


Owner of this site. Application engineer, currently employed by STMicroelectronics. Exploring latest technologies and owner of different libraries posted on Github.

You may also like...