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.

RTOS/CC1310: RF core stop send packets after few minutes of normal work

Part Number: CC1310

Tool/software: TI-RTOS

Hi TI team, 

1. My project  execute RF_open and transmitt RF packet by pressing button.

2. Next RF core going to Rx for 10 seconds.

3. After receive packet RF core going to Rx for 10 seconds again.

4. If no packet received, executed RF_close.

I can send RF packets as well but after few minutes, when i push button again, the Tx function (RF_postCmd) not send any data. TxCallback function on send event not called. Program hangs.

Place where program hangs:

My code: 

SendAndListen.c
/***** Includes *****/
#include "utlRadio.h"
#include "separator.h"

/***** Includes *****/
#include "smartrf_settings/smartrf_settings.h"
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <xdc/runtime/Error.h>


const char str1[] = "Send me command!";
/***** Variable declarations *****/
static RF_Object rfObject;
static RF_Handle rfHandle;
static RF_Params rfParams;
static RF_CmdHandle rfCmd;
//static RF_EventMask result;

static RF_Object rfObject2;
static RF_Handle rfHandle2;
static RF_Params rfParams2;
static RF_CmdHandle rfCmd2;
static RF_EventMask result2;

/***** Tx parameters *****/
static uint8_t  TxPacket[PAYLOAD_LENGTH];
static uint8_t  WbTxPacket[WALKBY_PAYLOAD_LENTH];
static uint16_t seqNumber;

/***** Rx parameters *****/
#pragma data_alignment = 4
static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                                 MAX_LENGTH,
                                                                 NUM_APPENDED_BYTES)];
        
/* Receive dataQueue for RF Core to fill in data */
static dataQueue_t dataQueue;
static rfc_dataEntryGeneral_t* currentDataEntry;
static uint8_t packetLength;
static uint8_t* packetDataPointer;

static char packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */

char* copyAnswer;

static Semaphore_Handle rxDoneSem;
static Semaphore_Handle txDoneSem;

/***** RF QUEUE *****/
/* Receive entry pointer to keep track of read items */
rfc_dataEntryGeneral_t* readEntry;


static void rxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
static void txCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
/***** Function definitions *****/


void radioCommInit(void)
{
  if( RFQueue_defineQueue(&dataQueue,
                            rxDataEntryBuffer,
                            sizeof(rxDataEntryBuffer),
                            NUM_DATA_ENTRIES,
                            MAX_LENGTH + NUM_APPENDED_BYTES))
    {
        /* Failed to allocate space for all data entries */
        while(1);
    }
    
    /* Create a semaphore for Rx timeout*/
    Semaphore_Params params;
    Error_Block eb;
    /* Init params */
    Semaphore_Params_init(&params);
    Error_init(&eb);
    /* Create semaphore instance */
    rxDoneSem = Semaphore_create(0, &params, &eb);
        
    /* Create a semaphore for Button Rx*/
    Semaphore_Params params2;
    Error_Block eb2;
    /* Init params */
    Semaphore_Params_init(&params2);
    Error_init(&eb2);
    /* Create semaphore instance */
    txDoneSem = Semaphore_create(0, &params, &eb);
}



