{"id":1122,"date":"2016-09-07T20:30:14","date_gmt":"2016-09-07T12:30:14","guid":{"rendered":"http:\/\/www.kumouse.com\/?p=1122"},"modified":"2016-09-07T20:30:14","modified_gmt":"2016-09-07T12:30:14","slug":"stm8-%e8%af%bb%e5%8f%96-uid","status":"publish","type":"post","link":"https:\/\/www.kumouse.com\/?p=1122","title":{"rendered":"STM8 \u8bfb\u53d6 UID"},"content":{"rendered":"<p>UID<\/p>\n<p>UID\u5373Unique ID,STM8S105\u63d0\u4f9b\u4e8696BIT\u7684\u5168\u7403\u552f\u4e00ID,\u53ef\u4ee5\u7528\u4e8e\u52a0\u5bc6\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u677f\u5b50\u7684ID\uff0c\u50cf\u6211\u7684\u5e94\u7528\uff0c\u5c31\u662f\u7528\u5728\u4e86\u7ed9\u7bb1\u5b50\u4e00\u4e2a\u5168\u7403\u552f\u4e00\u7684ID\uff0c\u8fd9\u6837\u5c31\u4fbf\u4e8e\u8054\u7f51\u4e86\u3002<\/p>\n<p>\u7528UID\u7684\u65f6\u5019\uff0c\u8bf7\u53c2\u8003\u82f1\u6587\u624b\u518c\uff0c\u4e0d\u77e5\u9053\u4e3a\u4ec0\u4e48\uff0c\u4e2d\u6587\u7248\u7684\u662f\u6ca1\u6709UID\u8fd9\u65b9\u9762\u7684\u4ecb\u7ecd\u7684\u3002\u90a3\u4e48\u6211\u4eec\u5c31\u6765\u5b66\u4e60\u4e00\u4e0bUID\u628a\uff0c\u5b98\u65b9\u7ed9\u7684\u5e94\u7528\u5982\u4e0b\uff1a<\/p>\n<p>\u2022For use as serial numbers<\/p>\n<p>\u2022For 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.<\/p>\n<p>\u2022To activate secure boot processes<\/p>\n<p align=\"left\">\n<p align=\"left\">\u5176\u5730\u5740\u5982\u4e0b\uff1a<\/p>\n<p>\u00a0<a href=\"http:\/\/www.kumouse.com\/wp-content\/uploads\/2016\/09\/1473251352-3985-30.png\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-medium size-medium\" src=\"http:\/\/www.kumouse.com\/wp-content\/uploads\/2016\/09\/1473251352-3985-30-300x217.png\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" srcset=\"http:\/\/www.kumouse.com\/wp-content\/uploads\/2016\/09\/1473251352-3985-30-300x217.png 300w, http:\/\/www.kumouse.com\/wp-content\/uploads\/2016\/09\/1473251352-3985-30-768x554.png 768w, http:\/\/www.kumouse.com\/wp-content\/uploads\/2016\/09\/1473251352-3985-30-1024x739.png 1024w, http:\/\/www.kumouse.com\/wp-content\/uploads\/2016\/09\/1473251352-3985-30.png 1179w\" alt=\"1473251352-3985-30\" width=\"300\" height=\"217\" \/><\/a><\/p>\n<p>1-2\u00a0byte\u4e3a\u6676\u5706\u4e0ax\u8f74\u4f4d\u7f6e<br \/>\n3-4\u00a0byte\u4e3a\u6676\u5706\u4e0ay\u8f74\u4f4d\u7f6e<br \/>\n5\u00a0\u00a0\u00a0byte\u4e3a\u6676\u5706\u53f7\u7801<br \/>\n6-12\u00a0byte\u662fLot\u00a0number.<\/p>\n<p>\u5b9e\u9645\u4e0a\u4e00\u5f00\u59cb\u7684\u65f6\u5019\uff0c\u6211\u4e5f\u5bf9UID\u7684\u8bfb\u53d6\u662f\u76f8\u5f53\u7684\u7591\u60d1\uff0c\u4f46\u662f\u770b\u4e86\u8fd9\u4e2a\u5730\u5740\u540e\uff0c\u5176\u5b9e\u5c31\u662f\u76f4\u63a5\u8bfb\u53d6\u5730\u5740\u4e0a\u7684\u6570\u636e\u5c31\u53ef\u4ee5\u4e86\u3002\u7a0b\u5e8f\u5982\u4e0b\uff1a<\/p>\n<p>void get_id(void)<\/p>\n<p>{<\/p>\n<p>u8 i;<\/p>\n<p>u16 addr;<\/p>\n<p>u8 uid1[12];<\/p>\n<p>addr=0x48CD;<\/p>\n<p>for(i=0;i&lt;12;i++)<\/p>\n<p>{<\/p>\n<p>uid1[i]=*(u8*)addr++;<\/p>\n<p>putchar(uid1[i]);<\/p>\n<p>}<\/p>\n<p>}<\/p>\n<p>\u600e\u4e48\u6837\uff0c\u7b80\u5355\u628a\uff0c\u8fd8\u6709\u53e6\u5916\u4e00\u4e2a\u65b9\u6cd5\uff0c\u5728\u7f51\u4e0a\u641c\u5230\u7684\uff0c\u4e5f\u5206\u4eab\u7ed9\u5927\u5bb6\u628a\uff0c<\/p>\n<p>__no_init const union { \/\/either the struct or a string<\/p>\n<p>struct { \/\/nameless struct<\/p>\n<p>unsigned short X_coordinate; \/\/X-coordinate on the wafter<\/p>\n<p>unsigned short Y_coordinate; \/\/Y-coordinate on the wafer<\/p>\n<p>unsigned char Wafer_Number; \/\/wafer number<\/p>\n<p>unsigned char Lot_Number[7]; \/\/lot number<\/p>\n<p>} ;<\/p>\n<p>unsigned char str[12]; \/\/or the string<\/p>\n<p>} U_ID @ 0x48cd; \/\/u_id typ<\/p>\n","protected":false},"excerpt":{"rendered":"<p>UID UID\u5373Unique ID,STM8S105\u63d0\u4f9b\u4e8696BIT\u7684\u5168\u7403\u552f\u4e00ID,\u53ef\u4ee5\u7528\u4e8e\u52a0\u5bc6\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u677f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1123,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-1122","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-stm32"],"_links":{"self":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/1122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1122"}],"version-history":[{"count":1,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/1122\/revisions"}],"predecessor-version":[{"id":1124,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/posts\/1122\/revisions\/1124"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=\/wp\/v2\/media\/1123"}],"wp:attachment":[{"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kumouse.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}