
也就是说,通过设置这组寄存器,可以达到设置或者重设ODx bit
和我平时理解的稍微有些差异
我以为设置,那么就置一,重置呢就置零(再不解放台湾,志玲就老了)
实际上呢,设置是把 Port x set bit y 置一
重置呢是把Port x reset bit y 置零
再回头看mbed官网连接中的这个程序:
#include "mbed.h" // Reuse initialization code from the mbed library DigitalOut led1(LED1); // P1_18 int main() { unsigned int mask_pin18 = 1 << 18; volatile unsigned int *port1_set = (unsigned int *)0x2009C038; volatile unsigned int *port1_clr = (unsigned int *)0x2009C03C; while (true) { *port1_set |= mask_pin18; wait(0.5); *port1_clr |= mask_pin18; wait(0.5); } }
对于我们来讲:
portA_set 的地址为:0x5000 0000 + 0x18
portA_reset 的地址同样为:0x5000 0000 + 0x18
与例子中使用的MCU还是有所差异的

仿照这个例子:
我们重写个blink for Nucleo L053R8
#include <mbed.h> DigitalOut myled(LED1); int main() { unsigned int mask_pin5 = 1 << 5; volatile unsigned int *porta_set = (unsigned int *)0x50000018; volatile unsigned int *porta_clr = (unsigned int *)0x50000018; while (true) { *porta_set |= mask_pin5; wait(0.5); *porta_clr |= (mask_pin5 << 16); wait(0.5); } }
下到Nucleo L053R8中,是不是开始闪烁啦?
真好玩啊真好玩
回复
打赏帖 | |
---|---|
汽车电子中巡航控制系统的使用被打赏10分 | |
【我踩过的那些坑】工作那些年踩过的记忆深刻的坑被打赏100分 | |
分享汽车电子中巡航控制系统知识被打赏10分 | |
分享安全气囊系统的检修注意事项被打赏10分 | |
分享电子控制安全气囊计算机知识点被打赏10分 | |
【分享开发笔记,赚取电动螺丝刀】【OZONE】使用方法总结被打赏20分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K314】芯片启动流程分析被打赏40分 | |
【分享开发笔记,赚取电动螺丝刀】【S32K146】S32DS RTD 驱动环境搭建被打赏12分 | |
【分享开发笔记,赚取电动螺丝刀】【IAR】libc标注库time相关库函数使用被打赏23分 | |
LP‑MSPM0L1306开发版试用结果被打赏10分 |