读取stm32 产品的唯一身份的寄存器

来源:互联网 发布:中国的软件怎么样 编辑:程序博客网 时间:2024/06/06 01:01

 读取stm32 产品的唯一身份的寄存器

voidGet_ChipID(void)

{

    uint32_t temp0,temp1,temp2;

        temp0 = *(__IO uint32_t*)(0x1FFF7A10);    

        temp1 = *(__IO uint32_t*)(0x1FFF7A14);

        temp2 = *(__IO uint32_t*)(0x1FFF7A18);

//    temp0=(*( uint32_t *)0x1FFF7A10);     //产品唯一身份标识寄存器(96位)

//      temp1=(*( uint32_t *)0x1FFF7A14);

//      temp2=(*( uint32_t *)0x1FFF7A18);

                                  

//ID码地址: 0x1FFFF7E8  0x1FFFF7EC  0x1FFFF7F0 ,只需要读取这个地址中的数据就可以了。

 

    temp[0] = (uint8_t)(temp0 &0x000000FF);

    temp[1] = (uint8_t)((temp0 &0x0000FF00)>>8);

    temp[2] = (uint8_t)((temp0 &0x00FF0000)>>16);

    temp[3] = (uint8_t)((temp0 & 0xFF000000)>>24);

    temp[4] = (uint8_t)(temp1 &0x000000FF);

    temp[5] = (uint8_t)((temp1 &0x0000FF00)>>8);

    temp[6] = (uint8_t)((temp1 &0x00FF0000)>>16);

    temp[7] = (uint8_t)((temp1 &0xFF000000)>>24);

    temp[8] = (uint8_t)(temp2 &0x000000FF);

    temp[9] = (uint8_t)((temp2 &0x0000FF00)>>8);

    temp[10] = (uint8_t)((temp2 &0x00FF0000)>>16);

    temp[11] = (uint8_t)((temp2 &0xFF000000)>>24);        

}

本单片机读取的数据为1D 00 5A 00 03 51 35 34 36 34 39 35。