RT-Thread Studio使用笔记(八):PWM的使用

 按board.h说明进行配置

    根据前几次实验,发现使用RTT组件非常简单,只要根据board.h中对应的步骤进行修改即可,比如要使用pwm组件,需要进行如下4步操作。

/** if you want to use pwm you can use the following instructions.
 *
 * STEP 1, open pwm driver framework support in the RT-Thread Settings file
 *
 * STEP 2, define macro related to the pwm
 *                 such as     #define BSP_USING_PWM1
 *
 * STEP 3, copy your pwm timer init function from stm32xxxx_hal_msp.c generated by stm32cubemx to the end if board.c file
 *                 such as     void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)  and
 *                             void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
 *
 * STEP 4, modify your stm32xxxx_hal_config.h file to support pwm peripherals. define macro related to the peripherals
 *                 such as     #define HAL_TIM_MODULE_ENABLED
 *
 */

概况来说,仅仅需要如下4步即可完成配置:

  • 1. 使能框架层
  • 2. 打开板级支持宏定义
  • 3. 拷贝初始化函数(cubemx)
  • 4. 打开hal库外设模块使能

但是,PWM的使用,还需要单独进行通道的使能配置(系统没有自动使能),,如下所示:

#define BSP_USING_PWM3
// 必须进行PWM通道的使能操作
#define BSP_USING_PWM3_CH1
#define BSP_USING_PWM3_CH2

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值