rfpacketTx例程结构:在原始例程的基础之上,我单独又开了一个测量传感器温度的任务(这个优先级比发送的任务要高),这个已经测试了很久了,很稳定。
今天想在rfpacketTx中,添加LBT例程中做载波监听的命令时。发现,前面程序运行好好的,运行了一段时间后,发现rx端接收不到数据了,但TX端测量温度的任务还在进行。
1.reset RX端,发现没有变化,还是收不到数据。
2.reset TX端,RX接收到了数,但过段时间又接收不到数据。
通过排查,发现是发送的任务死掉了,没有发送成功(目前不知道是什么原因导致的)。以下是我TX发送数据的代码,加入了LBT。请TI工程师帮忙看一下。
#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
static uint32_t time1;
/***** Function definitions *****/
void *mainThread(void *arg0)
{
RF_Params rfParams;
RF_Params_init(&rfParams);
// Watchdog_Init(TIMEOUT_MS);
#ifdef POWER_MEASUREMENT
#if defined(Board_CC1350_LAUNCHXL)
/* Route out PA active pin to Board_DIO30_SWPWR */
PINCC26XX_setMux(ledPinHandle, Board_DIO30_SWPWR, PINCC26XX_MUX_RFC_GPO1);
#endif
#endif
RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
RF_cmdPropTx.pPkt = packet;
// RF_cmdPropTx.startTrigger.triggerType = TRIG_NOW;
RF_cmdNop.startTrigger.triggerType = TRIG_ABSTIME;
RF_cmdNop.startTrigger.pastTrig = 1;
/* Set up the next pointers for the command chain 设置命令链表中,指向下个命令的指针*/
RF_cmdNop.pNextOp = (rfc_radioOp_t*)&RF_cmdPropCs;
RF_cmdPropCs.pNextOp = (rfc_radioOp_t*)&RF_cmdCountBranch;
RF_cmdCountBranch.pNextOp = (rfc_radioOp_t*)&RF_cmdPropTx;
RF_cmdCountBranch.pNextOpIfOk = (rfc_radioOp_t*)&RF_cmdPropCs;
/* 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 */
RF_cmdCountBranch.counter = CS_RETRIES_WHEN_BUSY;
/* Request access to the radio */
#if defined(DeviceFamily_CC26X0R2)
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioSetup, &rfParams);
#else
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
#endif// DeviceFamily_CC26X0R2
/* Set the frequency */
RF_postCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
/* Get current time */
time1 = RF_getCurrentTime();
/* Power down the radio */
RF_yield(rfHandle);
while(1)
{
send_pend();
// FEED_WATCHDOG();
/* Set absolute TX time to utilize automatic power management */
time1 += (PACKET_INTERVAL_US * 4);
RF_cmdNop.startTime = time1;
/* Send packet */
// RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx,RF_PriorityNormal, NULL, 0);
RF_EventMask terminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdNop, RF_PriorityNormal,
NULL, 0);
Display_printf(uartDisplayHandle, 0, 0, "Send packet success time:%d\n",time1);
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_cmdPropTx)->status;
switch(cmdStatus)
{
case PROP_DONE_OK:
// Packet transmitted successfully
break;
case PROP_DONE_STOPPED:
// received CMD_STOP while transmitting packet and finished
// transmitting packet
break;
case PROP_DONE_ABORT:
// Received CMD_ABORT while transmitting packet
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_TXUNF:
// TX underflow observed during operation
break;
default:
// Uncaught error event - these could come from the
// pool of states defined in rf_mailbox.h
while(1);
}
RF_cmdNop.status = IDLE;
RF_cmdPropCs.status = IDLE;
RF_cmdCountBranch.status = IDLE;
RF_cmdPropTx.status = IDLE;
RF_cmdCountBranch.counter = CS_RETRIES_WHEN_BUSY;
/* Power down the radio */
RF_yield(rfHandle);
}
}