读取STM8 Unique ID registers

来源:互联网 发布:4g转有线网络 编辑:程序博客网 时间:2024/05/22 11:38
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

0 0
原创粉丝点击