How to wait in Low Power mode with FreeRTOS and Kinetis MKL16Z

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to wait in Low Power mode with FreeRTOS and Kinetis MKL16Z

跳至解决方案
2,000 次查看
bgraham
Contributor IV

Kinetis MKL16Z

MCUXpresso IDE v10.2.1 [Build 795] [2018-07-25] 

Amazon FreeRTOS

I need to put the MCU into low power mode.

I go the "power_mode_switch" example to work with my custom board.

I am attempting to convert the "power_mode_switch" example to work with FreeRTOS.

Around the calls to APP_PowerModeSwitch(), which calls SMC_PreEnterWaitModes() SMC_SetPowerModeWait(SMC), I used portENTER_CRITICAL() and portEXIT_CRITICAL().

portENTER_CRITICAL(); // stop the RTOS kernel tick timer

APP_PowerModeSwitch(SMC_GetPowerModeState(SMC), kAPP_PowerModeWait);

portEXIT_CRITICAL(); // resume the RTOS kernel tick timer

The FreeRTOS APIs did not keep the MCU in low power mode. I am guessing that an interrupt woke the MCU.

I would like to determine which interrupt woke the MCU. Can MCUXpresso catch the interrupt in the debugger?

The FreeRTOS docs do't cover this problem. Is there a "correct way" to do this in FreeRTOS?

Thanks,

Bruce

0 项奖励
回复
1 解答
1,788 次查看
bgraham
Contributor IV

I think I have working solution.

I added a vApplicationIdleHook() that checks a global variable, and if set, it calls APP_PowerModeSwitch().

When an interrupt like the FreeRTOS system tick wakes MCU, the state of a user button is checked.

If pressed, the task that requested low power mode is sent an event, so that it wakes up.

在原帖中查看解决方案

2 回复数
1,789 次查看
bgraham
Contributor IV

I think I have working solution.

I added a vApplicationIdleHook() that checks a global variable, and if set, it calls APP_PowerModeSwitch().

When an interrupt like the FreeRTOS system tick wakes MCU, the state of a user button is checked.

If pressed, the task that requested low power mode is sent an event, so that it wakes up.

1,788 次查看
danielchen
NXP TechSupport
NXP TechSupport

Thanks for sharing this good idea.

Regards

Daniel

0 项奖励
回复