RT-Thread 学习笔记(三)——读取MCU ID及FLASH大小

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/skawu/article/details/78507466
突然想读一读MCU的识别ID号和FLASH大小,那就写一写呗!

型号:stm32f103zet6

根据datasheet知道相应的内容存储地址:

 

 然后就贴代码:

void rt_show_mcu_id(void)
{
    unsigned int mcu_id[3];
    unsigned short mcu_flash_size;

    mcu_id[0] = *(unsigned int*)(0x1FFFF7E8);
    mcu_id[1] = *(unsigned int*)(0x1FFFF7EC);
    mcu_id[2] = *(unsigned int*)(0x1FFFF7F0);
    rt_kprintf("MCU ID: %X %X %X\n",mcu_id[0],mcu_id[1],mcu_id[2]);
    mcu_flash_size = *(unsigned short*)(0x1FFFF7E0);
    rt_kprintf("MCU Flash size: %d K\n",mcu_flash_size);
}

调用这个函数就可以了!

 

完工!!!

展开阅读全文

没有更多推荐了,返回首页