在使用 lpc55s69_nxp_evk 开发板对接 rtduino 的过程,对接 PWM 部分的时候,遇到了不少坑,在此记录。
BSP 中 driver 的问题
由于调用的 SDK 版本问题,kCLOCK_CTimer 需要更改为 kCLOCK_Timer,这个问题在与定时器相关的 drv_hwtimer 文件中同样存在。
同样因为 SDK 的版本问题,CTIMER_SetupPwmPeriod 函数增加了一个参数
/*!
- brief Configures the PWM signal parameters.
- Enables PWM mode on the match channel passed in and will then setup the match value
- and other match parameters to generate a PWM signal.
- This function can manually assign the specified channel to set the PWM cycle.
- note When setting PWM output from multiple output pins, all should use the same PWM
- period
- param base Ctimer peripheral base address
- param pwmPeriodChannel Specify the channel to control the PWM period
- param matchChannel Match pin to be used to output the PWM signal
- param pwmPeriod PWM period match value
- param pulsePeriod Pulse width match value
- param enableInt Enable interrupt when the timer value reaches the match value of the PWM pulse,
if it is 0 then no interrupt will be generated.- return kStatus_Success on success
kStatus_Fail If matchChannel is equal to pwmPeriodChannel; this channel is reserved to set the PWM period
*/
status_t CTIMER_SetupPwmPeriod(CTIMER_Type *base,
const ctimer_match_t pwmPeriodChannel,
ctimer_match_t matchChannel,
uint32_t pwmPeriod,
uint32_t pulsePeriod,
bool enableInt)
新增的 param pwmPeriodChannel 指定一个定时器的通道控制 PWM 的 Period ,需要注意的是,其中提示:当使用一个定时器的多个通道输出 PWM 时,其 Period 均是一致的。
通过对比之前版本的 SDK ,了解到之前是使用 kCTIMER_Match_3 通道作为 pwmPeriodChannel 。因此,在对应的参数位置填入 kCTIMER_Match_3 。
引脚配置问题
解决上述的那些问题之后,就已经可以正常使用 PWM 了。但是在对接 RTduino 的过程中又出现了新的问题。
在 RTduino 框架下一直不能正常使用 PWM 功能,最后发现,是需要将引脚配置为对应的功能,具体对应到的是 RT-Threadrtthreadbsplpc55sxxlpc55s69_nxp_evkboardMCUX_Configboardpin_mux 相关文件,可以通过 NXP 官方工具进行配置 MCUXpresso Config Tools
修改引脚功能后,rtduino 框架下的 PWM 还是对接不上,debug 发现在 drv_pwm 中定时器2对应的是 pwm1 ,而 RT-Thread 的设备框架下应该对应的是 pwm2 ,导致识别不到。于是将 drv_pwm 中定时器2改为 pwm2 ,呼吸灯正常。
之后优化的方向
使用 bsp 时注意到,drv_pwm 中只考虑了定时器2一种情况,并且只有一个通道。接下来需要对 PWM 设备进一步的抽象,更好的对接到 RT-Thread 的设备框架下。
-
LPC
+关注
关注
8文章
137浏览量
79379 -
定时器
+关注
关注
23文章
3373浏览量
124531 -
RT-Thread
+关注
关注
32文章
1638浏览量
45207 -
PWM输出
+关注
关注
1文章
68浏览量
6820
发布评论请先 登录
光耦失效的N种现场!工程师都踩过的坑
从 FRAM 读取数据期间 I2C 通信卡住了,怎么解决?
使用 LPC55S69 和 MCUX 驱动程序的 CDC 应该实现什么样的吞吐量?
Linux新手最常踩的10个命令坑介绍
采购晶振怕被坑?这份避坑手册请收好
无法获得在 StarFive 上运行的 StarFive Linux 映像的 55 或 69 版本,怎么解决?
N沟道 vs P沟道MOS管,怎么选才不踩坑?一文搞懂选型关键
从踩坑到高效落地:关键词搜索淘宝天猫商品列表 API 的实操心得
塑料激光焊接机怎么选?看完这篇不踩坑
K8s生产环境10大踩坑记录复盘
记ESP32CAM踩坑解决指南,已反映商家
智能工厂改造踩坑?有人物联网手把手教你挑对系统
STM32 5 个容易踩坑的外设使用技巧
LPC55S69 PWM踩坑寄录
评论