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!

Library

Features

  • 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

Dependencies

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

Functions and enumerations

Example

  • 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.

Icon
TM STM32F4 OTP Library

tilz0R

Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!