2013-12-10 03:32 AM
Hi,
I have been looking for some time and I cannot find an answer. In a previous project I found the UID for the STM32F107 using the following function. Can someone tell me what the equivalent for STM32F2 is?void GetDeviceID(void){u8 HexTmp, H_HexTmp,L_HexTmp,i;u32 Dev_Serial0, Dev_Serial1, Dev_Serial2;u8 HEX[6] ={'A','B','C','D','E','F'};Unique_Device_ID[24] = '\0'; Dev_Serial0 = *(vu32*)(0x1FFFF7E8);Dev_Serial1 = *(vu32*)(0x1FFFF7EC);Dev_Serial2 = *(vu32*)(0x1FFFF7F0);for(i=0;i<24;) { if( 0==i ) HexTmp = (u8)Dev_Serial0; else if( 2==i ) HexTmp = (u8)( Dev_Serial0 >> 8 ); else if( 4==i ) HexTmp = (u8)( Dev_Serial0 >> 16 ); else if( 6==i ) HexTmp = (u8)( Dev_Serial0 >> 24 ); else if( 8==i ) HexTmp = (u8)Dev_Serial1; else if( 10==i ) HexTmp = (u8)( Dev_Serial1 >> 8 ); else if( 12==i ) HexTmp = (u8)( Dev_Serial1 >> 16 ); else if( 14==i ) HexTmp = (u8)( Dev_Serial1 >> 24 ); else if( 16==i ) HexTmp = (u8)Dev_Serial2; else if( 18==i ) HexTmp = (u8)( Dev_Serial2 >> 8 ); else if( 20==i ) HexTmp = (u8)( Dev_Serial2 >> 16 ); else if( 22==i ) HexTmp = (u8)( Dev_Serial2 >> 24 ); H_HexTmp = HexTmp >> 4; L_HexTmp = HexTmp & 0x0F; if( L_HexTmp > 9 ) Unique_Device_ID[i+1] = HEX[ L_HexTmp - 10 ]; else Unique_Device_ID[i+1] = L_HexTmp + '0'; if( H_HexTmp > 9 ) Unique_Device_ID[i+0] = HEX[ H_HexTmp - 10 ]; else Unique_Device_ID[i+0] = H_HexTmp + '0'; i += 2; } }I see from some earlier posts that the start address is0x1FFF7A10 but do I increment in 4 Bytes?
2013-12-10 04:45 AM
I have been looking for some time and I cannot find an answer. In a previous project I found the UID for the STM32F107 using the following function. Can someone tell me what the equivalent for STM32F2 is?
Like the ? Here from Rev5 0x1FFF7A10/0x1FFF7A14/0x1FFF7A182013-12-10 05:53 AM
The conversion code looks a bit clunky; how about:
Unique_Device_ID[25] = 0; // Don't forget the NUL terminator!
itoa( Dev_Serial2 , &Unique_Device_ID[ 0], 16 );
itoa( Dev_Serial1 , &Unique_Device_ID[ 8], 16 );
itoa( Dev_Serial0 , &Unique_Device_ID[16], 16 );
?