PreviousNext
iqrfDeepSleep
Help > OS functions > Control > iqrfDeepSleep

Function

 

Setting the TR module in extremely power-saving mode (Deep sleep). This function operates like the iqrfSleep but RF IC is put in the Shutdown (with no internal supply of RF circuitry) instead of the Sleep state.

Purpose

 

Power management in cases when extreme low power consumption is required and TR operation can be disabled for long periods. This function puts TR including all RF IC functionality into the Deep sleep mode.

Syntax

 

void iqrfDeepSleep()

Parameters

 

  –

Return value

 

  –

Output values

 

After waking up, RF IC will be switched to RF Sleep mode and reset to the default state like after power on.

Preconditions

 

     Suitable where very low power consumption is required and long periods of inactivity (approx. 5 minutes or more) occur.

     The user should suspend all resources used by the application before entering the Deep sleep mode to achieve minimal power consumption.

     No MCU pins must be left as digital inputs without a defined input log. level values. See example E14-CONSUMPTION.

     Global interrupt enable (GIE) must not be disabled before iqrfDeepSleep call.

     For wake-up on pin change, the required sequence should be executed. See the Example 2 below. Wake-up on pin change is default disabled.

Remarks

 

     IOCBF flag is cleared automatically by OS.

     Flags IOCBN and IOCBP are unchanged (not cleared) within iqrfDeepSleep.

     Wake-up can be caused by power off/on, watchdog timeout, or on the C5 (for TR modules for SIM mounting, e.g. TR-72G) or Q12 (for SMT mounting, e.g.TR-76G) pin change.

     Wake-up takes about 1 ms.

     Wake-up types can be identified via the –TO and –PD status flags (in the MCU STATUS register).

     If RF functionality is needed after waking up, the setRFready must be called and all RF parameters specified by the user (RF channel, TX power, possibly RF band, and parameters set by the setRFmode and checkRF) which are different from OS default and parameters specified in TR configuration must be restored first. See Example 4.

Side effects

 

  –

See also

 

iqrfSleep, setRFsleep

Example 1

 

       // Minimize consumption (depends on resources used by the user)

  ...               // Disable all TR resources utilized by the user

SWDTEN = 0;         // Disable watchdog

iqrfDeepSleep();    // Put the module into Deep sleep mode

 

 


 

Example 2

 

  // Wake-up on pin change.

GIE = 0;                               // Disable all interrupts

writeToRAM(&IOCBN, IOCBN | 0x10);       // Negative edge enabled.

                                         // Instead of IOCBN.4=1;

                                         // Bit IOCBN.4 cannot be written

                                         // directly due to OS restriction.

IOCBP.4 = 1;                           // Positive edge enabled

IOCIE = 1;                             // Interrupt on change enabled

GIE = 1;                               // Global interrupt enabled

SWDTEN = 0;                            // Watchdog disabled

iqrfDeepSleep();                       // Deep sleep

GIE = 0;

writeToRAM(&IOCBN, IOCBN & 0xEF);  // Negative edge disabled (Instead of IOCBN.4=0)

IOCBP.4 = 0;                           // Positive edge disabled

GIE = 1;                                // Global interrupt enabled

if (buttonPressed)                      // If button is pressed

  { ... }                              //   ...

Example 3

 

iqrfDeepSleep();    // Deep sleep

  ...               // Perform necessary operation (if no RF is needed)

iqrfDeepSleep();    // and go to Deep sleep again as soon as possible

Example 4

 

iqrfDeepSleep();    // Deep sleep

setRFready();       // After waking up: switch RF IC to Ready mode

setRFchannel(40);   //   Restore all RF parameters to be specified by application

setRFpower(5);

setRFmode(0x51);

checkRF(3);

    ...             //   and continue