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: WOR-RX

Part Number: CC1310

Tool/software: TI-RTOS

In the example of WOR-RX,I want to send back the received data.It works, but there was a problem:There is a long interval between sending and receiving data!

Based on the results of my tests, I think the module will send data after the next wake-up.What should I do while maintaining low power consumption?

/* Called for every received packet and command done */
void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
    /* If we've received a new packet and it's available to read out */
    if (e & RF_EventRxEntryDone)
    {
        do
        {
            /* Toggle LED on RX */
            PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1));

            /* 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);
            
            /* This code block is added to avoid a compiler warning.
            * Normally, an application will reference these variables for
            * useful data. */
            dummy = packetLength + packetDataPointer[0];
            
            txPacket[0] = packetLength;
            memcpy(&txPacket[1],packetDataPointer,packetLength);
            
            Display_printf(uartDisplayHandle, 0, 0, "RX");
            
            Event_post(radioOperationEventHandle, RADIO_EVENT_VALID_PACKET_RECEIVED);
            
        } while(RFQueue_nextEntry() == DATA_ENTRY_FINISHED);
    }
}

static void txTaskFunction(UArg arg0, UArg arg1)
{
  /* Initialize TX_ADV command from TX command */
    initializeTxAdvCmdFromTxCmd(&RF_cmdPropTxAdv, &RF_cmdPropTx);

    /* Set application specific fields */
    RF_cmdPropTxAdv.pktLen = 31; /* +1 for length byte */
    RF_cmdPropTxAdv.pPkt = txPacket;
    RF_cmdPropTxAdv.preTrigger.triggerType = TRIG_NOW;
    //RF_cmdPropTxAdv.startTime = 0;   
    while(1)
    {   
        uint32_t events = Event_pend(radioOperationEventHandle, 0, RADIO_EVENT_ALL, BIOS_WAIT_FOREVER);
        
        if(events & RADIO_EVENT_VALID_PACKET_RECEIVED)
        {                   
          RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv,RF_PriorityNormal, NULL, 0);
          Display_printf(uartDisplayHandle, 0, 0, "TX");
        }       
    }
}

  • Hi,

    How do your WOR implementation function, is it exactly like in the example or have you modified it in any way?
    Would it be possible to share your complete code?
  • Sorry, the code won't be displayed until tomorrow. What information do you want to know? Do you think it's reasonable for me to do this? Would it not be able to send data immediately because it was dormant?
  • The interesting part here is to see how you combine WOR with the TX part, let's look on this again when you have the code available. As for feasibility, I think what you want to achieve is possible.
  • /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    
    /* XDCtools Header files */
    #include <xdc/std.h>
    #include <xdc/runtime/Assert.h>
    
    /* BIOS Header files */
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* TI-RTOS Header files */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/pin/PINCC26XX.h>
    
    /* Board Header files */
    #include "Board.h"
    
    /* Application Header files */ 
    #include "RFQueue.h"
    #include "smartrf_settings/smartrf_settings.h"
    
    #include <ti/devices/DeviceFamily.h>
    #include DeviceFamily_constructPath(driverlib/rf_prop_mailbox.h)
    
    /***** Defines *****/
    /* Wake-on-Radio wakeups per second */
    #define WOR_WAKEUPS_PER_SECOND 2
    
    /* Wake-on-Radio mode. Can be:
    * - RSSI only
    * - PQT, preamble detection
    * - Both, first RSSI and then PQT if RSSI */
    #define WOR_MODE CarrierSenseMode_RSSIandPQT
    
    /* Threshold for RSSI based Carrier Sense in dBm */
    #define WOR_RSSI_THRESHOLD ((int8_t)(-111))
    
    /* Macro used to set actual wakeup interval */
    #define WOR_WAKE_UP_MARGIN_S 0.005f
    #define WOR_WAKE_UP_INTERVAL_RAT_TICKS(x) \
    ((uint32_t)(4000000*(1.0f/(x) - (WOR_WAKE_UP_MARGIN_S))))
    
    /* TI-RTOS Task configuration */
    #define RX_TASK_STACK_SIZE 1024
    #define RX_TASK_PRIORITY 2
    
    /* TX Configuration */
    #define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH 31 /* Max length byte the radio will accept */
    #define NUM_DATA_ENTRIES 2 /* NOTE: Only two data entries supported at the moment */
    #define NUM_APPENDED_BYTES 1 /* Length byte included in the stored packet */
    
    /***** Type declarations *****/
    /* General wake-on-radio RX statistics */
    struct WorStatistics {
    uint32_t doneIdle;
    uint32_t doneIdleTimeout;
    uint32_t doneRxTimeout;
    uint32_t doneOk;
    };
    
    /* Modes of carrier sense possible */
    enum CarrierSenseMode {
    CarrierSenseMode_RSSI,
    CarrierSenseMode_PQT,
    CarrierSenseMode_RSSIandPQT,
    };
    
    
    /***** Variable declarations *****/
    /* TX task objects and task stack */
    static Task_Params rxTaskParams;
    static Task_Struct rxTask;
    static uint8_t rxTaskStack[RX_TASK_STACK_SIZE];
    
    /* RF driver object and handle */
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    /* Pin driver object and handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    /* General wake-on-radio sniff status statistics and statistics from the RF Core about received packets */
    static volatile struct WorStatistics worStatistics;
    static rfc_propRxOutput_t rxStatistics;
    
    /*
    * Application LED pin configuration table:
    * - All LEDs board LEDs are off.
    */
    static PIN_Config pinTable[] =
    {
    Board_PIN_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    Board_PIN_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    #if defined __CC1352R1_LAUNCHXL_BOARD_H__
    Board_DIO30_RFSW | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    #endif 
    PIN_TERMINATE
    };
    
    /* Buffer which contains all Data Entries for receiving data.
    * Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)];
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment = 4
    static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
    static uint8_t rxDataEntryBuffer [RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH, NUM_APPENDED_BYTES)] __attribute__ ((aligned (4)));
    #else
    #error This compiler is not supported.
    #endif
    
    /* RX Data Queue and Data Entry pointer to read out received packets */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    
    /* Received packet's length and pointer to the payload */
    static uint8_t packetLength;
    static uint8_t* packetDataPointer;
    
    static volatile uint8_t dummy;
    
    /* Sniff command for doing combined Carrier Sense and RX*/
    static rfc_CMD_PROP_RX_SNIFF_t RF_cmdPropRxSniff;
    
    /***** Prototypes *****/
    static void rxTaskFunction(UArg arg0, UArg arg1);
    static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
    static void initializeSniffCmdFromRxCmd(rfc_CMD_PROP_RX_SNIFF_t* rxSniffCmd, rfc_CMD_PROP_RX_t* rxCmd);
    static void configureSniffCmd(rfc_CMD_PROP_RX_SNIFF_t* rxSniffCmd, enum CarrierSenseMode mode, uint32_t datarate, uint8_t wakeupPerSecond);
    static uint32_t calculateSymbolRate(uint8_t prescaler, uint32_t rateWord);
    
    /*-------------My Add-----------------*/
    
    #include <ti/sysbios/knl/Event.h>
    #include <ti/display/Display.h>
    
    /*发送任务配置*/
    #define TX_TASK_STACK_SIZE 1024
    #define TX_TASK_PRIORITY 3
    
    static Task_Params txTaskParams;
    static Task_Struct txTask;
    static uint8_t txTaskStack[TX_TASK_STACK_SIZE];
    
    #define RADIO_EVENT_ALL 0xFFFFFFFF
    #define RADIO_EVENT_VALID_PACKET_RECEIVED (uint32_t)(1 << 0)
    #define RADIO_EVENT_INVALID_PACKET_RECEIVED (uint32_t)(1 << 1)
    
    static Event_Struct radioOperationEvent; 
    static Event_Handle radioOperationEventHandle;
    
    static Display_Handle uartDisplayHandle;
    static void txTaskFunction(UArg arg0, UArg arg1);
    static void initializeTxAdvCmdFromTxCmd(rfc_CMD_PROP_TX_ADV_t* RF_cmdPropTxAdv, rfc_CMD_PROP_TX_t* RF_cmdPropTx);
    static RF_Params rfParams;
    static rfc_CMD_PROP_TX_ADV_t RF_cmdPropTxAdv;
    static uint8_t txPacket[31];
    
    
    /*-------------My Add-----------------*/
    
    /***** Function definitions *****/
    
    /*-------------My Add-----------------*/
    void txTaskInit()
    {
    Task_Params_init(&txTaskParams);
    txTaskParams.stackSize = TX_TASK_STACK_SIZE;
    txTaskParams.priority = TX_TASK_PRIORITY;
    txTaskParams.stack = &txTaskStack;
    
    Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL);
    }
    /*-------------My Add-----------------*/
    
    /* RX task initialization function. Runs once from main() */
    void rxTaskInit()
    {
    Task_Params_init(&rxTaskParams);
    rxTaskParams.stackSize = RX_TASK_STACK_SIZE;
    rxTaskParams.priority = RX_TASK_PRIORITY;
    rxTaskParams.stack = &rxTaskStack;
    
    Task_construct(&rxTask, rxTaskFunction, &rxTaskParams, NULL);
    }
    
    /* RX task function. Executed in Task context by TI-RTOS when the scheduler starts. */
    static void rxTaskFunction(UArg arg0, UArg arg1)
    { 
    /* Route out LNA active pin to LED1 */
    PINCC26XX_setMux(ledPinHandle, Board_PIN_LED0, PINCC26XX_MUX_RFC_GPO0);
    
    /* Create queue and data entries */
    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);
    }
    
    /* Copy all RX options from the SmartRF Studio exported RX command to the RX Sniff command */
    initializeSniffCmdFromRxCmd(&RF_cmdPropRxSniff, &RF_cmdPropRx);
    
    /* Configure RX part of RX_SNIFF command */
    RF_cmdPropRxSniff.pQueue = &dataQueue;
    RF_cmdPropRxSniff.pOutput = (uint8_t*)&rxStatistics;
    RF_cmdPropRxSniff.maxPktLen = MAX_LENGTH;
    
    /* Discard ignored packets and CRC errors from Rx queue */
    RF_cmdPropRxSniff.rxConf.bAutoFlushIgnored = 1;
    RF_cmdPropRxSniff.rxConf.bAutoFlushCrcErr = 1;
    
    /* Calculate datarate from prescaler and rate word */
    uint32_t datarate = calculateSymbolRate(RF_cmdPropRadioDivSetup.symbolRate.preScale,
    RF_cmdPropRadioDivSetup.symbolRate.rateWord);
    
    /* Configure Sniff-mode part of the RX_SNIFF command */
    configureSniffCmd(&RF_cmdPropRxSniff, WOR_MODE, datarate, WOR_WAKEUPS_PER_SECOND);
    
    /* Request access to the radio */
    rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
    /* Set frequency */
    RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, &callback, 0);
    
    /* Save the current radio time */
    RF_cmdPropRxSniff.startTime = RF_getCurrentTime();
    
    /* Enter main loop */
    while(1)
    {
    /* Set next wakeup time in the future */
    RF_cmdPropRxSniff.startTime += WOR_WAKE_UP_INTERVAL_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);
    
    /* Schedule RX */
    RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxSniff, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
    
    /* Log RX_SNIFF status */
    switch(RF_cmdPropRxSniff.status) {
    case PROP_DONE_IDLE:
    /* Idle based on RSSI */
    worStatistics.doneIdle++;
    break;
    case PROP_DONE_IDLETIMEOUT:
    /* Idle based on PQT */
    worStatistics.doneIdleTimeout++;
    break;
    case PROP_DONE_RXTIMEOUT:
    /* Got valid preamble on the air, but did not find sync word */
    worStatistics.doneRxTimeout++;
    break;
    case PROP_DONE_OK:
    /* Received packet */
    worStatistics.doneOk++;
    break;
    default:
    /* Unhandled status */
    break;
    };
    }
    }
    
    /*-------------My Add-----------------*/
    static void txTaskFunction(UArg arg0, UArg arg1)
    {
    /* Initialize TX_ADV command from TX command */
    initializeTxAdvCmdFromTxCmd(&RF_cmdPropTxAdv, &RF_cmdPropTx);
    
    /* Set application specific fields */
    RF_cmdPropTxAdv.pktLen = 31; /* +1 for length byte */
    RF_cmdPropTxAdv.pPkt = txPacket;
    RF_cmdPropTxAdv.preTrigger.triggerType = TRIG_NOW;
    RF_cmdPropTxAdv.startTime = 0; 
    while(1)
    { 
    uint32_t events = Event_pend(radioOperationEventHandle, 0, RADIO_EVENT_ALL, BIOS_WAIT_FOREVER);
    
    if(events & RADIO_EVENT_VALID_PACKET_RECEIVED)
    { 
    Display_printf(uartDisplayHandle, 0, 0, "RX");
    RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv,RF_PriorityNormal, NULL, 0);
    Display_printf(uartDisplayHandle, 1, 0, "TX");
    } 
    }
    }
    /*-------------My Add-----------------*/
    
    /* Calculates datarate from prescaler and rate word */
    static uint32_t calculateSymbolRate(uint8_t prescaler, uint32_t rateWord)
    {
    /* Calculate datarate according to TRM Section 23.7.5.2:
    * f_baudrate = (R * f_ref)/(p * 2^20)
    * - R = rateWord
    * - f_ref = 24Mhz
    * - p = prescaler */
    uint64_t numerator = rateWord*24000000ULL;
    uint64_t denominator = prescaler*1048576ULL;
    uint32_t result = (uint32_t)(numerator/denominator);
    return result;
    }
    
    /* Copy the basic RX configuration from CMD_PROP_RX to CMD_PROP_RX_SNIFF command. */
    static void initializeTxAdvCmdFromTxCmd(rfc_CMD_PROP_TX_ADV_t* RF_cmdPropTxAdv, rfc_CMD_PROP_TX_t* RF_cmdPropTx)
    {
    #define RADIO_OP_HEADER_SIZE 14
    
    /* Copy general radio operation header from TX commmand to TX_ADV */
    memcpy(RF_cmdPropTxAdv, RF_cmdPropTx, RADIO_OP_HEADER_SIZE);
    
    /* Set command to CMD_PROP_TX_ADV */
    RF_cmdPropTxAdv->commandNo = CMD_PROP_TX_ADV;
    
    /* Copy over relevant parameters */
    RF_cmdPropTxAdv->pktConf.bFsOff = RF_cmdPropTx->pktConf.bFsOff;
    RF_cmdPropTxAdv->pktConf.bUseCrc = RF_cmdPropTx->pktConf.bUseCrc;
    RF_cmdPropTxAdv->syncWord = RF_cmdPropTx->syncWord;
    }
    
    /* Copies all RX options from the SmartRF Studio exported RX command to the RX Sniff command */
    static void initializeSniffCmdFromRxCmd(rfc_CMD_PROP_RX_SNIFF_t* rxSniffCmd, rfc_CMD_PROP_RX_t* rxCmd)
    {
    
    /* Copy RX configuration from RX command */
    memcpy(rxSniffCmd, rxCmd, sizeof(rfc_CMD_PROP_RX_t));
    
    /* Change to RX_SNIFF command from RX command */
    rxSniffCmd->commandNo = CMD_PROP_RX_SNIFF;
    }
    
    /* Configures Sniff-mode part of the RX_SNIFF command based on mode, datarate and wakeup interval */
    static void configureSniffCmd(rfc_CMD_PROP_RX_SNIFF_t* rxSniffCmd, enum CarrierSenseMode mode, uint32_t datarate, uint8_t wakeupPerSecond)
    {
    /* Enable or disable RSSI */
    if ((mode == CarrierSenseMode_RSSI) || (mode == CarrierSenseMode_RSSIandPQT)) {
    rxSniffCmd->csConf.bEnaRssi = 1;
    } else {
    rxSniffCmd->csConf.bEnaRssi = 0;
    }
    
    /* Enable or disable PQT */
    if ((mode == CarrierSenseMode_PQT) || (mode == CarrierSenseMode_RSSIandPQT)) {
    rxSniffCmd->csConf.bEnaCorr = 1;
    rxSniffCmd->csEndTrigger.triggerType = TRIG_REL_START;
    } else {
    rxSniffCmd->csConf.bEnaCorr = 0;
    rxSniffCmd->csEndTrigger.triggerType = TRIG_NEVER;
    }
    
    /* General Carrier Sense configuration */
    rxSniffCmd->csConf.operation = 1; /* Report Idle if RSSI reports Idle to quickly exit if not above
    RSSI threshold */
    rxSniffCmd->csConf.busyOp = 0; /* End carrier sense on channel Busy (the receiver will continue when
    carrier sense ends, but it will then not end if channel goes Idle) */
    rxSniffCmd->csConf.idleOp = 1; /* End on channel Idle */
    rxSniffCmd->csConf.timeoutRes = 1; /* If the channel is invalid, it will return PROP_DONE_IDLE_TIMEOUT */
    
    /* RSSI configuration */
    rxSniffCmd->numRssiIdle = 1; /* One idle RSSI samples signals that the channel is idle */
    rxSniffCmd->numRssiBusy = 1; /* One busy RSSI samples signals that the channel is busy */
    rxSniffCmd->rssiThr = (int8_t)WOR_RSSI_THRESHOLD; /* Set the RSSI threshold in dBm */
    
    /* PQT configuration */
    rxSniffCmd->corrConfig.numCorrBusy = 1; /* One busy PQT samples signals that the channel is busy */
    rxSniffCmd->corrConfig.numCorrInv = 1; /* One busy PQT samples signals that the channel is busy */
    
    /* Calculate basic timing parameters */
    uint32_t symbolLengthUs = 1000000UL/datarate;
    uint32_t preambleSymbols = (1000000UL/wakeupPerSecond)/symbolLengthUs;
    uint8_t syncWordSymbols = RF_cmdPropRadioDivSetup.formatConf.nSwBits;
    
    /* Calculate sniff mode parameters */
    #define US_TO_RAT_TICKS 4
    #define CORR_PERIOD_SYM_MARGIN 16
    #define RX_END_TIME_SYM_MARGIN 8
    #define CS_END_TIME_MIN_TIME_SYM 30
    #define CS_END_TIME_MIN_TIME_STATIC_US 150
    
    /* Represents the time in which we need to receive corrConfig.numCorr* correlation peaks to detect preamble.
    * When continously checking the preamble quality, this period has to be wide enough to also contain the sync
    * word, with a margin. If it is not, then there is a chance the SNIFF command will abort while receiving the
    * sync word, as it no longer detects a preamble. */
    uint32_t correlationPeriodUs = (syncWordSymbols + CORR_PERIOD_SYM_MARGIN)*symbolLengthUs;
    
    /* Represents the time where we will force a check if preamble is present (only done once).
    * The main idea is that his should be shorter than "correlationPeriodUs" so that if we get RSSI valid, but
    * there is not a valid preamble on the air, we will leave RX as quickly as possible. */
    uint32_t csEndTimeUs = (CS_END_TIME_MIN_TIME_SYM*symbolLengthUs + CS_END_TIME_MIN_TIME_STATIC_US);
    
    /* Represents the maximum time from the startTrigger to when we expect a sync word to be received. */
    uint32_t rxEndTimeUs = (preambleSymbols + syncWordSymbols + RX_END_TIME_SYM_MARGIN)*symbolLengthUs;
    
    /* Set sniff mode timing configuration in sniff command in RAT ticks */
    rxSniffCmd->corrPeriod = (uint16_t)(correlationPeriodUs * US_TO_RAT_TICKS);
    rxSniffCmd->csEndTime = (uint32_t)(csEndTimeUs * US_TO_RAT_TICKS);
    rxSniffCmd->endTime = (uint32_t)(rxEndTimeUs * US_TO_RAT_TICKS);
    
    /* Set correct trigger types */
    rxSniffCmd->endTrigger.triggerType = TRIG_REL_START;
    rxSniffCmd->startTrigger.triggerType = TRIG_ABSTIME;
    rxSniffCmd->startTrigger.pastTrig = 1;
    }
    
    /* Called for every received packet and command done */
    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
    /* If we've received a new packet and it's available to read out */
    if (e & RF_EventRxEntryDone)
    {
    do
    {
    /* Toggle LED on RX */
    PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1));
    
    /* 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);
    
    /* This code block is added to avoid a compiler warning.
    * Normally, an application will reference these variables for
    * useful data. */
    dummy = packetLength + packetDataPointer[0];
    
    /*-------------My Add-----------------*/
    txPacket[0] = packetLength;
    memcpy(&txPacket[1],packetDataPointer,packetLength);
    
    Event_post(radioOperationEventHandle, RADIO_EVENT_VALID_PACKET_RECEIVED);
    /*-------------My Add-----------------*/
    
    } while(RFQueue_nextEntry() == DATA_ENTRY_FINISHED);
    }
    }
    
    
    /*
    * ======== main ========
    */
    int main(void)
    {
    /* Call driver init functions. */
    Board_initGeneral();
    
    /*-------------My Add-----------------*/
    Display_init();
    
    Display_Params params;
    Display_Params_init(&params);
    params.lineClearMode = DISPLAY_CLEAR_BOTH;
    uartDisplayHandle = Display_open(Display_Type_UART, &params);
    
    
    Event_Params eventParam;
    Event_Params_init(&eventParam);
    Event_construct(&radioOperationEvent, &eventParam);
    radioOperationEventHandle = Event_handle(&radioOperationEvent);
    
    RF_Params_init(&rfParams);
    /*-------------My Add-----------------*/
    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, pinTable);
    Assert_isTrue(ledPinHandle != NULL, NULL);
    
    /* Initialize task */
    rxTaskInit();
    txTaskInit();
    
    /* Start BIOS */
    BIOS_start();
    
    return (0);
    }

  • Hi,Did you receive my code?
  • Yes, I will have a look at it and get back to you with feedback.
  • Hi,

    I think your issue is due to RF queue placements as you don't know in what order your TX and RX operations are scheduled. I suggest you keep all radio operations inside one task to better control the order they run in. For example, it could look like this if re-using the RX task:

    /* Enter main loop */
    
    while(1)
    {
    /* Set next wakeup time in the future */
    RF_cmdPropRxSniff.startTime += WOR_WAKE_UP_INTERVAL_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);
    
    /* Schedule RX */
    RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRxSniff, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
    
    /* Log RX_SNIFF status */
    switch(RF_cmdPropRxSniff.status) {
    
    case PROP_DONE_IDLE:
    /* Idle based on RSSI */
    worStatistics.doneIdle++;
    break;
    
    case PROP_DONE_IDLETIMEOUT:
    /* Idle based on PQT */
    worStatistics.doneIdleTimeout++;
    break;
    
    case PROP_DONE_RXTIMEOUT:
    /* Got valid preamble on the air, but did not find sync word */
    worStatistics.doneRxTimeout++;
    break;
    
    case PROP_DONE_OK:
    /* Received packet */
    worStatistics.doneOk++;
    RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv,RF_PriorityNormal, NULL, 0);
    break;
    
    default:
    /* Unhandled status */
    break;
    
    };
    }
    }

    You can of course structure it in different ways, but the point is that you should not spread the radio operations over several tasks unless you are absolutely sure you get the queue placements correct. 

  • Wonderful ,You're right man,the order of commands is the key.!After I put them in the same task, the problem was solved.By the way,I only created two tasks, How can I figure out the order of commands in the queue and solve this problem,like Easylink_Abort?
  • Hi,

    The best practice here is to do what suggested above, keeping all posting RF Driver calls inside a single task where you can control the flow. You can abort and stop commands that is already running or in the queue by using for example the RF_cancelCmd API.