在使用 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文章
136瀏覽量
77714 -
定時器
+關注
關注
23文章
3255瀏覽量
115385 -
RT-Thread
+關注
關注
31文章
1305瀏覽量
40388 -
PWM輸出
+關注
關注
1文章
66瀏覽量
5220
發布評論請先 登錄
相關推薦
手機喇叭氣密性檢測儀選購攻略,避免踩坑!
![手機喇叭氣密性檢測儀選購攻略,避免<b class='flag-5'>踩</b><b class='flag-5'>坑</b>!](https://file1.elecfans.com/web3/M00/04/DA/wKgZO2d4ycuAXRh6AABrRj1NM4Q645.png)
串口設計如何避免踩坑?看這篇!
![串口設計如何避免<b class='flag-5'>踩</b><b class='flag-5'>坑</b>?看這篇!](https://file1.elecfans.com/web3/M00/03/73/wKgZPGdpHfWAOcOdAAMkQITM7Ug963.png)
踩坑又給項目埋雷,RS485自動收發電路設計
![<b class='flag-5'>踩</b><b class='flag-5'>坑</b>又給項目埋雷,RS485自動收發電路設計](https://file1.elecfans.com/web3/M00/01/4A/wKgZO2dSW_2AbkIkAAASDdThh94098.jpg)
ADC高速采樣電路設計詳解之STM32踩坑
![ADC高速采樣電路設計詳解之STM32<b class='flag-5'>踩</b><b class='flag-5'>坑</b>](https://file1.elecfans.com/web3/M00/00/AA/wKgZO2dNDYKAFHMzAAAy6RZvMtU132.png)
在學習go語言的過程踩過的坑
零基礎開發小安派-Eyes-S1【外設篇】——PWM
![零基礎開發小安派-Eyes-<b class='flag-5'>S</b>1【外設篇】——<b class='flag-5'>PWM</b>](https://file1.elecfans.com//web1/M00/F4/64/wKgZoWcq2yeAHsRMAAC0LA8cL7M904.jpg)
CMS8S69xx可代替STM8S003F3P6 5.5V多個封裝
【RA-Eco-RA0E1-32PIN-V1.0開發板試用】+ 應用遇到的坑
ESP32C3 I2C no ack無應答怎么解決?
家庭路由器如何選?實用技巧讓你不再踩坑!
stm8s001退出仿真后,進入不了halt模式,耗電一直為1MA左右,為什么?
恩智浦半導體發布S32N55處理器,賦能汽車中央實時控制!
痛苦踩坑“電池電壓偵測電路”,含淚總結設計要點
![痛苦<b class='flag-5'>踩</b><b class='flag-5'>坑</b>“電池電壓偵測電路”,含淚總結設計要點](https://file1.elecfans.com/web2/M00/C8/26/wKgaomYSPcWAZXv3AAAY09AD45A917.png)
高低溫試驗箱選購指南—防踩坑秘籍
![高低溫試驗箱選購指南—防<b class='flag-5'>踩</b><b class='flag-5'>坑</b>秘籍](https://file1.elecfans.com/web2/M00/C0/D3/wKgZomXZROyASRaVAABMFw0LEso848.png)
評論