Issue Summary:
- When entering VLPS before starting the scheduler, the MCU enters sleep as expected and current drops to ~27µA.
- When entering VLPS inside a FreeRTOS task, POWER_SYS_SetMode() returns STATUS_SUCCESS, but the MCU does not enter VLPS properly, and current remains ~1.5mA.
Case 1: Before Scheduler (Working) :
power_status = POWER_SYS_SetMode(VLPS, POWER_MANAGER_POLICY_AGREEMENT);
if (power_status == STATUS_SUCCESS)
__asm volatile("nop");
- Called before vTaskStartScheduler().
- MCU enters VLPS successfully.
- Current consumption: ~27µA.
- Debugger halts at nop and only proceeds on interrupt (expected behavior).
Case 2: Inside Task (Not Working) :
INT_SYS_DisableIRQ(PORT_IRQn);
INT_SYS_ClearPending(PORT_IRQn);
peripheral_deinit();
INT_SYS_EnableIRQ(PORT_IRQn);
vPortEnterCritical();
sts = POWER_SYS_SetMode(VLPS, POWER_MANAGER_POLICY_AGREEMENT);
vPortExitCritical();
- Called inside a FreeRTOS task after suspending other tasks and deinitializing peripherals.
- POWER_SYS_SetMode() returns STATUS_SUCCESS .
- MCU does not appear to enter VLPS.
- Current consumption: ~1.5mA (higher than expected).
- With debugger attached, code proceeds beyond POWER_SYS_SetMode() without interrupt (unexpected).
Case 3: Inside Task with SysTick Disabled (Partially Working) :
INT_SYS_DisableIRQ(PORT_IRQn);
INT_SYS_ClearPending(PORT_IRQn);
peripheral_deinit();
INT_SYS_EnableIRQ(PORT_IRQn);
vPortEnterCritical();
S32_SysTick->CSR &= ~(SYSTICK_CSR_ENABLE_MASK); // Disable SysTick
sts = POWER_SYS_SetMode(VLPS, POWER_MANAGER_POLICY_AGREEMENT);
S32_SysTick->CSR |= SYSTICK_CSR_ENABLE_MASK; // Re-enable SysTick
vPortExitCritical();
- Disabling SysTick timer before VLPS seems to help.
- Debugger halts until interrupt (expected).
- However, current consumption is still ~1.5mA (not the expected ~27µA).
My Setup:
- MCU: S32K118
- SDK : (s32sdk_s32k1xx_rtm_402)
- RTOS: FreeRTOS(1.0.0)
- Peripherals are deinitialized and unnecessary tasks are suspended before entering VLPS.
- Behavior is same with or without debugger.
Questions:
- Why does POWER_SYS_SetMode() not put the MCU into VLPS properly when called from a FreeRTOS task?
- Are there additional steps required for VLPS under FreeRTOS (e.g., disabling SysTick or configuring interrupt priorities)?
- How can I achieve the same low current (~27µA) when entering VLPS from within a task?