uint8_t radioStartCommunication(void)
{
    uint8_t i = 0;
     
    Bool semRXpendAns;
    Bool semTXpendAns;
    
    while ((str1[i] != '\0') & (i < PAYLOAD_LENGTH))
    {                
        TxPacket[i] = str1[i];
        i++;
    }
    TxPacket[i] = '\0';
    
    RF_Params_init(&rfParams);
    RF_cmdPropTx.pktLen = (i + 1);//PAYLOAD_LENGTH;
    RF_cmdPropTx.pPkt = TxPacket;
    RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
    RF_cmdPropTx.startTrigger.pastTrig = 1;
    RF_cmdPropTx.startTime = 0;
  
    
    /* Request access to the radio */
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    ///Power_setDependency(PowerCC26XX_PERIPH_RFCORE);
    ///Power_setConstraint(PowerCC26XX_SB_DISALLOW);
    
    /* Set the frequency */
    //rfCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);//
    RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);//
    /*
    result = RF_pendCmd(rfHandle, rfCmd, RF_EventLastCmdDone);
    if (!(result & RF_EventLastCmdDone))
    {
         Error 
        return 0;
    }*/
    
    /* Send packet */
    rfCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, &txCallback, RF_EventLastCmdDone);
    //RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, &txCallback, RF_EventLastCmdDone);
    /*
    result = RF_pendCmd(rfHandle, rfCmd, RF_EventLastCmdDone);
    if (!(result & RF_EventLastCmdDone))
    {
         Error 
        return 0;
    }*/
    
    semTXpendAns = Semaphore_pend(txDoneSem, 500000); //1s
    if(!semTXpendAns)
    {
        //while(1); // now error here
//        RF_flushCmd(rfHandle, rfCmd, 0);
        //RF_cancelCmd(rfHandle, rfCmd, 1);
        RF_close(rfHandle);//RF_yield(rfHandle);//
        //Power_releaseDependency(PowerCC26XX_PERIPH_RFCORE);
        //Power_releaseConstraint(PowerCC26XX_SB_DISALLOW);
//        rfHandle = NULL;
        return 0;// end on error*/
    }
    
    RF_cmdPropRx.pQueue = &dataQueue;           /* Set the Data Entity queue for received data */
    RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;  /* Discard ignored packets from Rx queue */
    RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1;   /* Discard packets with CRC error from Rx queue */
    RF_cmdPropRx.maxPktLen = MAX_LENGTH;        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
    RF_cmdPropRx.startTrigger.triggerType = TRIG_NOW;
    RF_cmdPropRx.startTrigger.pastTrig = 1;
    RF_cmdPropRx.startTime = 0;
    RF_cmdPropRx.endTrigger.triggerType = TRIG_ABSTIME;
    RF_cmdPropRx.endTime = RF_getCurrentTime() + UTL_RADIO_RECEIVE_TIME;   // 10 s of Rx time
        
    /* Enter RX mode to stay some time in RX */
    rfCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &rxCallback, IRQ_RX_ENTRY_DONE);
    //RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &rxCallback, IRQ_RX_ENTRY_DONE);
    /*
    result = RF_pendCmd(rfHandle, rfCmd, RF_EventLastCmdDone);
    if (!(result & RF_EventLastCmdDone))
      {
           Error
          return 0;
      }*/ 
    
    /* Enter in communication sequence until timeout */
    while(1)
    {
       
        semRXpendAns = Semaphore_pend(rxDoneSem, 1000000); //10s
        if(!semRXpendAns)
        {
//            RF_flushCmd(rfHandle, rfCmd, 0);
            //RF_cancelCmd(rfHandle, rfCmd, 1);
            RF_close(rfHandle);//RF_yield(rfHandle);//
            //Power_releaseDependency(PowerCC26XX_PERIPH_RFCORE);
            //Power_releaseConstraint(PowerCC26XX_SB_DISALLOW);
//            rfHandle = NULL;
            return 1; // no packet
        }
              
         copyAnswer = parser(packet);
         i = 0;
         while ((copyAnswer[i] != '\0') & (i < PAYLOAD_LENGTH))
         {                
             TxPacket[i] = copyAnswer[i];
             i++;
         }
         TxPacket[i] = '\0';
         
              
         RF_cmdPropTx.pktLen = (i + 1);//PAYLOAD_LENGTH;
         RF_cmdPropTx.pPkt = TxPacket;
         RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
         RF_cmdPropTx.startTrigger.pastTrig = 1;
         RF_cmdPropTx.startTime = 0;
         
         /* Send packet */
         //rfCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, &txCallback, RF_EventLastCmdDone);
         RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, &txCallback, RF_EventLastCmdDone);
         /*
         result = RF_pendCmd(rfHandle, rfCmd, RF_EventLastCmdDone);
         if (!(result & RF_EventLastCmdDone))
         {
              Error 
             return 0;
         }*/
      
         semTXpendAns = Semaphore_pend(txDoneSem, 100000);//1s
         if(!semTXpendAns)
         {
              /* Error*/
              //return 0; // end on error
              ///RF_close(rfHandle);//RF_yield(rfHandle);//
              ///Power_releaseDependency(PowerCC26XX_PERIPH_RFCORE);
              ///Power_releaseConstraint(PowerCC26XX_SB_DISALLOW);
              return 0;// end on error
         }
         
         
         RF_cmdPropRx.pQueue = &dataQueue;           /* Set the Data Entity queue for received data */
         RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;  /* Discard ignored packets from Rx queue */
         RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1;   /* Discard packets with CRC error from Rx queue */
         RF_cmdPropRx.maxPktLen = MAX_LENGTH;        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
         RF_cmdPropRx.startTrigger.triggerType = TRIG_NOW;
         RF_cmdPropRx.startTrigger.pastTrig = 1;
         RF_cmdPropRx.startTime = 0;
         RF_cmdPropRx.endTrigger.triggerType = TRIG_ABSTIME;
         RF_cmdPropRx.endTime = RF_getCurrentTime() + UTL_RADIO_RECEIVE_TIME;   // 10 s of Rx time
          
         /* Enter RX mode to stay some time in RX */
         //rfCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &rxCallback, IRQ_RX_ENTRY_DONE);
         RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &rxCallback, IRQ_RX_ENTRY_DONE);
         /* 
         result = RF_pendCmd(rfHandle, rfCmd, RF_EventLastCmdDone);
         if (!(result & RF_EventLastCmdDone))
           {
               Error 
               return 0;
           }*/
    }
}

void rxCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
    if (e & RF_EventRxEntryDone)
    {
        /* Get current unhandled data entry */
        currentDataEntry = RFQueue_getDataEntry();

        /* Handle the packet data, located at &currentDataEntry->data:
         * - Length is the first byte with the current configuration
         * - Data starts from the second byte */
        packetLength      = *(uint8_t*)(&currentDataEntry->data);
        packetDataPointer = (uint8_t*)(&currentDataEntry->data + 1);

        /* Copy the payload + the status byte   to the packet variable */
        memcpy(packet, packetDataPointer, (packetLength + 1));
        
        RFQueue_nextEntry();
        
        Semaphore_post(rxDoneSem);
    }
}

void txCallback (RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
    if (e & RF_EventLastCmdDone)
    {  
      Semaphore_post(txDoneSem);
    }
}

My environment:

custom device with cc1310F128 and cc1310 LaunchPad,

tirtos_cc13xx_cc26xx_2_21_00_06,

IAR.

Can you help me to analyze why it happens?

I will appreciate for your reply.