您的位置:首页 > 编程语言 > MATLAB

MATLAB2018A 与stm32cubemx5.3生成stm32f103x的代码

2020-03-28 20:05 1661 查看

以下对可能会出现的问题进行记录:

1 pc机安装软件注意版本:matlab2018a 、stm32cubemx5.3  stm32-mat-target4.4

2 根据stm32-mat-target4.4安装目录中的readme.pdf文件配置matlab,及matlab simlink工程,配置好matlab后,可以在simlulink库中找到:target support packege-stm32 adapter;配置过程可以参考博文:https://blog.csdn.net/u010411288/article/details/91382302

3 配置完matlab后,用simulink生成stm32的代码时候可能报错:CRL: "ARM CMSIS SIN COS" cannot be found in the registry.,可以在matlab命令行运行:RTW.TargetRegistry.getInstance('reset');解决具体见:https://ww2.mathworks.cn/matlabcentral/answers/473310-stm32f4-build-error-arm-cmsis-sin-cos?s_tid=prof_contriblnk

4 生成代码后,可能遇到在板子上执行无任何结果的情况,此时可能是生成的代码 stm32f4xx_it.c的systick终端中没有调用HAL_SYSTICK_IRQHandler();造成matlab生成的代码没有被周期调用;

5 使用定时器时,生成的代码可能在编译的时候报错,__HAL_TIM_SetCompare()等函数未定义,此函数在LEGACY版本中才有,需要定义宏USE_HAL_LEGACY,可以在预编译选项中直接加入定义:

6 使用PIL模式时,需要安装编译器,安装mingw-w64 5.3版本编译过程见博文:https://www.geek-share.com/detail/2792757028.html

注意:其中所说的环境变量名 NW_MINGW64_LOC,实际为 MW_MINGW64_LOC

  各版本mingw编译器下载如下,来自博文:https://blog.csdn.net/qq153471503/article/details/84494090

MinGW
32位下载链接:https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/

64位下载链接: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/

GCC
下载地址: http://ftp.gnu.org/gnu/gcc/

  • 点赞
  • 收藏
  • 分享
  • 文章举报
YANGM 发布了2 篇原创文章 · 获赞 1 · 访问量 70 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: