This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/CC2530: SampleSwitch ZStack application power consumption is sleep mode

Part Number: CC2530
Other Parts Discussed in Thread: Z-STACK

Tool/software: TI C/C++ Compiler

Hi. I have problems with power consumption in sleep mode.

I've enabled sleep mode using POWER_SAVING option. The MCU goes into sleep mode just fine BUT:

1. Just after I download the firmware MCU consumes about 0.2mA until I do a reset. Then it finally sleeps with 0.00 mA power consumption.

Why do I need to reset it?

2. After it has joined the network and when I turn off the parent ZStack recognizes the parent lost and with 10sec delay (default value) tries to rejoin the network. AND during that period MCU consumes 27mA. How come?

When I try to debug and stop at a breakpoint it still consumes 27mA even when it is paused. That means that some MCU circuit is on an consumes energy.

The in the state "parent lost" I try to start debugging without download and follow the program step by step. It starts consuming somewhere in osal_run_system() while executing one of the tasksArr[] items.

Any help is appreciated.

  • When you measure power consumption, don’t connect Debugger to CC2530. It will cause inaccuracy. When you turn off parent node, device tries to send beacon requests to find parent to rejoin and it’s normal to see 27mA during this period.
  • 1. I disconnect the Debugger, but still consumes 0.2mA until reset.
    2. I can agree that 27mA is normal but only for a few ms, not for all 10s delay. Continuous 27mA consumption is not suitable for a device powered by 2032 button battery.

    It should be like this: beacon (27mA) , delay 10s (0mA), beacon (27mA). But now it is continuous 27mA consumption. Even if I pause the MCU.
  • 1. If you just disconnect Debugger and don’t do reset to device, it might be in unknown state.
    2. If you use Z-Stack Home 1.2.2a, you can set scan/backoff period in f8wconfig.cfg when device loses its parent to constrain scan period to conserve power.
  • I have this by default

    REJOIN_POLL_RATE=440
    REJOIN_BACKOFF=900000
    REJOIN_SCAN=900000
  • Set REJOIN_SCAN=9000 and it would only scan for 9000 ms.
  • Tried to change REJOIN_SCAN=9=1000 and had no success. Consumes 27mA continuosly.

    Also checked packets using sniffer. Beacon packets are send at 10s interval according to this lines:

    #if ZG_BUILD_ENDDEVICE_TYPE    
        case BDB_COMMISSIONING_PARENT_LOST:
          if(bdbCommissioningModeMsg->bdbCommissioningStatus == BDB_COMMISSIONING_NETWORK_RESTORED)
          {
            //We did recover from losing parent
          }
          else
          {
            //Parent not found, attempt to rejoin again after a fixed delay
            osal_start_timerEx(zclSampleSw_TaskID, SAMPLEAPP_END_DEVICE_REJOIN_EVT, SAMPLEAPP_END_DEVICE_REJOIN_DELAY);
          }
        break;
    #endif 

    SAMPLEAPP_END_DEVICE_REJOIN_DELAY = 10000

    Also MAC refuses to go into sleep in hal_sleep.c

    MAC_PwrOffReq(MAC_PWR_SLEEP_DEEP) returns MAC_DENIED

  • So you use Z-Stack 3.0.1 not Z-Stack Home 1.2.2a. Backoff/Rescan period don’t work in Z-Stack 3.0.1. You should increase SAMPLEAPP_END_DEVICE_REJOIN_DELAY to extend backoff period in your application.
  • Chen, default value SAMPLEAPP_END_DEVICE_REJOIN_DELAY= 10000 is just fine and when the parent is lost Application sends beacon requests every 10s (as seen using packet sniffer) BUT it doesn't consume 27mA only every 10 seconds, it constumes 27mA ALL the time even between beacon requests until it finds its parent. Debugging figured out that ZED can not go into sleep mode because MAC_PwrOffReq(MAC_PWR_DEEP_SLEEP) returns MAC_DENIED and thus Radio is always on.

    I think that's the reason. Why it doesn't let to turn off the radio between beacon requests?

  • When device calls "osal_start_timerEx(zcl_852_TaskID, SAMPLEAPP_END_DEVICE_REJOIN_EVT, SAMPLEAPP_END_DEVICE_REJOIN_DELAY);", it should delay 10 seconds to go to SAMPLEAPP_END_DEVICE_REJOIN_EVT which calls bdb_ZedAttemptRecoverNwk and will turn on radio. I see no reason why you will see the current is 27mA all the time. Do you change anything to SampleSwitch before you test this?
  • SAMPLEAPP_END_DEVICE_REJOIN_EVT calls bdb_ZedAttemptRecoverNwk and turns on the radio but it's not turned off after. I can not see the source code for MAC and can't get the MAC_DENIED reason.

    What I've changed is removed all the calls to UI_Update() because I have no LCD, set Interrupt mode for the keys.
    Also added osal_pwrmgr_device(PWRMGR_BATTERY) into ZDApp_Init.
  • After dig into this more, I find this is a bug in Z-Stack 3.0.1 and you have to put the following red codes to turn off RX in bdb_parentLost

    void bdb_parentLost(void)
    {
    #if ZG_BUILD_ENDDEVICE_TYPE
      if(ZG_DEVICE_ENDDEVICE_TYPE)
      {
        while(pBDBListNwk)
        {
          bdb_nwkDescFree(pBDBListNwk);
        }
        
        nwk_desc_list_free();  
        if(bdbCommissioningProcedureState.bdbCommissioningState != BDB_PARENT_LOST)
        {
          //If parent lost during TCLK exchange, then report TCLK exchange fail
          if(bdbCommissioningProcedureState.bdbCommissioningState == BDB_COMMISSIONING_STATE_TC_LINK_KEY_EXCHANGE)
          {
            bdb_reportCommissioningState(BDB_COMMISSIONING_STATE_TC_LINK_KEY_EXCHANGE, FALSE);
            return;
          }
          bdbCommissioningProcedureState.bdb_ParentLostSavedState = bdbCommissioningProcedureState.bdbCommissioningState;
          
        }
        bdbCommissioningProcedureState.bdbCommissioningState = BDB_PARENT_LOST;
        NLME_OrphanStateSet();
        ZDApp_ChangeState( DEV_NWK_ORPHAN );
        bdb_reportCommissioningState(BDB_PARENT_LOST,FALSE);
     
        // turn receiver off while in orphan state
        byte temp = FALSE;
        ZMacSetReq(ZMacRxOnIdle, &temp);
      }
    #endif
    }