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.

CC2530: TIMAC CC530 Sleep Timer

Part Number: CC2530
Other Parts Discussed in Thread: TIMAC,

Hi Team,

I use the protocol stack as TIMAC, adopt the beacon mode, and synchronize all devices. The scenario I need is that after the beacon frame carries device information, the terminal device with matching device information will send data to the coordinator, and other terminal devices will be sleeping. At the beginning, I used the halSleep() function of the protocol stack, and enabled Power saving, but I found that the terminal device did not go to sleep. Later, I adopted the method of sleep timer, but the interrupt function could not be triggered. I found that the interrupt function of the sleep timer had been written by the protocol stack, and the interrupt function of the protocol stack also cleared the interrupt flag and sleep mode. Thus, I though the interrupt function of the protocol stack could be used. Through experiments, I found that this method could only make the coordinator enter the specified sleeping status once. Sleep couldn't be triggered after a subsequent beacon frame arrived.

Kind regards,

Katherine

  • Hi Katherine,

    I assume that the msa_cc2530 examples from TIMAC 1.5.2 are being evaluated.  Please note that MSA_PWR_MGMT_ENABLED is used by default for devices and enabled on coordinators if MSA_MAC_BEACON_ORDER is not equal to 15.  MSA_PWR_MGMT_ENABLED itself must be set to TRUE.  Both of these definitions are established in the msa.h file after which no further power modifications should be required.  Can you please expand on what changes have been made to the default projects and how it is being confirmed whether the devices are entering a low-power state?

    Regards,
    Ryan

  • Hi Ryan,

    Bo is set to 10, S0 is set to 9, and the beacon frame interval is about 15 seconds. Each terminal device is numbered. The beacon frame sent by the coordinator carries the device number. When I detected that the device number carried by the beacon frame was different from its own device number, the sleep event was triggered, and the device went to sleep immediately. I used the sleep timer of CC2530.

    /*sleep event*/

    //I set the system's sleep mode.

    //It entered the sleep mode and would be awoken by interrupts.

    //Active/idle mode. The system would be awoken by interrupts.

    The settings above are about the sleep timer, and the following one is the interrupt function written by the protocol stack, to which I made no modifications.

    When the device entered PM2 mode, only the sleep timer worked, and the serial port couldn't work normally. I only set the sleep event. Before the event was triggered, the serial port could receive and reply. After the sleep event was triggered, the serial port couldn't receive, so I thought the device entered PM2 mode. At the same time, through debugging, I found that the interrupt of the sleep timer was triggered.

    Regards,

    Katherine

  • It appears that the inquiries have migrated towards a serial port issue.  The serial port will not operate in PM2 since the high-frequency oscillator which clocks this peripheral is disabled.  The device will need to exit sleep before servicing the serial port.

    Regards,
    Ryan

  • Hi Ryan,

              case 0xA2:
                if(Beacon_Receive[4] != MSA_DEVICE_NUMBER)
                {
                  HalUARTWrite(HAL_UART_PORT_0 , "The Enddevice Sleep" , sizeof("The Enddevice Sleep"));
                  osal_set_event(MSA_TaskId, DEVICE_SLEEP_EVENT);
                }
    It can be seen that if the information carried by the beacon frame is different from the device itself, the device will start to sleep. But from the results, the device can only go to sleep after the first beacon frame is sent, and then wake up at regular intervals. When the coordinator sends the beacon frame for another time, the device will not go to sleep.

    Regards,

    Katherine

  • Hi Katherine,

    I do not understand the context of the code provided.  Please clarify exactly where this code is being implemented.  Does this issue concern the coordinator (FFD) or devices (RFD)?  Can it be confirmed whether the coordinator or devices are able to enter sleep mode regularly using the default msa_2530 example and MSA_PWR_MGMT_ENABLED set to TRUE?  Please validate with power consumption measurement screenshots.  Also, further debug the device to determine what code is being processed while the device does not sleep.

    Regards,
    Ryan

  • Hi Ryan,

    After the device (RFD) received the beacon frame, namely MAC_MLME_BEACON_NOTIFY_IND in the system event, it evaluated the load of the beacon frame and then slept.

      /* sleep event */
      if(events & DEVICE_SLEEP_EVENT)
      {
        setSleepPeriod(10);//set sleep time
        setPowerMode(2);//device sleep
      }
      /* the function of setting sleep time */
      static void setSleepPeriod(uint8 nS)
    {
        uint32 sleepTimer = 0;
        sleepTimer  = (uint32)ST0;
        sleepTimer |= (uint32)ST1 << 8;
        sleepTimer |= (uint32)ST2 << 16;
    
        sleepTimer += (uint32)nS * 32768;
    
        ST2 = (uint8)(sleepTimer >> 16);
        ST1 = (uint8)(sleepTimer >> 8);
        ST0 = (uint8)(sleepTimer);
    }
    
      /* set the sleep mode */
      static void setPowerMode(uint8 mode)
    {
         if(mode > 0 && mode < 4)
         {
            SLEEPCMD |= mode;    //Set the system's sleep mode
            PCON = 0x01;         //Entered the sleep mode and would be awaken by the interrupt
         }
         else
         {
             PCON = 0x00;        //Active/idle mode. Awook the system with the interrupt
         }
    }

    I used the interrupt function regarding the sleep timer in the protocol stack.

    HAL_ISR_FUNCTION(halSleepTimerIsr, ST_VECTOR)
    {
    
      HAL_ENTER_ISR();
      HAL_SLEEP_TIMER_CLEAR_INT();
    
    #ifdef HAL_SLEEP_DEBUG_POWER_MODE
      halSleepInt = TRUE;
    #endif
    
      CLEAR_SLEEP_MODE();
      HAL_EXIT_ISR();
    
    
    }

    The msa_2530 example is used and MSA_PWR_MGMT_ENABLED has been set as TRUE. And I don't have any equipment that can measure power consumption measurement for the time being.

    When the device is not sleeping, it is printing on the serial port, that is, printing after receiving the beacon frame.

    Regards,

    Katherine

  • Hi Katherine,

    Can you confirm that both the FFD (beacon transmitter) and RFD (beacon receiver) are using the values for BO and SO?

    Is the FFD able to receive messages from RFD?

    Thanks,
    Toby

  • Hi,

    I can confirm that both RFD and FFD are using the values ​​of BO and SO to send the data received by the RFD serial port to FFD, and FFD can successfully receive and print it out on the serial port.

    Regards,

    Katherine

  • Hi,

    Now I have found the cause of my problem. After the first sleep, the terminal would not receive the second beacon frame, that is, it would not enter the MAC_MLME_BEACON_NOTIFY_IND in the system event. Thus, instead of entering the second sleep, bit executed other untriggered event.

    Kind regards,

    Katherine

  • Hi,

    Now after the RFD exits sleep, where should I make modifications if it cannot receive the beacon frame? Is it in the callback function of the terminal receiving the message?

    Regards,

    Katherine

  • Hi Katherine,

    Thank you for providing an update to your issue.  You could utilize a timer to detect missed beacon frames.  You should add event IDs to be serviced from the event processor to avoid spending too many cycles from within a hardware interrupt context.

    Regards,
    Ryan