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.

CC1310: Need help with CMD_PROP_CS

Part Number: CC1310

I am developing an application that waits for a beacon packet (comes every second) and then transmits a packet if there

are no other devices transmitting.  The pseudo-code looks something like this:

waitForNextBeacon();
if (no-carrier for 5 msec)
{
   transmitPacket();
}

My plan is to CMD_PROP_CS to check for up to 5 msec if another device is transmitting.

I started by looking at the rFListenBeforeTalk example but it appears much more complicated

than I need.  In addition, I don't want it to wait until there is an open spot.   I only want it to

wait for up 5 msec.  If a carrier is detected before the 5 msec is up it should return immediately

indicating that the channel is busy.

The configuration for the CMD_PROP_CS is

    RF_cmdPropCs =
    {
        .commandNo                = CMD_PROP_CS,
        .pNextOp                  = 0,
        .startTrigger.triggerType = TRIG_NOW,
        .csConf.bEnaRssi          = 0x1, // Enable RSSI as a criterion
        .csConf.busyOp            = 0x1, // End carrier sense on channel Busy
        .rssiThr                  = -80, // Set the RSSI threshold in the application
        .numRssiIdle              = 0x3, // Number of consecutive RSSI measurements - 1 below the threshold
                                         // needed before the channel is declared Idle
        .numRssiBusy              = 0x3, // Number of consecutive RSSI measurements -1 above the threshold
                                         // needed before the channel is declared Busy
        .csEndTrigger.triggerType = TRIG_REL_START, // Trigs at a time relative to the command started
        .csEndTime                = 20000;
    };

How do I make it return after 5 msec if it does not see a carrier and immediately if it does?

Victor

  • Hi Victor

    Below is a modified version of the LBT example. It transmit a packet if the channel has been IDLE in 5 ms and return immediately if the channel is BUSY:

    /***** Includes *****/
    /* Standard C Libraries */
    #include <stdlib.h>
    #include <unistd.h>
    
    /* TI Drivers */
    #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 "smartrf_settings/smartrf_settings.h"
    #include "application_settings.h"
    
    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;
    
    /* Application LED pin configuration table: */
    PIN_Config ledPinTable[] =
    {
        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,
        PIN_TERMINATE
    };
    
    /***** Defines *****/
    #define PAYLOAD_LENGTH          30
    #define PACKET_INTERVAL_US      200000
    /* Number of times the CS command should run when the channel is BUSY */
    #define CS_RETRIES_WHEN_BUSY    10
    /* The channel is reported BUSY is the RSSI is above this threshold */
    #define RSSI_THRESHOLD_DBM      -80
    #define IDLE_TIME_US            5000
    /* Proprietary Radio Operation Status Codes Number: Operation ended normally */
    #define PROP_DONE_OK            0x3400
    
    /***** Prototypes *****/
    static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
    
    /***** Variable declarations *****/
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    
    static uint8_t packet[PAYLOAD_LENGTH];
    static uint16_t seqNumber;
    
    /*
     *  ======== txTaskFunction ========
     */
    void *mainThread(void *arg0)
    {
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, ledPinTable);
        if (ledPinHandle == NULL)
        {
            while(1);
        }
    
        PINCC26XX_setMux(ledPinHandle, Board_PIN_LED0, PINCC26XX_MUX_RFC_GPO0);
        PINCC26XX_setMux(ledPinHandle, Board_PIN_LED1, PINCC26XX_MUX_RFC_GPO2);
    
        RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
        RF_cmdPropTx.pPkt = packet;
        RF_cmdPropCs.startTrigger.triggerType = TRIG_NOW;
        RF_cmdPropCs.pNextOp = (rfc_radioOp_t*)&RF_cmdPropTx;
        RF_cmdPropCs.condition.rule = 0;
        RF_cmdPropCs.condition.rule = COND_STOP_ON_TRUE; // Stop if this command returned TRUE, run next command if it returned FALSE
                                                         // End causes for the CMD_PROP_CS command:
                                                         // Observed channel state Busy with csConf.busyOp = 1:                            PROP_DONE_BUSY        TRUE
                                                         // 0bserved channel state Idle with csConf.idleOp = 1:                            PROP_DONE_IDLE        FALSE
                                                         // Timeout trigger observed with channel state Busy:                              PROP_DONE_BUSY        TRUE
                                                         // Timeout trigger observed with channel state Idle:                              PROP_DONE_IDLE        FALSE
                                                         // Timeout trigger observed with channel state Invalid and csConf.timeoutRes = 0: PROP_DONE_BUSYTIMEOUT TRUE
                                                         // Timeout trigger observed with channel state Invalid and csConf.timeoutRes = 1: PROP_DONE_IDLETIMEOUT FALSE
                                                         // Received CMD_STOP after command started:                                       PROP_DONE_STOPPED     FALSE
    
        /* Customize the API commands with application specific defines */
        RF_cmdPropCs.rssiThr = RSSI_THRESHOLD_DBM;
        RF_cmdPropCs.csEndTime = (IDLE_TIME_US + 150) * 4; /* Add some margin */
    
    
        /* Request access to the radio */
        rfHandle = RF_open(&rfObject, &RF_prop,
                           (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
    
        /* Set the frequency */
        RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0)
    
        /* Run forever */
        while(true)
        {
            /* Create packet with incrementing sequence number & random payload */
            packet[0] = (uint8_t)(seqNumber >> 8);
            packet[1] = (uint8_t)(seqNumber);
            uint8_t i;
            for (i = 2; i < PAYLOAD_LENGTH; i++)
            {
                packet[i] = rand();
            }
    
            /* Send packet */
            RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropCs, RF_PriorityNormal,
                      &callback, 0);
    
            /* Power down the radio */
            RF_yield(rfHandle);
    
            usleep(50000);
        }
    }
    
    /*
     *  ======== callback ========
     */
    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
        if ((e & RF_EventLastCmdDone) && (RF_cmdPropTx.status == PROP_DONE_OK))
        {
            seqNumber++;
        }
    }

    Siri

  • Thanks for your help Siri.
  • This fixed my issue. Thanks.