读取STM8 Unique ID registers

本文介绍了一种用于STM8S105XX芯片的UID解析方法,通过定义联合体类型来获取芯片的X坐标、Y坐标、晶圆编号及生产批次等信息。该方法适用于IAR环境,并提供了具体的内存地址布局。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

here is a more generic code:

==========u_id.h=================

//u_id for stm8s105xx chips
/*typedef union {
        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_t;                                                                        //u_id typ

__no_init const U_ID_t U_ID @ 0x48cd;
*/

//alternative approach to delcare U_ID
__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


//
/*to verify, compare the following with the corresponding items in above struct
__no_init const unsigned short X_coordinate @ 0x48cd;                //X-coordinate on the wafter
__no_init const unsigned short Y_coordinate @ 0x48cf;                //Y-coordinate on the wafer
__no_init const unsigned char Wafer_Number @ 0x48d1;                        //wafer number
__no_init const unsigned char Lot_Number[7] @ 0x48d2;                //wafer number
__no_init const unsigned char Lot_Number0 @ 0x48d2;                //lot number
__no_init const unsigned char Lot_Number1 @ 0x48d3;                //lot number
__no_init const unsigned char Lot_Number2 @ 0x48d4;                //lot number
__no_init const unsigned char Lot_Number3 @ 0x48d5;                //lot number
__no_init const unsigned char Lot_Number4 @ 0x48d6;                //lot number
__no_init const unsigned char Lot_Number5 @ 0x48d7;                //lot number
__no_init const unsigned char Lot_Number6 @ 0x48d8;                //lot number
//end to verify*/
=====================================

it was written for iar and on on stm8s105xx. for other chips, you may need to change the offset.

all you need to do is to include it in your code and compile.

U_ID.X_coordinate gives you the x coordinate of the chip on its wafer; etc.

or U_ID.str gives you the entire 12 bytes in a string format.
</pre><pre code_snippet_id="477972" snippet_file_name="blog_20140930_1_8961502" name="code" class="cpp">
</pre><pre code_snippet_id="477972" snippet_file_name="blog_20140930_1_8961502" name="code" class="cpp"><span style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);">第1、2字节:x坐标</span><br style="word-wrap: break-word; color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);" /><span style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);">第3、4字节:y坐标</span><br style="word-wrap: break-word; color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);" /><span style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);">第5字节:晶体号</span><br style="word-wrap: break-word; color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);" /><span style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);">第6~第12字节:生产批号</span><br style="word-wrap: break-word; color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);" /><span style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 14px; line-height: 21px; background-color: rgb(238, 238, 238);">我只能告诉你这么多了。。。。。。。。。。</span>
还有一种:http://blog.chinaaet.com/detail/24156

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值