how to find MCU serial number/unique id for the MCU?
If you are using HAL:
uint32_t HAL_GetREVID (void ) uint32_t HAL_GetDEVID (void )
alternatively, find where the uid is located and simply point a pointer to it.
#define U_ID ((const uint16_t *) 0x48CD) //U_ID95..0, referenced via U_ID, ..., U_ID#define U_ID0 U_ID //X coordinate#define U_ID1 U_ID //Y coordinate
the starting address, 0x48CD here, can vary from chip family to chip family but the basic idea is the same.
Does the STM8 have a serial number or unique ID?
Bogdan Golab and dhenry might be thinking of STM32.
I am sorry for misleading you. Frankly I do not know the STM8 family.
But I googled the st site () and found for an example MCU:
it seems that there should be 96 unique id embedded in the a device.
I used this particular query using google to narrow down search results only to the st site:
"site:st.com stm8 unique id"
I'm currently using the STM8L052R8 and that does not have a unique ID, as far as I can tell by reading the data sheets and reference manual (and I just read back the data from 0x48CD and it's just zeros). So I looks like some STM8 devices do have a Unique ID, while others don't (or its not documented). The OP does not mention which device or family they are using. They'll need to read the data sheets to check.
If they do have a device with a unique ID then method mentioned by dhenry would work, or could be adapted. To be unique all 12 bytes (96-bits) would be needed.
Retrieving data ...