Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 7 months ago.
96- bit Unique ID
I am using STM32F429ZIT6 development board. In data sheet for STM32 there a unique ID and the ID length have 96 -bit mentioned in features of the STM controller. I am using three STM32 controllers. So How can I get the Device ID of each controller? In future can I use that 96-bit ID for Identification of controller or track the controller using the program is possible or not.
2 Answers
7 years, 7 months ago.
Try following function, UID_BASE is the start address of the unique ID and is different for each type. You need following variable declaration for the UID
uint8_t uid[12];
void stm32UID(uint8_t uid[]) { for(uint8_t i = 0; i < 12; i++) { uid[i] = *(volatile uint8_t *)(UID_BASE + i); } }
7 years, 7 months ago.
You should check the addresses of the ID in the microcontroller's datasheet. Here are a few examples.
#if defined TARGET_NUCLEO_F103RB #define USE_ID_ADDRESS ID_ADDRESS_STM32F1XXX #elif defined TARGET_NUCLEO_F411RE || defined TARGET_ARCH_MAX || defined TARGET_DISCO_F429ZI #define USE_ID_ADDRESS ID_ADDRESS_STM32F4XXX #elif defined TARGET_NUCLEO_L053R8 #define USE_ID_ADDRESS ID_ADDRESS_STM32F0XXX #else #define USE_ID_ADDRESS 0 #endif #define getUniqueId8(x) ((x >= 0 && x < 12) ? (*(uint8_t *) (USE_ID_ADDRESS + (x))) : 0) #define getUniqueId16(x) ((x >= 0 && x < 6) ? (*(uint16_t *) (USE_ID_ADDRESS + 2 * (x))) : 0) #define getUniqueId32(x) ((x >= 0 && x < 3) ? (*(uint32_t *) (USE_ID_ADDRESS + 4 * (x))) : 0)