在使用 lpc55s69_nxp_evk 開發(fā)板對接 rtduino 的過程,對接 PWM 部分的時候,遇到了不少坑,在此記錄。
BSP 中 driver 的問題
由于調(diào)用的 SDK 版本問題,kCLOCK_CTimer 需要更改為 kCLOCK_Timer,這個問題在與定時器相關(guān)的 drv_hwtimer 文件中同樣存在。
同樣因為 SDK 的版本問題,CTIMER_SetupPwmPeriod 函數(shù)增加了一個參數(shù)
/*!
- 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 。因此,在對應的參數(shù)位置填入 kCTIMER_Match_3 。
引腳配置問題
解決上述的那些問題之后,就已經(jīng)可以正常使用 PWM 了。但是在對接 RTduino 的過程中又出現(xiàn)了新的問題。
在 RTduino 框架下一直不能正常使用 PWM 功能,最后發(fā)現(xiàn),是需要將引腳配置為對應的功能,具體對應到的是 RT-Threadrtthreadbsplpc55sxxlpc55s69_nxp_evkboardMCUX_Configboardpin_mux 相關(guān)文件,可以通過 NXP 官方工具進行配置 MCUXpresso Config Tools
修改引腳功能后,rtduino 框架下的 PWM 還是對接不上,debug 發(fā)現(xiàn)在 drv_pwm 中定時器2對應的是 pwm1 ,而 RT-Thread 的設(shè)備框架下應該對應的是 pwm2 ,導致識別不到。于是將 drv_pwm 中定時器2改為 pwm2 ,呼吸燈正常。
之后優(yōu)化的方向
使用 bsp 時注意到,drv_pwm 中只考慮了定時器2一種情況,并且只有一個通道。接下來需要對 PWM 設(shè)備進一步的抽象,更好的對接到 RT-Thread 的設(shè)備框架下。
-
LPC
+關(guān)注
關(guān)注
8文章
137瀏覽量
78142 -
定時器
+關(guān)注
關(guān)注
23文章
3274瀏覽量
116882 -
RT-Thread
+關(guān)注
關(guān)注
31文章
1357瀏覽量
41415 -
PWM輸出
+關(guān)注
關(guān)注
1文章
66瀏覽量
5420
發(fā)布評論請先 登錄
MCUX SDK FreeRTOS I2C驅(qū)動程序中沒有超時選項是怎么回事?
LPC55 USB端點rx數(shù)據(jù)無響應是哪里出了問題?
LPC55S69-EVK無法加載安全啟動是怎么回事?
SwdRead等待response_“LPC55s28” 超時了怎么解決?
LPC2294能否輸出兩路不同頻率的PWM?
使用NXP控制器LPC55S69JBD100E,編程都需要SWD和JTAG嗎?
使用ConfigTools for USB創(chuàng)建新項目時遇到的問題求解
LPC55S69JBD100通過SPI連接到WM02C時,是否支持通過bootloader進行OTA更新?
EVK-LPC55S28的負載上限是多少?
在ISP模式下無法在LPC55S69 EVK上升級應用程序怎么解決?
LPC55S28修改音頻數(shù)據(jù)格式后USB Aduio類異常的原因?
ADC高速采樣電路設(shè)計詳解之STM32踩坑

在學習go語言的過程踩過的坑
ESP32C3 I2C no ack無應答怎么解決?
M16連接器12芯采購如何避免踩坑

評論