2017-01-19 06:15 AM
I need to read the unique device ID from a STM32L0.
The Low Level hal driver source (
stm32l0xx_ll_utils.h,
V1.7.0, 31-May-2016) uses:__STATIC_INLINE uint32_t LL_GetUID_Word0(void)
{
return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS)));
}
__STATIC_INLINE uint32_t LL_GetUID_Word1(void)
{
return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U))));
}
__STATIC_INLINE uint32_t LL_GetUID_Word2(void)
{
return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U))));
}
The reference manual says:
Base address: 0x1FF8 0050
Address offset: 0x00 => Bits 31:0
Address offset: 0x04 => Bits 63:32
Address offset: 0x14 => Bits 95:64
#uid #unique-id #unique-device-id-register""Solved! Go to Solution.
2018-02-23 09:40 AM
Hello
,The correct values are defined in the reference manual:
Base address: 0x1FF8 0050
Address offset: 0x00 => Bits 31:0
Address offset: 0x04 => Bits 63:32
Address offset: 0x14 => Bits 95:64
The fix in the HAL should be included in the next release of STM32CubeL0, but I don't have the exact release date.
So, this wrong line:
__STATIC_INLINE uint32_t LL_GetUID_Word2(void) { return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); }�?�?�?�?
must be corrected to
__STATIC_INLINE uint32_t LL_GetUID_Word2(void) { return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 0x14U)))); }�?�?�?�?
Best Regards,
Imen
2017-01-19 07:57 AM
Hello @
Jorgensen.Martin
,Thanks for sharingthis issue and bringing itto our attention.
We review your feedbackinternally and working for fixing it.
Regards
Imen
2018-02-22 05:23 AM
Hi
DAHMEN.IMEN
,is there news on the address? I also have the same question and i'm unsure if I should trust the driver implementation or the reference manual.
Thanks,
Nils
2018-02-22 05:43 AM
In your code, if the uid is defined, undefine it and then redefine it to the right address.
2018-02-23 06:59 AM
what is the right address and what are the correct offsets to the 2nd and 3rd word?
(That's what this issue is about, because driver and datasheet aren't stating the same thing, so it's unclear what gives the correct UID.)2018-02-23 07:02 AM
/*!
* \brief Unique Devices IDs register set (STM32L0xxx) */ ♯ define ID1 (0x1FF80050) ♯ define ID2 (0x1FF80054) ♯ define ID3 (0x1FF80064)2018-02-23 07:31 AM
thanks Clive! Just out of curiousity: where did you find that the reference manual is correct and the drivers are wrong?
I have two STM32L073RZ and read the UUID on both like this:
myProperties.UUID1 = (uint32_t) ((uint32_t*) 0x1FF80050);
myProperties.UUID2 = (uint32_t) ((uint32_t*) 0x1FF80054); myProperties.UUID3 = (uint32_t) ((uint32_t*) 0x1FF80064);When I then print the
myProperties.UUID1 etc the first o
ne gives me:UUID 536346704 536346708 536346724
and the other gives me:
UUID 536346704 536346708 536346724
and that's not good when it should be a unique ID i figured
:)
I guess it's a pretty stupid mistake i'm making, but I can't figure out where?!
2018-02-23 07:51 AM
chehck the reference manual: they are not consistently at the same place.
the chance of ST making a mistake in the reference manual is much smaller than the chance of ST making a mistake in the code.
2018-02-23 09:40 AM
Hello
,The correct values are defined in the reference manual:
Base address: 0x1FF8 0050
Address offset: 0x00 => Bits 31:0
Address offset: 0x04 => Bits 63:32
Address offset: 0x14 => Bits 95:64
The fix in the HAL should be included in the next release of STM32CubeL0, but I don't have the exact release date.
So, this wrong line:
__STATIC_INLINE uint32_t LL_GetUID_Word2(void) { return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U)))); }�?�?�?�?
must be corrected to
__STATIC_INLINE uint32_t LL_GetUID_Word2(void) { return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 0x14U)))); }�?�?�?�?
Best Regards,
Imen