当前位置:网站首页>stm32mp1 Cortex M4开发篇8:扩展板LED灯控制实验
stm32mp1 Cortex M4开发篇8:扩展板LED灯控制实验
2022-06-21 09:09:00 【华清远见IT开放实验室】
写在前面:
本文章为《ARM Cortex-M4裸机开发篇》系列中的一篇,,全系列总计14篇。笔者使用的开发平台为华清远见FS-MP1A开发板(STM32MP157开发板),Cortex-M4裸机开发篇除了讲M4裸机开发外,还会讲解通过M4控制资源扩展板上的各种传感器执行器模块(包括空气温湿度传感器、LED灯、数码管、蜂鸣器、震动马达、按键中断、风扇等),本篇是M4控制资源扩展板中的一篇。
资源扩展板是FS-MP1A开发板的扩展模块,主要包含了10余种助主流传感器、执行器件、总线控制器件,非常方便项目扩展用。可拓展开发智慧家庭、智能医疗、智能安防、工业控制、图像识别、环境检测等方向的10个左右综合项目,华清远见开发板也将配套提供所有项目的说明文档、实验源码、应用程序等资料。
针对FS-MP1A开发板,除了Cortex-M4裸机开发篇外,还包括其他多系列教程,包括Cortex-A7开发篇、FreeRTOS篇、Linux基础及应用开发篇、Linux系统移植篇、Linux驱动开发篇、硬件设计篇、人工智能机器视觉篇、Qt应用编程篇、Qt综合项目实战篇等。欢迎关注,更多stm32mp157开发教程及视频,可加技术交流Q群459754978,感谢关注。
FS-MP1A开发板详情介绍:淘宝网 - 淘!我喜欢
目录
1.资源扩展板介绍
1.1硬件介绍

1.2资源扩展板可开发项目

2.扩展板LED灯控制
2.1实验原理
打开扩展板原理图对照扩展板可以看到扩展板有四个LED灯,其中LED4为底板电压指示灯,LD1、LD2、LD3为可控LED,原理如下:

有图可知,当LED1为高电平是三极管Q1导通,这时发光二极管LED1会被点亮,同理当LED2和LED3为高电平时LD2、LD3会被点亮。
查看原理图可知LED1、LED2、LED3分别对应STM32MP157芯片的PE10、PF10、PE8如下图:

扩展板与底板接口对照图
根据网络编号可最终追至CPU对应管脚,由于上图已经可以明确LED灯对应管脚。
原理图网络编号 | 对应管脚 | 管脚功能 | 管脚功能码 |
LED1 | PE10 | GPIO | ANALOG |
LED2 | PF10 | GPIO | ANALOG |
LED3 | PE8 | GPIO | ANALOG |
2.2实验目的
了解LED工作原理
学习GPIO口的使用方法,掌握如何利用STM32MP157A芯片的I/O口控制LED
2.3实验环境
FS-MP1A开发平台
ST-Link仿真器
STM32CubeIDE开发软件
PC机 XP、Window7/10 (32/64bit)
2.4实验步骤
打开STM32CubeIDE,配置CubeMX。
搜索框内搜索扩展板LED对应GPIO引脚PE8、PE10、PF10,左键点击设置为GPIO_Output

这里我们需要注意一下,和其他单片机不同,还需要继续设置“ Pin Reservation”给“ Cortex-M4”,否则STM32CubeMX不会生生成GPIO初始化相关代码。具体操作:在刚才选择的引脚上,鼠标右键选择“ Pin Reservation”->“ Cortex-M4”。

在Code Generator处选择为每个外设生成单独的C和H文件,这样设置方便阅读代码

完成以上设置后,Ctrl+S保存,会提示是否需要生成代码,选择Yes即可自动生成代码。系统会自动生成System Clock代码

上述为新建工程配置过程,可参考12.3.2章节进行导入已有工程,工程存放路径【华清远见-FS-MP1A开发资料\02-程序源码\ARM体系结构与接口技术\Cortex-M4\7_EX_GPIO_LED】
添加GPIO函数说明:
我们需要在main.c中添加GPIO相关函数, GPIO引脚输出电平高低函数
void bsp_led_on(void)
{
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_8,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_10,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOF,GPIO_PIN_10,GPIO_PIN_SET);
}
void bsp_led_off(void)
{
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_8,GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOE,GPIO_PIN_10,GPIO_PIN_RESET);
HAL_GPIO_WritePin(GPIOF,GPIO_PIN_10,GPIO_PIN_RESET);
}
在main.c中调用函数改变GPIO引脚高低电平来改变LED灯的状态

硬件平台:华清远见FS-MP1A开发板(STM32MP157)
部分开发教程下载:加QQ群459754978,群文件里有。
部分视频课程收看:华清远见研发中心的个人空间_哔哩哔哩_Bilibili
淘宝购买链接:华清远见stm32mp157 linux开发板stm32单片机arm开发嵌入式学习板
手机淘宝分享码:复制本行文字打开手淘₤T4FPXn3YYJ2₤
边栏推荐
- The difference between tuples and lists
- Shortcut keys accumulated when using various software
- Abstractqueuedsynchronizer (AQS) source code detailed analysis - semaphore source code analysis
- [vs], [usage problem], [solution] when VS2010 is opened, it stays in the startup interface
- Binary search (integer binary)
- Windows10 LAN shared folder process
- Unity .net 框架问题
- Detailed analysis of ThreadPoolExecutor source code of thread pool
- window10局域网共享文件夹流程
- Audio immersive experience
猜你喜欢

Lei niukesi --- basis of embedded AI

STL教程3-类型转换static_cast、dynamic_cast、const_cast、reinterpret_cast方法

智能制造的下一站:云原生+边缘计算双轮驱动

The next stop of Intelligent Manufacturing: cloud native + edge computing two wheel drive

Binary search (integer binary)

Audio immersive experience

PingCAP 入选 2022 Gartner 云数据库“客户之声”,获评“卓越表现者”最高分

Alibaba P6 employees came to a small company for an interview and asked for an annual salary increase of 500000 yuan. How dare you speak

Client construction and Optimization Practice

【实战】STM32 FreeRTOS移植系列教程7:FreeRTOS 事件标志组
随机推荐
Unity . Net framework
sql查看数据库/表磁盘占用情况,杀死进程终止tidb中的连接
优化食品生产行业库存管理的6种方法
[vs], [usage problem], [solution] when VS2010 is opened, it stays in the startup interface
Requirements for setting up points sign in tasks and common problems in the process of building points mall
leetcode:19. Delete the penultimate node of the linked list
Jar package required for full stack development
Unity write multithreading considerations
It is said that this year gold three silver four has become gold one silver two.
R language uses the < - operator to create new variables, uses the attach function to bind data, and directly uses the two data column names to calculate mean value to make new feelings in D
The R language plot function visualizes multiple lines in the same plot, and uses the BMP function to save the visualization image to the BMP format file in the specified directory
android 数据库升级
Android database upgrade
Qsort sort string
Linux环境下MySQL的安装过程
Token, cookie and session
R language through rprofile Site file, custom configuration of R language development environment startup parameters, shutdown parameters, configuration of R startup output custom text and system time
Detailed analysis of abstractqueuedsynchronizer (AQS) source code - Analysis of lock release and response interrupt locking processes
finally block can not complete normally
Post-Process初级使用笔记(重要的几项)