PreviousNext
Sleep
Help > Peripherals > OS > Sleep

Puts the device into sleep (power saving) mode.

 

[sync] [comdown] This command is implemented at the [N] device only. Brown-Out Reset (BOR) is disabled during the execution and enabled on exit at TR-7xD transceivers.

 

The (in)accuracy of the real sleep time depends on the PIC LFINTOSC oscillator that runs the watchdog timer. The oscillator frequency is mainly influenced by the device supply voltage and temperature volatility. See the PIC MCU datasheet for more details.

 

If the interface is used then it is disabled before going to sleep and enabled after the device wakes up.

 

Before going to sleep mode the UART DPA peripheral or DPA interfaces are automatically shut down and later restarted when the device wakes up. Please consider implementing BeforeSleep and AfterSleep events to handle MCU peripherals and pins to obtain the lowest possible device consumption.

 

The command provides two sleep modes. Standard sleep (with RF transceiver chip in a ready state) and Deep sleep (with RF transceiver chip in sleep state). It might seem that the deep sleep one is always the best choice because of lower power consumption but one must consider the time (i.e. power consumption) needed to switch the RF transceiver from the sleep mode into the fully operational mode. Please note Online DPA Menu at TR-7xG is not active during sleep unless wake up is enabled using Control.bit.0.

 

Request

 

NADR

PNUM

PCMD

HWPID

0

1

2

NADR

0x02

0x04

?

Time

Control

 

Time                             Sleep time in 2.097 s or 32.768 ms units. See Control.bit.4. Maximum sleep time is 38 hours 10 minutes 38.95 seconds or 35 minutes 47.48 seconds respectively. 0 specifies endless sleep (except Control.bit1 is set to run the calibration process without performing sleep). In case of endless sleep make sure to set Control.bit.0 or Control.bit.3 to enable wake up.

 

Control             • bit 0    Wake up on PORTB.4 pin negative edge change. See the iqrfSleep IQRF OS function for more information.

                        • bit 1    Runs the calibration process before going to sleep. Calibration takes approximately 16 ms and this time is subtracted from the requested sleep time. Calibration time deviation may produce an absolute sleep time error at short sleep times. But it is worth running the calibration always before a long sleep because the calibration time deviation then accounts for a very small total relative error. The calibration is always run before a first sleep with nonzero Time after the module reset if the calibration was not already initiated by Time=0 and Control.bit.1=1.

                        • bit 2    If set, then when the device wakes up after the sleep period, a green LED once shortly flashes. It is useful for diagnostic purposes.

                        • bit 3    Wake up on PORTB.4 pin positive edge change. See the iqrfSleep IQRF OS function for more information.

                        • bit 4    If set then the unit is 32.768 ms instead of the default 2.097 s (i.e. 2048 × 1.024 ms).

                        • bit 5    iqrfDeepSleep instead of iqrfSleep is used. See IQRF OS documentation for more information.

                        • bit 6-7 Reserved.

 

Response

 

The general response to writing request with STATUS_NO_ERROR Error code.

 

Example 1

 

[N] #1 sleep for 1 minute with green LED flash after waking up:

 

Unit is 32.768 ms => sleep time is 1831 = 0x0727 units:

NADR=0x0001, PNUM=0x02, PCMD=0x04, HWPID=0xFFFF, PData={0x27}
(time lower byte) {0x07}(time higher byte) {0x14}(LED flash + finer unit)

 

Example 2

 

[N] #10 deep sleep for 1 hour with forced calibration and wake up on negative edge change:

 

Unit is 2.097 s => sleep time is 1717 = 0x06B5 units:

NADR=0x000A, PNUM=0x02, PCMD=0x04, HWPID=0xFFFF, PData={0xB5}
(time lower byte) {0x06}(time higher byte) {0x43}(calibration + negative edge + deep sleep)