I want to konw how to test RSSI(cc1310) use softe code .I don't want to use smartRFstdio,beacause it too Trouble.
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.
Why do you say that SmartRF Studio is too much trouble?
The function RF_getRssi() always returns the most up-to-date RSSI value. It basically issues a CMD_GET_RSSI (refer to the [TRM| ] p. 1506) and returns the content of the RSSIVAL register from the RF core. When calling RF_getRssi(), please be aware of the these conditions:
- The RF core has to be in RX mode. Otherwise, -128 (invalid RSSI) is returned.
- How often, how fast and when exactly RSSIVAL is updated, depends highly on the current command.
- After issuing the first RX command, RF_getRssi() may return 0 for a very short time (some microseconds) and the returned value might not be stable immediately. A delay of 1ms should get you on the safe side. We are currently investigating, how we can guarantee that RF_getRssi() always returns the next available valid RSSI value. I also admit, that we need to improve the API documentation.
The RSSI of the last received packet is only available in the packet itself.
Here is a code snippet that shows how to measure the RSSI with a RX Test command. Any other RX command would work as well.
int8_t rssi = (int8_t)RF_GET_RSSI_ERROR_VAL; // CMD_RX_TEST volatile rfc_CMD_RX_TEST_t RF_cmdRxTest = { .commandNo = CMD_RX_TEST, .status = 0x0000, .pNextOp = 0, // INSERT APPLICABLE POINTER: (uint8_t*)&xxx .startTime = 0x00000000, .startTrigger.triggerType = TRIG_NOW, .startTrigger.bEnaCmd = 0x0, .startTrigger.triggerNo = 0x0, .startTrigger.pastTrig = 0x0, .condition.rule = COND_NEVER, .condition.nSkip = 0x0, .config.bEnaFifo = 0x0, .config.bFsOff = 0x1, .config.bNoSync = 0x1, .endTrigger.triggerType = TRIG_REL_START, .endTrigger.bEnaCmd = 0x0, .endTrigger.triggerNo = 0x0, .endTrigger.pastTrig = 0x0, .syncWord = 0x930b51de, .endTime = EasyLink_ms_To_RadioTime(10), }; // Execute the command asynchronously RF_CmdHandle cmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdRxTest, RF_PriorityNormal, 0, EASYLINK_RF_EVENT_MASK); // Make sure that the RX_TEST command is running while (RF_cmdRxTest.status != ACTIVE); // Even though the command is running, we have to wait for the RF core to be in receive mode // Otherwise it returns 0 while ((rssi == RF_GET_RSSI_ERROR_VAL) || (rssi == 0)) { rssi = RF_getRssi(rfHandle); }
hi TER:
Thanks for your reply.
I have a question:Why you add "while ((rssi == RF_GET_RSSI_ERROR_VAL) || (rssi == 0))" before reading RSSI Value?
I tried like what you said,it returned at the first time ,and then it returned nothing.
hi Richard
Thanks for your reply.
I mean RSSI returned at the first time because rssi value was initialled by RF_GET_RSSI_ERROR_VAL, and then rssi value was read by rssi = RF_getRssi(rfHandle); now rssi value neither equals to RF_GET_RSSI_ERROR_VAL nor 0,so it never enters while ((rssi == RF_GET_RSSI_ERROR_VAL) || (rssi == 0)).
Below is my test code,can you pls check if there is any problem?
/* Request access to the radio */
rfHandle = RF_open(&rfObject, &RF_prop, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup, &rfParams);
//rfHandle = RF_open(&rfObject, &RF_prop_lrm, (RF_RadioSetup*)&RF_cmdPropRadioDivSetup_lrm, &rfParams);
/* Set the frequency */
RF_runCmd(rfHandle, (RF_Op*)&RF_cmdFs, RF_PriorityNormal, NULL, 0);
/* Enter RX mode and stay forever in RX */
rxCmdHndl = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, IRQ_RX_ENTRY_DONE);
while(1)
{
if(packetReceived)
{
packetReceived = 0;
UART_write(uart, "Received OK!", 12);
}
while ((rssi == RF_GET_RSSI_ERROR_VAL) || (rssi == 0))
{
rssi = RF_getRssi(rfHandle);
char string1[10];
sprintf(string1,"Rssi Value:%ddB\r\n", rssi);
UART_write(uart, string1, strlen(string1));
}
void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
if (e & RF_EventRxEntryDone)
{
packetReceived =1;
/* Toggle pin to indicate RX */
PIN_setOutputValue(pinHandle, Board_LED2,!PIN_getOutputValue(Board_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 = *(uint8_t*)(¤tDataEntry->data);
packetDataPointer = (uint8_t*)(¤tDataEntry->data + 1);
/* Copy the payload + the status byte to the packet variable */
memcpy(packet, packetDataPointer, (packetLength + 2));
RFQueue_nextEntry();
}
}
And this is test result:
No valid RSSI value is printed when RF received data.
Sorry, there was a misunderstanding. This loop is a delay loop that waits for a valid RSSI:
int rssi = RF_GET_RSSI_ERROR_VAL; while ((rssi == RF_GET_RSSI_ERROR_VAL) || (rssi == 0)) { rssi = RF_getRssi(rfHandle); }
Depending on the command timing it might run only once. After that you can do
while (1) { rssi = RF_getRssi(rfHandle); char string1[10]; sprintf(string1,"Rssi Value:%ddB\r\n", rssi); UART_write(uart, string1, strlen(string1)); }
Richard
hi richard
Thanks for your reply.
As you suggested,I modified my code like this:
while ((rssi == RF_GET_RSSI_ERROR_VAL) || (rssi == 0))
{
rssi = RF_getRssi(rfHandle);
}
while(1)
{
if(packetReceived)
{
packetReceived = 0;
UART_write(uart, "Received OK!\r\n", 14);
char string1[30];
rssi = RF_getRssi(rfHandle);
sprintf(string1,"Rssi Value:%ddB\r\n", rssi);
UART_write(uart, string1, strlen(string1));
}
}
When packet received correctly(packetreceived is set in RX Callback), print "Received OK" and the current RSSI Value, but the result is below:
Received OK!
Rssi Value:-99dB
Received OK!
Rssi Value:-101dB
Received OK!
Rssi Value:-104dB
Received OK!
Rssi Value:-94dB
Received OK!
Rssi Value:-95dB
Received OK!
Rssi Value:-101dB
Received OK!
Rssi Value:-100dB
Received OK!
Rssi Value:-100dB
Received OK!
It's very strange that the RSSI Value is very low, and if I modified my code if(packetReceived) to if(1), then correct RSSI value can be printed occasionally,like this:
Rssi Value:-99dB
Received OK!
Rssi Value:-101dB
Received OK!
Rssi Value:-104dB
Received OK!
Rssi Value:-14dB
Received OK!
Rssi Value:-95dB
Received OK!
Rssi Value:-101dB
Received OK!
Rssi Value:-100dB
Why is this strange? As long as you don't send anything on that frequency, -100dBm is totally valid. In the moment when you receive a packet, you can observe a RSSI of -14dBm when transceiver and receiver are close together.
If you are interested only in the RSSI of the received packet, then there is a more reliable way:
// Output structure for CMD_PROP_RX rfc_propRxOutput_t rxStatistics; // Set up RX command to output statistics data RF_cmdPropRx.pOutput = (uint8_t*)&rxStatistics; // Read RSSI after a packet has been received int8 rssi = &rxStatistics.lastRssi;