Ember Enddevice Power/sleep mechanism

Source: Internet
Author: User
Tags sleep function

Reference transfer from https://www.sekorm.com/news/9339.html

The efr32mg itself has five low-power modes of operation:

EM0: Active state, at which time the CPU activity, peripheral activity, the highest power consumption, the lowest 65ua/mhz.

EM1: Idle state, at this time, CPU stop, peripheral activity, power consumption and the peripherals used, generally can be considered at this time 3ma~5ma power consumption.

EM2: DeepSleep state, at this time, part of the Lfxo or Lfrco, Ulfrco low-speed clock peripheral activity, RAM storage, nominal current at this time is 1.5uA.

EM3: Stop state, at this time the high-speed clock hfxo or Hfrco, Lfrco, LFXO will be turned off, Ulfrco activity, the use of Ulfrco peripherals can still run, optional RAM storage, such as Rtcc/wdog/crotimer.

em4h: hibernation state, starting from this state, the storage of RAM will be limited and up to 128 bytes of RAM data is saved through the Ram area of the RTCC peripheral. Therefore, this state wakeup will reset the system. In this state, you can use Cryotimer and the specified Gpio to wake up.

em4s: off state, in this state, all peripherals are basically switched off, all the ram is lost, can be woken up by Ulfrco-based Cryotimer or a specified Gpio, and the system resets after wake-up.

In the Emberznet protocol stack, the EM0, EM1, EM2, and em4h modes are used, and the main dormant work in idle-sleep-soc.c line21 of void Emberafpluginidlesleeptickcallback ( void) function.

The process is as follows:

1. To turn off global interrupts, ensure that sleep processing is interrupted and tampered with.

2. Is it possible to enter hibernation, judging the condition is

1) Whether the developer specifies that the awake state is not dormant.

2) Whether the developer specifies not to hibernate when not joining the network.

3) Whether there is a serial port is sending data, at this time can not hibernate.

4) is enough to have a task waiting to be executed, if there is no hibernation, to process the ready task, including user tasks and protocol stack tasks.

If these all pass, then at least you can enter the idle state.

3. If the decision can sleep, for sleepy End device, because radio in hibernation is not open, it is also necessary to further determine whether you can turn off radio, enter the rest mode, judging by whether the query has a high-priority protocol stack task needs to run, The current definition is 4 tasks with a high priority:

1) Radio data Sending task.

2) Radio Data Reception task.

3) Radio peripherals are in use.

4) rf4ce network busy. (A ZigBee remote Control standard protocol)

If any of the above tasks are executing, the system still cannot hibernate.

4. If there is no stack high-priority task in the execution, the system can sleep at ease, first, the need to calculate the time of sleep, sleep time refers to the time from now to the execution of the next event, in [1/1024] seconds, if the calculation can sleep less than 5ms (system default, can be modified) , that also can not enter the DeepSleep state, because into the deepsleep need to close the peripheral, the protocol stack, wake up need to open peripherals, open the protocol stack, these actions will take a few milliseconds to complete, power accounting down into DeepSleep no meaning. In this case, the system will default into a EM1 idle state. If the sleep time is greater than 5ms, the system begins to enter the DeepSleep. When you wake up again, you will be given how long you have been sleeping for debugging purposes.

Note that no matter the system enters the idle or DeepSleep state, all interrupts are reopened before sleep and used as wake-up source, but the operation is encapsulated in the sleep function is not open source, we do not go to manually add.

Next, if we want to use the em4--system's lowest power mode, then we need to do a bit more complex processing.

First, the EM4 wake will be reset, so before entering EM4, to save the parent Info, that is, the parents of the IEEE address and Nodeid, this do not let us do, the system will be automatically added, in determining whether to enter the EM4, the default will be bool Emberparenttokenset (void) Determines whether the operation has completed and cannot enter EM4 if it is not completed. At the same time, it is necessary for the user to return true in the bool Emberafoktogotoem4callback () function before the system can confirm the entry to EM4, and the system will use RTCC to save 16 bytes of data related to the current network traffic encryption before entering EM4. It includes the framecounter of sending data, the framecounter of receiving data, the linkkeyframecounter of sending data, the linkkeyframecounter of receiving data, and automatically reading when Wake up again. After wake-up from EM4, the system will get the reason for the reset, if it is caused by EM4, it will go into the void Emberafcamebackfromem4callback () function, the EM4 parameter readback work.

However, the use of EM4 still requires a lot of work, because if the direct use of EM4, will cause the periodic task events can not be executed, each entry EM4 will lose the previous task information, such as sleepy End device short poll, Long poll event does not execute properly. It is advisable to do this work before entering EM4, and bool Emberafoktogotoem4callback () is a very suitable interface.

EM4 Current entry mechanism in the protocol stack some areas need to be modified, in addition to the ISC file selected EM4 plugin outside. You need to add ember_af_plugin_em4, EMBER_ENABLE_EM4 definitions, and duplicate definition problems to get rid of the same definitions in $prj_name.h. Duration = Cryotimerinit.period (closestpoweroftwo) in micro.c file line380 void Setem4wakeuptimer (uint32_t duration) Calculation period is incorrect, please refer to manual configuration. Also, in Child.h file line 334

#define EMBEROKTOGOTOLOWPOWERMODE () (! Embercurrentstacktasks () && emberparenttokenset ())

Revision changed to

#define EMBEROKTOGOTOLOWPOWERMODE () (! Embercurrentstacktasks () &&! Emberparenttokenset ())

Ember Enddevice Power/sleep mechanism

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.