本帖最后由 dabendan001 于 2019-6-9 15:50 编辑
方法一:
char * GetChipUniqueID_Str_STM32F10x(char* stm32id_StrBuf_32char ) { uint32_t chipUniqueID32[3]; chipUniqueID32[2] = *(__IO uint32_t*)(0X1FFFF7F0); chipUniqueID32[1] = *(__IO uint32_t*)(0X1FFFF7EC); chipUniqueID32[0] = *(__IO uint32_t*)(0X1FFFF7E8); snprintf(stm32id_StrBuf_32char,32,"0x%X-%X-%X", chipUniqueID32[0],chipUniqueID32[1],chipUniqueID32[2]); return stm32id_StrBuf_32char; }
读得的UID是:0x5DBFF30-43084562-43084562
方法二:
uint32_t * GetSTM32MCUIDPMing(uint32_t *id,MCUTypedef type) { // type =1, idAddr[type] =0x1FFFF7E8; if(id!=NULL) { id[0]=*(uint32_t*)(idAddr[type]); id[1]=*(uint32_t*)(idAddr[type]+4); id[2]=*(uint32_t*)(idAddr[type]+8); } //printf(" STM32_ID_Str(inside):0X%X-%X-%X ",id[0],id[1],id[2]); return id; }
读得的UID是:0x20009068-8000165-800016D;
为何 不相同呢??(这两个函数,写在在工程中不同的.C文件中)
我是参照这里的代码写的。
https://blog.csdn.net/foxclever/article/details/80294516
(向版主表示歉意。纯技术交流。)
一周热门 更多>