STM8 读取 UID

UID

UID即Unique ID,STM8S105提供了96BIT的全球唯一ID,可以用于加密,也可以用于板子的ID,像我的应用,就是用在了给箱子一个全球唯一的ID,这样就便于联网了。

用UID的时候,请参考英文手册,不知道为什么,中文版的是没有UID这方面的介绍的。那么我们就来学习一下UID把,官方给的应用如下:

•For use as serial numbers

•For use as security keys to increase the code security in the program memory while using and combining this unique ID with software cryptograhic primitives and protocols before programming the internal memory.

•To activate secure boot processes

其地址如下:

 1473251352-3985-30

1-2 byte为晶圆上x轴位置
3-4 byte为晶圆上y轴位置
5   byte为晶圆号码
6-12 byte是Lot number.

实际上一开始的时候,我也对UID的读取是相当的疑惑,但是看了这个地址后,其实就是直接读取地址上的数据就可以了。程序如下:

void get_id(void)

{

u8 i;

u16 addr;

u8 uid1[12];

addr=0x48CD;

for(i=0;i<12;i++)

{

uid1[i]=*(u8*)addr++;

putchar(uid1[i]);

}

}

怎么样,简单把,还有另外一个方法,在网上搜到的,也分享给大家把,

__no_init const union { //either the struct or a string

struct { //nameless struct

unsigned short X_coordinate; //X-coordinate on the wafter

unsigned short Y_coordinate; //Y-coordinate on the wafer

unsigned char Wafer_Number; //wafer number

unsigned char Lot_Number[7]; //lot number

} ;

unsigned char str[12]; //or the string

} U_ID @ 0x48cd; //u_id typ

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注