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.

LAUNCHXL-CC1310: CC1310 Rx cannot exit callback function.

Part Number: LAUNCHXL-CC1310

Hi,

I am using the ready rfWakeOnRadioTx application. After sending data over this application, I want it to stay in reading mode until it gets the return value, and when the reading mode is finished, I want it to switch to Write mode and wait, but I could not succeed.

Can you help me in this regard.

Code:

/* TX task function. Executed in Task context by TI-RTOS when the scheduler starts. */
static void txTaskFunction(UArg arg0, UArg arg1)
{
/* Setup callback for button pins */
PIN_Status status = PIN_registerIntCb(buttonPinHandle, &buttonCallbackFunction);
Assert_isTrue((status == PIN_SUCCESS), NULL);

/* Initialize the radio */
RF_Params rfParams;
RF_Params_init(&rfParams);


/* 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);
}

/* Modify CMD_PROP_RX command for application needs */
/* Set the Data Entity queue for received data */
RF_cmdPropRx.pQueue = &dataQueue;
/* Discard ignored packets from Rx queue */
RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;
/* Discard packets with CRC error from Rx queue */
RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1;
/* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
RF_cmdPropRx.maxPktLen = MAX_LENGTH;
RF_cmdPropRx.pktConf.bRepeatOk = 1;
RF_cmdPropRx.pktConf.bRepeatNok = 1;

/* Initialize TX_ADV command from TX command */
initializeTxAdvCmdFromTxCmd(&RF_cmdPropTxAdv, &RF_cmdPropTx);

/* Set application specific fields */
RF_cmdPropTxAdv.pktLen = PAYLOAD_LENGTH +1; /* +1 for length byte */
RF_cmdPropTxAdv.pPkt = packet;
RF_cmdPropTxAdv.preTrigger.triggerType = TRIG_REL_START;
RF_cmdPropTxAdv.preTime = WOR_PREAMBLE_TIME_RAT_TICKS(WOR_WAKEUPS_PER_SECOND);

/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);

/* Set the frequency */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);

/* Enter main TX loop */
while(1)
{
/* Wait for a button press */
Semaphore_pend(txSemaphoreHandle, BIOS_WAIT_FOREVER);

packet[0] = PAYLOAD_LENGTH;
packet[1] = 0xAA;
packet[2] = 0xBB;
packet[3] = 'I';
packet[4] = 'N';
packet[5] = 'O';
packet[6] = 'V';
packet[7] = 'A';
packet[8] = 'R';

/* Send packet */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);

switch(RF_cmdPropTxAdv.status)
{
case PROP_DONE_OK:
// Packet transmitted successfully

/* Toggle LED */
PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1));

RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx,RF_PriorityNormal, &callback,RF_EventRxEntryDone);

/* Log RX_SNIFF status */
switch(RF_cmdPropRx.status) {
case PROP_DONE_IDLE:
/* Idle based on RSSI */
break;
case PROP_DONE_IDLETIMEOUT:
/* Idle based on PQT */
break;
case PROP_DONE_RXTIMEOUT:
/* Got valid preamble on the air, but did not find sync word */
break;
case PROP_DONE_OK:
/* Received packet */
PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, !PIN_getOutputValue(Board_PIN_LED1));
break;
default:
/* Unhandled status */
break;
};
break;
default:
// Uncaught error event - these could come from the
// pool of states defined in rf_mailbox.h
while(1);
}
}
}

/* 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;
}


/*
* ======== main ========
*/
int main(void)
{
/* Call driver init functions. */
Board_initGeneral();
Display_init();

/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, pinTable);
Assert_isTrue(ledPinHandle != NULL, NULL);

/* Open Button pins */
buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
Assert_isTrue(buttonPinHandle != NULL, NULL);

/* Initialize task */
//txTaskInit();

/* Initialize TX semaphore */
Semaphore_construct(&txSemaphore, 0, NULL);
txSemaphoreHandle = Semaphore_handle(&txSemaphore);

/* Initialize and create TX task */
Task_Params_init(&txTaskParams);
txTaskParams.stackSize = TX_TASK_STACK_SIZE;
txTaskParams.priority = TX_TASK_PRIORITY;
txTaskParams.stack = &txTaskStack;
Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL);

/* Start BIOS */
BIOS_start();

return (0);
}

void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
if (e & RF_EventRxEntryDone)
{
do{

/* 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_Rx, packetDataPointer, (packetLength + 1));

} while(RFQueue_nextEntry() == DATA_ENTRY_FINISHED);

}
}

Note:

In the rfWakeOnRadioRx application, I could do what I said, the device is in read mode at the first startup, when the data is received, the device reads the data and switches to write mode after 5 seconds, and then after finishing the writing process, it switches to read mode again.

Ali,

 

  • Hi Ali, 

    Which version of the SDK are you using? And have you made any modifications to the code? 

    Thanks, 
    Elin 

  • Hi Elin,

    SDK version = simplelink_cc13x0_sdk_4_10_01_01

    yes, i have modified the code.

  • You have set bothrepeat modes to 1

    RF_cmdPropRx.pktConf.bRepeatOk = 1;
    RF_cmdPropRx.pktConf.bRepeatNok = 1;

    Meaning that you will never return from the

    RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);

    unless the radio exit RX due to some kind of error state (buffer overflow etc.)

    Set repeat mode to 0, and you will exit RX once a packet is received. If you do not want to stay in RX forever 8in case no packets are received), you can use an endTrigger for the RX command. It will then exit when a packet is received, or when the trigger hits.

    BR

    Siri

  • Hi Siri,

    Thanks solved the problem.

    /* Modify CMD_PROP_TX and CMD_PROP_RX commands for application needs */
    /* Set the Data Entity queue for received data */
    RF_cmdPropRx.pQueue = &dataQueue;
    /* Discard ignored packets from Rx queue */
    RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1;
    /* Discard packets with CRC error from Rx queue */
    RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1;
    /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
    RF_cmdPropRx.maxPktLen = PAYLOAD_LENGTH;
    /* End RX operation when a packet is received correctly and move on to the
    * next command in the chain */
    RF_cmdPropRx.pktConf.bRepeatOk = 0;
    RF_cmdPropRx.pktConf.bRepeatNok = 1;
    RF_cmdPropRx.startTrigger.triggerType = TRIG_NOW;
    RF_cmdPropRx.pNextOp = (rfc_radioOp_t *)&RF_cmdPropTx;
    /* Only run the TX command if RX is successful */
    RF_cmdPropRx.condition.rule = COND_STOP_ON_FALSE;
    RF_cmdPropRx.pOutput = (uint8_t *)&rxStatistics;

    Thanks, 

    Ali