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

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 20:08   2619   0

读取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。

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP