問題描述
看到部分同學(xué)已經(jīng)開始使用RT-Thread 的PM框架了,當(dāng)然也反映了一些問題。
使用RT-Thread Studio 生成的基于STM32L4 的工程,發(fā)現(xiàn)開啟PM框架后,lptimer不能工作。
最明顯的現(xiàn)象是:進(jìn)入深睡眠后,定時(shí)、延時(shí)事件不可以用。
這里對(duì)這個(gè)問題進(jìn)行分析與提出解決方法
調(diào)試步驟:
一、基于Keil MDK pandora的工程,開啟PM后,LPTimer在深睡眠下工作正常。
二、基于RT-Thread Studio生成的工程,LPTimer確實(shí)不能工作。排除不是硬件問題。
三、對(duì)比工程代碼,LPTimer初始化,完全一致,pm_drv.c pm.c 等完全一致,依舊無法解決問題。
四、工程board.c 對(duì)比,發(fā)現(xiàn)時(shí)鐘配置一致。
以上步驟,未能確認(rèn)問題的所在。
開始懷疑:
一、BSP 驅(qū)動(dòng)包不一致,對(duì)比uart等,發(fā)現(xiàn)確實(shí)有點(diǎn)不同,但不是根本原因(與LPTimer無關(guān))。
二、開啟調(diào)試,發(fā)現(xiàn)LPTimer中斷無法觸發(fā)。
三、查看時(shí)鐘寄存器,發(fā)現(xiàn)問題:LPTimer的時(shí)鐘,未使能。
四、回顧發(fā)現(xiàn),RT-Thread Studio生成的工程,不提供STM32 底層驅(qū)動(dòng)初始化文件。
stm32l4xx_hal_msp.c,這個(gè)是板級(jí)的時(shí)鐘外設(shè)初始化文件,里面有一條開啟LPTimer時(shí)鐘的操作,初始LPTimer時(shí),會(huì)打開LPTimer時(shí)鐘,而工程drv_lptimer.c里,就沒再打開LPTimer時(shí)鐘。
/**
@brief LPTIM MSP Initialization
This function configures the hardware resources used in this example
@param hlptim: LPTIM handle pointer
@retval None
*/
void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef* hlptim)
{
if(hlptim->Instance==LPTIM1)
{
/* USER CODE BEGIN LPTIM1_MspInit 0 */
/* USER CODE END LPTIM1_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_LPTIM1_CLK_ENABLE();
/* USER CODE BEGIN LPTIM1_MspInit 1 */
/* USER CODE END LPTIM1_MspInit 1 */
}
}
解決方法:初始化LPTimer時(shí),不要忘記打開LPTimer時(shí)鐘。
問題得到解決
總結(jié):
基于RT-Thread Studio生成的工程,默認(rèn)【不包含】板級(jí)初始化文件:stm32l4xx_hal_msp.c,這個(gè)用戶要根據(jù)自己的硬件板,自己實(shí)現(xiàn)。
使用時(shí),可以通過:STM32CubeMX 生成,或手動(dòng)根據(jù)自己的外設(shè),處理好外設(shè)、時(shí)鐘、引腳等初始化工作。
-
UART接口
+關(guān)注
關(guān)注
0文章
124瀏覽量
15370 -
RT-Thread
+關(guān)注
關(guān)注
31文章
1306瀏覽量
40436 -
時(shí)鐘寄存器
+關(guān)注
關(guān)注
0文章
2瀏覽量
4971 -
STM32L4
+關(guān)注
關(guān)注
1文章
42瀏覽量
9449 -
stm32cubemx
+關(guān)注
關(guān)注
5文章
284瀏覽量
15052
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
STM32L051上使用RT-Thread (一、新建項(xiàng)目)
![<b class='flag-5'>STM32L</b>051上使用<b class='flag-5'>RT-Thread</b> (一、新建項(xiàng)目)](https://file.elecfans.com//web2/M00/4D/F9/pYYBAGK25yyALNv4AABTfS6Ea9E868.png)
如何使用RT-Thread studio開發(fā)STM32應(yīng)用
使用RT-Thread Studio開發(fā)各個(gè)外設(shè)的驅(qū)動(dòng)的操作方法
STM32L4 RT-Thread Studio-解決lptimer不工作的方法分享
基于RT-Thread Studio的STM32L4開發(fā)板支持包設(shè)計(jì)方案分享
RT-Thread Studio 主要亮點(diǎn)功能
RT-Thread STM32 配置系統(tǒng)時(shí)鐘(使用外部晶振)
![<b class='flag-5'>RT-Thread</b> <b class='flag-5'>STM32</b> 配置系統(tǒng)時(shí)鐘(使用外部晶振)](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
RT-Thread Studio驅(qū)動(dòng)SD卡
![<b class='flag-5'>RT-Thread</b> <b class='flag-5'>Studio</b>驅(qū)動(dòng)SD卡](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
RT-Thread文檔_RT-Thread 潘多拉 STM32L475 上手指南
![<b class='flag-5'>RT-Thread</b>文檔_<b class='flag-5'>RT-Thread</b> 潘多拉 <b class='flag-5'>STM32L</b>475 上手指南](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
基于RT-Thread Studio學(xué)習(xí)
![基于<b class='flag-5'>RT-Thread</b> <b class='flag-5'>Studio</b>學(xué)習(xí)](https://file1.elecfans.com/web2/M00/82/C1/wKgaomRhn_SAM7fdAACQhFt0KEA325.jpg)
RT-Thread移植使用webserver (lwip+httpd)
![<b class='flag-5'>RT-Thread</b>移植使用webserver (lwip+httpd)](https://file1.elecfans.com/web2/M00/A9/99/wKgZomUnepKAb9E9AABCKUIXJyA162.jpg)
RT-Thread使用Soft RTC(軟件模擬RTC)
![<b class='flag-5'>RT-Thread</b>使用Soft RTC(軟件模擬RTC)](https://file1.elecfans.com/web2/M00/A9/A9/wKgZomUnvnyAf3X9AACmcgoHcsQ875.jpg)
評(píng)論