很开心能够参与这次ufun开发板的测评,ufun是一块“麻雀虽小,五脏俱全”的开发板。不仅如此,它在最小系统电路的基础上,增加了RGB-LED、蜂鸣器、加速度传感器、触摸按键、超级电容等有趣的外设电路。使得在这一块小电路板上,可以实现更多有意思的功能。
本次试用,我将全程使用STM32CubeMX + MDK5的工具组合,对ufun开发板进行探索。这样同时保证了开发的快速性和对代码细节的把握。
话不多说,就此进入本次主题。单片机开发的“hello world”--点亮LED!
第一步,分析开发板原理图。
由图可知PA0、PA1、PA2分别对应RGB-LED的G、B、R三个颜色分量的控制端。只需给管脚高电平,即可点亮对应的颜色。


第二步, 创建工程。
打开STM32CubeMX ,在主页中选择芯片。

在出现的搜索栏里输入关键字“F103RC”,即可出现ufun开发板上对应的芯片类型。

双击STM32F103RCTx,进入工程。
首先选择芯片的时钟源,我们选择板载外部晶振。

接下来配置时钟树,我们进入时钟树界面,我们将其配置成本型号的最高主频72M,注意ufun使用的是12M晶振,需要把默认的8M修改为12M,具体配置如图。

接下来配置GPIO,我们回到外设配置界面,可以看到芯片的管脚图。

本次我们只控制一路蓝色LED,所以选择PA1。

将其配置称为推挽输出,并重命名为LED_0。

接下来就可以生成工程了。配置好工程名、路径与工程类型,生成工程的设置如下。


点击GENERATE CODE,生成工程,并打开生成的MDK工程。

第三步、修改代码。
在工程的main函数中,只需要加入两行代码即可,功能是使LED每秒切换一次状态。

编译并烧写程序,开发板就可以开始闪烁啦!


工程源码(附件):

继续阅读本篇相关更多标签
热门资料
热门活动
全部回复 1
- 0 主题
- 1711 帖子
- 6179 积分
身份:LV6 初级工程师
E币:2180
发消息
学习板开发环境
>>资料:UFUN开发板学习笔记2.OLED能显示哪些ASC符号源程序