cancel
Showing results for 
Search instead for 
Did you mean: 

Unique device ID address in STM32F2xx

rmccarthy
Associate
Posted on December 10, 2013 at 12:32

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 is 

0x1FFF7A10 but do I increment in 4 Bytes?

2 REPLIES 2
Posted on December 10, 2013 at 13:45

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

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/reference_manual/CD00225773.pdf

?

Here from Rev5

0690X00000604uiQAA.png

0x1FFF7A10/0x1FFF7A14/0x1FFF7A18

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist
Posted on December 10, 2013 at 14:53

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 );

?