当前位置:网站首页>MATLAB/Simulink&&STM32CubeMX工具链完成基于模型的设计开发(MBD)(三)
MATLAB/Simulink&&STM32CubeMX工具链完成基于模型的设计开发(MBD)(三)
2022-07-31 03:57:00 【小师兄1995】
前言
基于上两篇内容,本篇博客借助于STM32提供的MATLAB硬件支持包完成基于模型的开发。此工具链用到的工具为MATLAB/Simulink和STM32CubeMX,而省略了Keil工具进行手工代码集成的步骤,所有的工作仅在MATLAB/Simulink和STM32CubeMX完成。
注:应用此工具链需要安装STM32硬件支持包,STM32CubeMX和STM32CubeProgrammer,并进行硬件环境配置。
一、概述
设计需求:通过按键控制两个LED的状态,按一次按键两个LED亮,再按一次按键两个LED以1s时间间隔交替闪烁,再按一次按键,两个LED灭。
控制器:STM32F407ZG
应用层开发:MATLAB/Simulink
底层配置:STM32CubeMX
二、使用步骤
1.硬件设计
指示灯:LED0、LED1
按键:KEY0

2.软件设计
1、MATLAB->APP->Run on Hardware Board,选择目标开发板。我的板子是STM32F407ZG,因此选STM32F4xx Based

2、新建STM32CubeMX工程,配置底层。配置PF9、PF10为输出,PE4为输入,进行Project Manager设置,保存工程




3、在MATLAB中打开设置将STM32CubeMX工程进行加载,进入MATLAB/Simulink进行应用层编程。
4、MATLAB编程如下
4.1安装STM32硬件支持包后在Simulink会出现该支持包的硬件资源
4.2读取PE4的状态,当产生一个下降沿表明按键KEY0被按下,触发子系统运行。触发第一次,子系统输出0;触发第二次,子系统输出1;触发第三次子系统输出3,重复循环。
4.2当触发子系统输出0时,关闭LED0、LED1,PF9、PF10输出1。
4.3当触发子系统输出1时,打开LED0、LED1,PF9、PF10输出0。
4.4当触发子系统输出2时,LED0和LED1成流水状态,1s间隔周期
5、设置求解器,自动处理数据传输的速率转换
6、打开开发板,点击Builid Deploy & Start,等待下载完成观察实验现象。

7、实验现象
0730
边栏推荐
猜你喜欢

LocalDate加减操作及比较大小

What is a system?
![[Dynamic programming] Maximum sum of consecutive subarrays](/img/3d/10731cc64d1c69d2beb3666ae0f064.png)
[Dynamic programming] Maximum sum of consecutive subarrays

Notes on the establishment of the company's official website (6): The public security record of the domain name is carried out and the record number is displayed at the bottom of the web page

(5) final, abstract class, interface, inner class

Understanding and Using Unity2D Custom Scriptable Tiles (4) - Start to build a custom tile based on the Tile class (below)

「 每日一练,快乐水题 」1331. 数组序号转换

TCP和UDP详解

(8) Math class, Arrays class, System class, Biglnteger and BigDecimal classes, date class

从滴滴罚款后数据治理思考
随机推荐
The application and practice of mid-to-platform brand advertising platform
LocalDate加减操作及比较大小
立足本土,链接全球 | 施耐德电气“工业SI同盟”携手伙伴共赴未来工业
(四)递归、可变参数、访问修饰符、理解 main 方法、代码块
[C language] Preprocessing operation
Summary of Huawei Distributed Storage FusionStorage Knowledge Points [Interview]
Detailed explanation of TCP (2)
pom文件成橘红色未加载的解决方案
Zotero如何删除自动生成的标签
进程间通信
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution
Why SocialFi achievement Web3 decentralized social in the future
Knowledge Distillation 7: Detailed Explanation of Knowledge Distillation Code
beforeDestroy与destroyed的使用
Redis 使用LIST做最新评论缓存
SIP协议标准和实现机制
What is a system?
端口排查步骤-7680端口分析-Dosvc服务
ClickHouse:设置远程连接
【AUTOSAR-RTE】-4-Port and Interface and Data Type