The example works the same as the default lowpower example, except after waking from LLS, the application immediately enters VLPS. It uses the LPTMR to wake after 10 seconds, and returns to RUN mode and restarts the example. Because the transition is immediate from the user perspective, the user will press the switch to enter LLS mode, after 10s the MCU will wake, turn on the blue LED, enter VLPS, wait another 10s, wake, turn off the blue LED, return to RUN mode and resume printing to the terminal. There is no text printed to the terminal between LLS and VLPS to show a quick transition.
This patch covers several files to enable VLPS mode in the twrk21d50m BSP, and modifies the lowpower example. The lowpower example is provided to demonstrate the MQX Low-Power Manager (LPM) driver, and change low-power modes on the K21 board. The BSP in the release provided does not include support for VLPS.
To use this patch, copy the patch directory into the MQX v4.0.2 root directory. The patch will over-write some existing files in the MQX installation. The changes addressed by this patch include the following:
MQX_ENABLE_LOW_POWER macro enabled. Required for LPM driver and lowpower example.
LowPower Example main.c
Modified as described above to add transition into VLPS mode
Added case for VLPS mode for clock mode transition
Added mode to LPM_CPU_OPERATION_MODES for LPM_OPERATION_MODE_VLPS
Added mode LPM_OPERATION_MODE_VLPS to enumeration LPM_OPERATION_MODE
Added settings for mode LPM_OPERATION_MODE_VLPS to the _bsp_sciX_operation_modes arrays for all the UARTs in the BSP
Added mode DOM_VLPS to LPM_PE_OPERATION_MODE_MAP
Disabled SPI0 clock gate when entering stop mode, otherwise stop entry is aborted. Re-enabled clock gate after waking up. If SPI0 peripheral is required in a stop mode, register the SPI driver with the LPM driver to properly configure when LPM changes operation mode to a stop mode. Refer to LPM documentation for details.
Disabled the SysTick interrupt for the 5ms RTOS tick before entering stop mode, and re-enabled after waking up. Without this, the example was entering VLPS mode fine without the debugger, but with the debugger the SysTick interrupt was causing VLPS entry to abort.