The Thread Low Power End Device is preconfigured to have both the MCU in low power state and the radio turned off most of the time to preserve battery life. The device wakes up periodically and polls its parent router for data addressed to it or optionally initiates sending data to the network by means of the parent router.
The low-power module (LPM) from the connectivity framework simplifies the process of putting a Kinetis-based wireless network node into the low-power or sleep modes. For the MKW41Z there are six low-power modes available.
By default, the Thread Low Power End Device uses Deep sleep mode 3, where:
- MCU in LLS3 mode.
- Link layers remain idle.
- RAM is retained.
The wake-up sources are:
- GPIO (push buttons).
- DCDC power switch (In buck mode).
- LPTMR with the 32kHz oscillator as clock source.
The LPTMR timer is also used to measure the time that the MCU spends in deep sleep to synchronize low-power timers at wake-up. See the Connectivity Framework Reference Manual and PWR_Configuration.h for more information about the sleep deep modes.
To change the polling time on deep sleep mode 3, we need to understand two macros:
1. The cPWR_DeepSleepDurationMs macro in \framework\LowPower\Interface\MKW41Z\PWR_Configuration.h.
#define cPWR_DeepSleepDurationMs 3000
This macro determines how long the MCU will go to low power mode (deep sleep). The maximum value is 65535000 ms (18.2 h).
2. The THR_SED_POLLING_INTERVAL_MS macro in \middleware\wireless\nwk_ip_1.2.0\examples\<application>\config\config.h.
/*! The default value for sleepy end device (SED) polling interval */
#define THR_SED_POLLING_INTERVAL_MS 3000 /* Milliseconds */
This macro determines how often the Low Power End Device will send a poll message to its parent.
NOTE: This value does not determine how often the MCU wakes up.
The polling interval should be a multiple of the Deep sleep duration value, otherwise the poll will be sent at the next deep sleep time out.
As an example, let's say we configure the polling interval to 4000ms and the deep sleep duration to 3000ms. The MCU will wake up every 3000ms but the poll message will be sent every 2 deep sleep timeouts = 6000ms because the timers are synchronized when the MCU wakes up. The following figure shows the behavior of this example.
It is recommended that the polling interval is the same as the deep sleep duration, so the MCU doesn't wake up unnecessarily. The following figure shows this behavior.
Another macro to keep in mind is THR_SED_TIMEOUT_PERIOD_SEC in app_thread_config.h.
#define THR_SED_TIMEOUT_PERIOD_SEC ((4*THR_SED_POLLING_INTERVAL_MS)/1000 + 3)
This value is the timeout period used by the parent to consider a sleepy end device (SED) disconnected. By default, this value is configured to be 4 times the polling interval + 3s. It is recommended to leave this macro as it is. This value is sent to the parent node during the commissioning.