Part Number: CC1352P
Other Parts Discussed in Thread: CC2520
We made a board with XCC1352P and we have tried the no-rtos Tx & Rx example programs in IAR.
For the IEEE802..15.4 operation, we have imported the settings from SmartRfStudio.
Tx & Rx example programs are working.. In Tx side, scheduleCmd() is working instead of runCmd().
runCmd() is not existing.Why is it so?
Then we tried the RfEcho program.We have a card with CC2520 sending periodic(90ms) frames and we setup our new board to echo the same after receiving it correctly.
Now the echo program is not exiting from the runCmd() . At the same time, the echo call back function is executing with the RfEvntRxEntryDone. It is never going to the RfEvntLastCmdDone or exiting from runCmd(). we are able to see the received packet in memory.
We are not seeing any packet going out as echo in the smart Rf studio also.
Why the tx cmd after the rx not working? why the rndCmd() is not exiting? How can we solve this issue?
Code, which we used for the same is given below:
#ifndef Echo
#define PAYLOAD_LENGTH 0x1E
static void echoCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);
/* Receive Statistics */
static rfc_ieeeRxOutput_t rxStatistics;
/* Set Transmit (echo) delay to 100ms */
#define TX_DELAY (uint32_t)(4000000*0.1f)
void *mainThread(void *arg0)
{
RF_Params rfParams;
RF_Params_init(&rfParams);
if( RFQueue_defineQueue(&dataQueue,
rxDataEntryBuffer,
sizeof(rxDataEntryBuffer),
NUM_DATA_ENTRIES,
PAYLOAD_LENGTH + NUM_APPENDED_BYTES))
{
/* Failed to allocate space for all data entries */
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, 1);
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2, 1);
while(1);
}
/* Modify CMD_PROP_TX and CMD_PROP_RX commands for application needs */
/* Set the Data Entity queue for received data */
RF_cmdIeeeRx.pRxQ = &dataQueue;
RF_cmdIeeeRx.rxConfig.bAutoFlushIgn=1;
/* Discard packets with CRC error from Rx queue */
RF_cmdIeeeRx.rxConfig.bAutoFlushCrc=1;
/* Discard ignored packets from Rx queue */
RF_cmdIeeeRx.rxConfig.bAutoFlushIgn = 1;
/* Discard packets with CRC error from Rx queue */
RF_cmdIeeeRx.rxConfig.bAutoFlushCrc = 1;
/* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
//RF_cmdIeeeRx.maxPktLen = PAYLOAD_LENGTH;
/* End RX operation when a packet is received correctly and move on to the
* next command in the chain */
//RF_cmdIeeeRx. pktConfig.bRepeatOk = 0;
//RF_cmdIeeeRx.pktConfig.bRepeatNok = 1;
RF_cmdIeeeRx.startTrigger.triggerType = TRIG_NOW;
RF_cmdIeeeRx.pNextOp = (rfc_radioOp_t *)&RF_cmdIeeeTx;
/* Only run the TX command if RX is successful */
RF_cmdIeeeRx.condition.rule = COND_ALWAYS;//COND_STOP_ON_FALSE;
RF_cmdIeeeRx.pOutput = &rxStatistics;
RF_cmdIeeeTx.payloadLen = PAYLOAD_LENGTH;
RF_cmdIeeeTx.pPayload = packet;
RF_cmdIeeeTx.startTrigger.triggerType = TRIG_NOW;//TRIG_REL_PREVEND;
RF_cmdIeeeTx.startTime =0;//TX_DELAY;
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop,
(RF_RadioSetup*)&RF_cmdRadioSetup, &rfParams);
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
while(1)
{
/* Wait for a packet
* - When the first of the two chained commands (RX) completes, the
* RF_EventCmdDone and RF_EventRxEntryDone events are raised on a
* successful packet reception, and then the next command in the chain
* (TX) is run
* - If the RF core runs into an issue after receiving the packet
* incorrectly onlt the RF_EventCmdDone event is raised; this is an
* error condition
* - If the RF core successfully echos the received packet the RF core
* should raise the RF_EventLastCmdDone event
*/
RF_EventMask terminationReason =
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdIeeeRx, RF_PriorityNormal,
echoCallback, (RF_EventRxEntryDone |
RF_EventLastCmdDone));
/* RF_EventMask terminationReason =
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdIeeeRx, RF_PriorityNormal,
echoCallback, (RF_EventRxEntryDone |
RF_EventLastCmdDone));
*/
/* RF_ScheduleCmdParams_init(&scheduleParam);
scheduleParam.priority=RF_PriorityNormal;
scheduleParam.allowDelay=0;*/
//RF_CmdHandle cmd=RF_runCmd(rfHandle, (RF_Op*)&RF_cmdIeeeTx, RF_PriorityNormal,echoCallback, (RF_EventRxEntryDone |
// RF_EventLastCmdDone));
// RF_CmdHandle cmd=RF_scheduleCmd(rfHandle, (RF_Op*)&RF_cmdIeeeTx, &scheduleParam,echoCallback, (RF_EventRxEntryDone |
//RF_EventLastCmdDone));
switch(terminationReason)
{
case RF_EventLastCmdDone:
// A stand-alone radio operation command or the last radio
// operation command in a chain finished.
break;
case RF_EventCmdCancelled:
// Command cancelled before it was started; it can be caused
// by RF_cancelCmd() or RF_flushCmd().
break;
case RF_EventCmdAborted:
// Abrupt command termination caused by RF_cancelCmd() or
// RF_flushCmd().
break;
case RF_EventCmdStopped:
// Graceful command termination caused by RF_cancelCmd() or
// RF_flushCmd().
break;
default:
// Uncaught error event
while(1);
}
uint32_t cmdStatus = ((volatile RF_Op*)&RF_cmdIeeeRx)->status;
#ifdef CMD_STATUS
switch(cmdStatus)
{
case PROP_DONE_OK:
// Packet received with CRC OK
break;
case PROP_DONE_RXERR:
// Packet received with CRC error
break;
case PROP_DONE_RXTIMEOUT:
// Observed end trigger while in sync search
break;
case PROP_DONE_BREAK:
// Observed end trigger while receiving packet when the command is
// configured with endType set to 1
break;
case PROP_DONE_ENDED:
// Received packet after having observed the end trigger; if the
// command is configured with endType set to 0, the end trigger
// will not terminate an ongoing reception
break;
case PROP_DONE_STOPPED:
// received CMD_STOP after command started and, if sync found,
// packet is received
break;
case PROP_DONE_ABORT:
// Received CMD_ABORT after command started
break;
case PROP_ERROR_RXBUF:
// No RX buffer large enough for the received data available at
// the start of a packet
break;
case PROP_ERROR_RXFULL:
// Out of RX buffer space during reception in a partial read
break;
case PROP_ERROR_PAR:
// Observed illegal parameter
break;
case PROP_ERROR_NO_SETUP:
// Command sent without setting up the radio in a supported
// mode using CMD_PROP_RADIO_SETUP or CMD_RADIO_SETUP
break;
case PROP_ERROR_NO_FS:
// Command sent without the synthesizer being programmed
break;
case PROP_ERROR_RXOVF:
// RX overflow observed during operation
break;
default:
// Uncaught error event - these could come from the
// pool of states defined in rf_mailbox.h
while(1);
}
#endif
}
}
static void echoCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
#ifdef LOG_RADIO_EVENTS
eventLog[evIndex++ & 0x1F] = e;
#endif// LOG_RADIO_EVENTS
if (e & RF_EventRxEntryDone)
{
/* Successful RX */
/* Toggle LED2, clear LED1 to indicate RX */
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, 0);
//PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,
// !PIN_getOutputValue(Board_PIN_LED2));
/* Get current unhandled data entry */
currentDataEntry = RFQueue_getDataEntry();
/* Handle the packet data, located at ¤tDataEntry->data:
* - Length is the first byte with the current configuration
* - Data starts from the second byte */
packetLength = 19;//0x1E;//*(uint8_t *)(&(currentDataEntry->data));
packetDataPointer = (uint8_t *)(&(currentDataEntry->data) + 1);
/* Copy the payload + status byte to the rxPacket variable, and then
* over to the txPacket
*/
memcpy(packet, packetDataPointer, packetLength);
RFQueue_nextEntry();
}
else if (e & RF_EventLastCmdDone)
{
/* Successful Echo (TX)*/
/* Toggle LED2, clear LED1 to indicate RX */
//PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, 0);
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2,
// !PIN_getOutputValue(Board_PIN_LED2));
packetLength = 19;//just for debugging purpose!
}
else // any uncaught event
{
/* Error Condition: set LED1, clear LED2 */
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED1, 1);
// PIN_setOutputValue(ledPinHandle, Board_PIN_LED2, 0);
packetLength = 19;//just for debugging purpose!
}
}
#endif