Is there any way to access the built-in serial number in an STM32F407 (for example) chip? I’d like to be able to use the chip’s SN as an identifier for devices in an application.
Thanks!
Is there any way to access the built-in serial number in an STM32F407 (for example) chip? I’d like to be able to use the chip’s SN as an identifier for devices in an application.
Thanks!
HAL(stm32f4xx_hal.c
) has this method.
/**
* @brief Return the unique device identifier (UID based on 96 bits)
* @param UID pointer to 3 words array.
* @retval Device identifier
*/
void HAL_GetUID(uint32_t *UID)
{
UID[0] = (uint32_t)(READ_REG(*((uint32_t *)UID_BASE)));
UID[1] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
}
If my understanding is correct, this reads Unique device id register. See page 1714 of the reference manual.
Thank you! That seems to work! At least it’s giving me the same number every time. My other board is in my office, and the campus is closed due to COVID, so I’ll just run with this for now.
Thank you, that was the information that I was looking to obtain. Appreciated.