Keil MDK的CMSIS USART Driver使用

前言:本文适用于使用过Keil MDK软件且有一定的单片机开发基础的人员

软件版本:Keil MDK v5.24

硬件开发板:STM32F429I-Discovery

预备知识:

Keil RTX线程使用

Keil MDK v5新增了pack Installer、Manage Run-Time Environment等功能使我们可以快速创建基于芯片pack包的工程。而基于ARM CMSIS标准的接口使程序的移植性大提高。此帖就演示如何快速创建基于ARM CMSIS 标准的串口驱动。

Keil MDK最新版软件下载地址:http://tools.emdoor.com/products/arm/keil/1196.html

或者:https://www.keil.com/demo/eval/arm.htm#/DOWNLOAD

pack包安装与下载

相关的芯片pack包也可以在keil官网(https://www.keil.com/dd2/pack/)下载

新建工程并配置相关外设

  • 创建工程

利用Manage Run-Time Environment配置工程

  • 添加Keil RTX实时操作系统

  • 添加CMSIS USART驱动

具体需要添加的

CMSIS->CORE

CMSIS Driver-USART(API)->USART

CMSIS->RTOS

Device->Startup

Board Support->LED(API)

Device->STM32Cube Framework(API)->Classic

  • 然后点击窗口中左下角Resolve按钮,让IDE自动帮我们选择其他需要的项目

  • 配置系统时钟频率为168MHZ,选择左侧工程窗口的CMSIS->RTX_Conf_CM.c打开RTE_Device文件,选择Configuration Wizard模式,将RTOS Kernel Timer input clock frequence频率设置为168000000(168MHZ)

  • 配置USART1的硬件接口:选择左侧工程窗口的Device->RTE_Device.h打开文件。选择Configuration Wizard模式,使用USART1并配置USART1_RX引脚为PA10,USART1_TX引脚为PA9

 

  • 通过查询窗口找到外部时钟宏定义并更改晶振宏定义数值为8000000(8MHZ)

创建串口线程编写代码

  • 编译后将hex文件通过ST-Link

效果

打开串口工具,这里使用SecureCRT工具。查看串口输出

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Version: 2.15.0 (2020-09-28) Keil.STM32F4xx_DFP.2.15.0.pack Download Updated Pack to STM32Cube_FW_F4 Firmware Package version V1.25.1 using HAL Drivers V1.7.9. STM32CubeMX integration (Version 6.0.1): Added support for Timebase Source TIMx (FrameworkCubeMX_gpdsc.ftl). Removed non-existent include path. CMSIS Flash Algorithm: Corrected STM32F42xxx_43xxx_OPT Algorithm. CMSIS SVD: Updated STM32F42*.svd, STM32F43*.svd files. CMSIS-Driver: I2C: Corrected 2 byte reception in master mode. MCI: Replaced empty delay loops with _NOP(). SPI: Corrected PowerControl function (to return error if Initialize was not called, to abort active transfer if power off was requested). Updated GetDataCount function to give accurate count in DMA mode. Corrected Control function (abort in DMA mode, software controlled slave select in slave mode, TI Frame Format selection, ignore bus speed for slave mode). Corrected Uninitialize function (to power off the peripheral if it is powered). Corrected SPI3_SCK pin configuration. Corrected DMA MemDataAlignment configuration. USART: Corrected DMA MemDataAlignment configuration. USBD_HS/USBH_HS: OTG_HS ULPI clock disabled in low power if internal PHY is used to enable proper operation of OTG_HS port in FS mode during CPU sleep. CAN/EMAC/USBD/USBH: Removed macros already provided by cmsis_compiler.h. Updated Boards Examples: Migrated CubeMX projects to V6.0.1 and updated config files. Changed variant selection to "MDK-Plus" where possible. Updated all USB Host/Device examples with user templates from MDK-Middleware v7.11.1. Terminating app_main thread with osThreadExit() to avoid endless loop Updated MS Windows UBS driver files.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值