[单片机芯片] 使用CH32V103获取唯一ID怎么操作

[复制链接]
1407|2
 楼主| yangjiaxu 发表于 2022-6-17 09:26 | 显示全部楼层 |阅读模式
官方有没有使用CH32V103获取唯一ID的操作,有代码提供么?
lilijin1995 发表于 2022-6-17 15:43 | 显示全部楼层
本帖最后由 lilijin1995 于 2022-6-17 15:45 编辑
  1. #define         UID_BASE              0x1FFFF7E8UL    /*!< Unique device ID register base address */
  2. #define         DEVICE_ID1          (UID_BASE)
  3. #define         DEVICE_ID2          (UID_BASE + 0x4)
  4. #define         DEVICE_ID3          (UID_BASE + 0x8)
  5. static void Get_SerialNum(void)
  6. {
  7.   uint32_t deviceserial0, deviceserial1, deviceserial2;

  8.   deviceserial0 = *(uint32_t *) DEVICE_ID1;
  9.   deviceserial1 = *(uint32_t *) DEVICE_ID2;
  10.   deviceserial2 = *(uint32_t *) DEVICE_ID3;

  11.   deviceserial0 += deviceserial2;

  12.   if (deviceserial0 != 0)
  13.   {
  14.     IntToUnicode(deviceserial0, &USBD_StringSerial[2], 8);
  15.     IntToUnicode(deviceserial1, &USBD_StringSerial[18], 4);
  16.   }
  17. }


跟STM32的地址一样的,https://www.bilibili.com/video/BV17r4y1z758/?vd_source=2bbde87de845d5220b1d8ba075c12fb0
可以参考我们的Eg3和Eg4
 楼主| yangjiaxu 发表于 2022-6-17 15:53 | 显示全部楼层
lilijin1995 发表于 2022-6-17 15:43
跟STM32的地址一样的,https://www.bilibili.com/video/BV17r4y1z758/?vd_source=2bbde87de845d5220b1d8b ...

如果和ST的一样就好办了,我们之前有用过ST的唯一ID,有获取函数,感谢坛友
您需要登录后才可以回帖 登录 | 注册

本版积分规则

认证:嵌入式技术专家
简介:擅长电路设计、物联网产品开发、射频产品开发,喜欢打篮球,技术交流,欢迎各位来聊~

805

主题

3383

帖子

10

粉丝
快速回复 在线客服 返回列表 返回顶部