STM32 Unique ID UID (96-Bit) | How To Read

In this article, we’ll discuss the STM32 unique ID (UID) which is a unique 96-bit value assigned to each STM32 microcontroller IC, how to read this UID value, and what are the possible applications and use cases for the STM32 UID. Without further ado, let’s get right into it!

Table of Contents

  1. STM32 Unique ID UID (96-Bit)
  2. How To Read STM32 Unique ID UID (96-Bit)
  3. Wrap Up

STM32 Unique ID UID (96-Bit)

What is The STM32 Unique ID?

STM32 microcontrollers have an embedded hard-coded unique identifier (UID), a unique 96-bit number assigned to each microcontroller IC during fabrication time. The 96-bit unique ID is a combination of the following fabrication-specific parameters:

  • UID[31:0]: X & Y coordinates on the wafer expressed in BCD format
  • UID[63:40]: LOT_NUM[23:0] Lot number (ASCII encoded)
  • UID[39:32]: WAF_NUM[7:0] Wafer number (8-bit unsigned number)
  • UID[95:64]: LOT_NUM[55:24] Lot number (ASCII encoded)

Applications of The STM32 UID

The UID number can be used in various embedded security applications, networking/IoT, as a serial number, or as a key for security applications.


How To Read STM32 Unique ID UID (96-Bit)

There is an API function in the HAL library that reads the UID for you. Given that the STM32 UID is a 96-bit value, it’s going to be read in 3 separate 32-bit words. And here is how to do it in code.

And here is the debugging result showing the 3-word content of the UID of my blue pill’s STM32F103 microcontroller.

SM32 Unique ID UID 96-Bit Reading Example

❕ Note

Not all STM32 microcontrollers have a UID fused on the flash memory. While other STM23 parts have the UID base address in an MPU-protected region in the flash causing read attempts to fire a hard fault. So you should seek help or ask an ST staff if you’re not able to read the UID using the provided code example in this article.


Required Parts For STM32 Examples

All the example Code/LABs/Projects in this STM32 Series of Tutorials are done using the Dev boards & Electronic Parts Below:

QTY.Component NameAmazon.comAliExpresseBay
1STM32-F103 BluePill Board (ARM Cortex-M3 @ 72MHz)AmazonAliExpresseBay
1Nucleo-L432KC (ARM Cortex-M4 @ 80MHz)AmazonAliExpresseBay
1ST-Link V2 DebuggerAmazonAliExpresseBay
2BreadBoardAmazonAliExpresseBay
1LEDs KitAmazonAmazonAliExpresseBay
1Resistors KitAmazonAmazonAliExpresseBay
1Capacitors KitAmazonAmazonAliExpress & AliExpresseBay & eBay
1Jumper Wires PackAmazonAmazonAliExpress & AliExpresseBay & eBay
1Push ButtonsAmazonAmazonAliExpresseBay
1PotentiometersAmazonAliExpresseBay
1Micro USB CableAmazonAliExpresseBay

★ Check The Links Below For The Full Course Kit List & LAB Test Equipment Required For Debugging ★


Wrap Up

In conclusion, we’ve explored how to read the STM32 unique ID (UID) 96-bit value and what are the possible use cases (applications) for this UID value.

If you’re just getting started with STM32, you need to check out the STM32 Getting Started Tutorial here.

Follow this STM32 Series of Tutorials to learn more about STM32 Microcontrollers Programming.

Share This Page With Your Network!
Join Our +25,000 Newsletter Subscribers!

Stay Updated With All New Content Releases. You Also Get Occasional FREE Coupon Codes For Courses & Other Stuff!

Photo of author
Author
Khaled Magdy
Embedded systems engineer with several years of experience in embedded software and hardware design. I work as an embedded SW engineer in the Automotive & e-Mobility industry. However, I still do Hardware design and SW development for DSP, Control Systems, Robotics, AI/ML, and other fields I'm passionate about.
I love reading, writing, creating projects, and teaching. A reader by day and a writer by night, it's my lifestyle. I believe that the combination of brilliant minds, bold ideas, and a complete disregard for what is possible, can and will change the world! I will be there when it happens, will you?

Leave a Comment