cancel
Showing results for 
Search instead for 
Did you mean: 

getting same unique ID for different controllers

meghasb
Senior

Hi everyone, can anyone pls help me with the problem, i'm trying to read the unique ID of the stm32U585 controller, i'm able to read the ID with HAL functions, but im getting the same output for all the three different controller with different systems,

here is the code,

 uid[0] = HAL_GetUIDw0();

 uid[1] = HAL_GetUIDw1();

 uid[2] = HAL_GetUIDw2();

 // Convert unique ID to byte array

 uid_buffer[0] = (uid[0] >> 24) & 0xFF;

 uid_buffer[1] = (uid[0] >> 16) & 0xFF;

 uid_buffer[2] = (uid[0] >> 😎 & 0xFF;

 uid_buffer[3] = uid[0] & 0xFF;

 uid_buffer[4] = (uid[1] >> 24) & 0xFF;

 uid_buffer[5] = (uid[1] >> 16) & 0xFF;

 uid_buffer[6] = (uid[1] >> 😎 & 0xFF;

 uid_buffer[7] = uid[1] & 0xFF;

 uid_buffer[8] = (uid[2] >> 24) & 0xFF;

 uid_buffer[9] = (uid[2] >> 16) & 0xFF;

 uid_buffer[10] = (uid[2] >> 😎 & 0xFF;

 uid_buffer[11] = uid[2] & 0xFF;

 //snprintf((char*)uid_buffer, sizeof(uid_buffer), "\n\r %08X%08X%08X \n\r", uid[2], uid[1], uid[0]);

 // Transmit the unique ID over UART

 transmit_uart(uid_buffer, sizeof(uid_buffer));

output:

with extracting via three buffers 20353339575

extracting with individaul buffer from 0 to 11 $WRP 539 

4 REPLIES 4
KnarfB
Principal III

Set a debug breakpoint after you have filled the buffers and inspect the hex values. Your output doesn't make sense to me.

hth

KnarfB

Not exactly presenting as a compelling case. Try harder

Is your string buffer big enough?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Pavel A.
Evangelist III

> transmit_uart(uid_buffer, sizeof(uid_buffer));

Some bytes of the 'unique ID' look like ascii characters - but some are not. Print all bytes in hex.

char string[32]; // Transmit the unique ID over UART

transmit_uart((void *)string, snprintf(string, sizeof(string), "\n\r %08X%08X%08X \n\r", uid[2], uid[1], uid[0]));

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..