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.

RTOS/LAUNCHXL-CC1310: how can i know the status of RF, i mind i want to know if it is in rx , tx or idle

Part Number: LAUNCHXL-CC1310
Other Parts Discussed in Thread: SYSBIOS, CC1310

Tool/software: TI-RTOS

Hi forum,

I am using two LAUNCHXL-CC1310, one transmits, the other receives and sends back a message indicating an ack, everything works well, but when both equipments put them to a certain distance, that is to say when the receiver does not receive well, this one stays In a state that no longer receives messages, i mind no longer goes into callback.
I have put that when this happens, if I press a button in the launchxl-1310 receiver, I write the command rfRxCmd = RF_postCmd (rfrxHandle, (RF_Op *) & RF_cmdPropRx, RF_PriorityNormal, & callback, RF_EventRxEntryDone); And everything works again, it is as if on receiving a message with error, it does not notify me and it stays out of the receiving state. I would like to know if there is any status that indicates if I am in reception, transmission or idle or know how I can know that I received a message with error.
Waiting for an answer, best regards

Luis Valseca

  • Hi,

    you can check the command status according to the proprietary RF user's guide. All status codes are listed in the Technical Reference Manual table 23-150. I just want to clarify:

    1. You have a link on short distances
    2. When increasing the distance, you don't receive packets anymore
    3. When you lower the distance again, you still don't receive packets
    4. Once you restart the RX command, you receive packets again.

    Is this what you are seeing?

  • Yes Richard,
    That is exactly what happen,I will look at the documentation you tell me and I will tell you if I have been able to solve the problem.
    Thank you very much your quick response.
    Best regards

    Luis Valseca
  • Ok, but this should not happen in that way. When you lose connection at some point, moving closer should make it work again. I have never seen this.
  • Hi Richard,

    I have been Saturday a lot of hours today, and I think I know what is happening, but I do not know how to solve it. When you move a device from another until it loses its coverage, it does not recover the reception. You can try the original programs rfPacketTx and RfPacketRx.Put the transmitter at high speed and -10dBm so you do not have to stray too far. With the original rfPacketRx program that
    There is in resource explorer, everything works fine, that is, you get out of coverage and come back and the receiver keeps getting. But now, if I replace the RUN command with POST, it happens that when you go away until the coverage is lost, you stop receiving it, only to receive again if I send the POST command. Here you have the modified rfPacketRx program, where RUN has been changed By POST and
    RF_cmdPropRx.pktConf.bRepeatOk = 0;
        RF_cmdPropRx.pktConf.bRepeatNok = 0;
    I have also modified the while (1); So that you see that pressing the button is recovered by sending the POST command.
    Here is the modified rfPacketRx reception program:

    ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7

    /*
    * Copyright (c) 2015-2016, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
    * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
    * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
    * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
    * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    */

    /***** Includes *****/
    #include <stdlib.h>
    #include <xdc/std.h>
    #include <xdc/cfg/global.h>
    #include <xdc/runtime/System.h>

    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Task.h>

    /* Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>

    #ifdef DEVICE_FAMILY
    #undef DEVICE_FAMILY_PATH
    #define DEVICE_FAMILY_PATH(x) <ti/devices/DEVICE_FAMILY/x>
    #include DEVICE_FAMILY_PATH(driverlib/rf_prop_mailbox.h)
    #else
    #error "You must define DEVICE_FAMILY at the project level as one of cc26x0, cc26x0r2, cc13x0, etc."
    #endif

    /* Board Header files */
    #include "Board.h"

    #include "RFQueue.h"
    #include "smartrf_settings/smartrf_settings.h"

    #include <stdlib.h>

    /* Pin driver handle */
    static PIN_Handle ledPinHandle;
    static PIN_State ledPinState;

    /*
    * Application LED pin configuration table:
    * - All LEDs board LEDs are off.
    */
    PIN_Config pinTable[] =
    {
    Board_PIN_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
    PIN_TERMINATE
    };
    RF_CmdHandle rfRxCmd;


    /***** Defines *****/
    #define RX_TASK_STACK_SIZE 1024
    #define RX_TASK_PRIORITY 2

    /* Packet RX Configuration */
    #define DATA_ENTRY_HEADER_SIZE 8 /* Constant header size of a Generic Data Entry */
    #define MAX_LENGTH 30 /* Max length byte the radio will accept */
    #define NUM_DATA_ENTRIES 2 /* NOTE: Only two data entries supported at the moment */
    #define NUM_APPENDED_BYTES 2 /* The Data Entries data field will contain:
    * 1 Header byte (RF_cmdPropRx.rxConf.bIncludeHdr = 0x1)
    * Max 30 payload bytes
    * 1 status byte (RF_cmdPropRx.rxConf.bAppendStatus = 0x1) */

    /***** Prototypes *****/
    static void rxTaskFunction(UArg arg0, UArg arg1);
    static void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e);

    /***** Variable declarations *****/
    static Task_Params rxTaskParams;
    Task_Struct rxTask; /* not static so you can see in ROV */
    static uint8_t rxTaskStack[RX_TASK_STACK_SIZE];

    static RF_Object rfObject;
    static RF_Handle rfHandle;

    /* Buffer which contains all Data Entries for receiving data.
    * Pragmas are needed to make sure this buffer is 4 byte aligned (requirement from the RF Core) */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_ALIGN (rxDataEntryBuffer, 4);
    static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)];
    #elif defined(__IAR_SYSTEMS_ICC__)
    #pragma data_alignment = 4
    static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH,
    NUM_APPENDED_BYTES)];
    #elif defined(__GNUC__)
    static uint8_t rxDataEntryBuffer [RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
    MAX_LENGTH, NUM_APPENDED_BYTES)] __attribute__ ((aligned (4)));
    #else
    #error This compiler is not supported.
    #endif

    /* Receive dataQueue for RF Core to fill in data */
    static dataQueue_t dataQueue;
    static rfc_dataEntryGeneral_t* currentDataEntry;
    static uint8_t packetLength;
    static uint8_t* packetDataPointer;

    static PIN_Handle pinHandle;

    static uint8_t packet[MAX_LENGTH + NUM_APPENDED_BYTES - 1]; /* The length byte is stored in a separate variable */


    /***** Function definitions *****/
    void RxTask_init(PIN_Handle ledPinHandle) {
    pinHandle = ledPinHandle;

    Task_Params_init(&rxTaskParams);
    rxTaskParams.stackSize = RX_TASK_STACK_SIZE;
    rxTaskParams.priority = RX_TASK_PRIORITY;
    rxTaskParams.stack = &rxTaskStack;
    rxTaskParams.arg0 = (UInt)1000000;

    Task_construct(&rxTask, rxTaskFunction, &rxTaskParams, NULL);
    }

    static void rxTaskFunction(UArg arg0, UArg arg1)
    {
    RF_Params rfParams;
    RF_Params_init(&rfParams);

    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 */
    RF_cmdPropRx.pQueue = &dataQueue; /* Set the Data Entity queue for received data */
    RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1; /* Discard ignored packets from Rx queue */
    RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1; /* Discard packets with CRC error from Rx queue */
    RF_cmdPropRx.maxPktLen = MAX_LENGTH; /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
    RF_cmdPropRx.pktConf.bRepeatOk = 0;     //1;
    RF_cmdPropRx.pktConf.bRepeatNok = 0;  //1;

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

    /* Enter RX mode and stay forever in RX */
    // RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, IRQ_RX_ENTRY_DONE);
    rfRxCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);

    while(1)
    {
    if(!GPIO_read(Board_GPIO_BTN1))
    {


    rfRxCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
    }

    }

    }

    void callback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
    if (e & RF_EventRxEntryDone)
    {
    /* Toggle pin to indicate RX */
    PIN_setOutputValue(pinHandle, Board_PIN_LED2,!PIN_getOutputValue(Board_PIN_LED2));

    /* 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, packetDataPointer, (packetLength + 1));
    rfRxCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);

    RFQueue_nextEntry();
    }
    }

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

    /* Open LED pins */
    ledPinHandle = PIN_open(&ledPinState, pinTable);
    if(!ledPinHandle)
    {
    System_abort("Error initializing board LED pins\n");
    }

    /* Initialize task */
    RxTask_init(ledPinHandle);

    /* Start BIOS */
    BIOS_start();

    return (0);
    }

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Waiting for someone to help me, best regards
    Luis Valseca

  • Hi,

    thanks for posting the relevant code. The problem is located in those lines:

    RF_cmdPropRx.rxConf.bAutoFlushIgnored = 1; /* Discard ignored packets from Rx queue */
    RF_cmdPropRx.rxConf.bAutoFlushCrcErr = 1; /* Discard packets with CRC error from Rx queue */
    RF_cmdPropRx.maxPktLen = MAX_LENGTH; /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
    RF_cmdPropRx.pktConf.bRepeatOk = 0;     //1;
    RF_cmdPropRx.pktConf.bRepeatNok = 0;  //1;

    You are flushing erroneous packets from the queue and you have set bRepeatNok at the same time. When you increase the distance between transmitter and receiver, the probability of packet errors increases as well. Such packets are flushed from the queue, you wouldn't get a callback and you wouldn't toggle the pin. The RX command is terminated and your loop would get stuck:

    while(1)
    {
       if(!GPIO_read(Board_GPIO_BTN1))
       {
           rfRxCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropRx, RF_PriorityNormal, &callback, RF_EventRxEntryDone);
       }
    }

    Don't use this approach. Either configure the RX command for infinite RX or restart it whenever it finishes. Use the RF_EventLastCmdDone callback event to determine when the command has finished.

  • Hi Richard
    I have only changed RF_cmdPropRx.pktConf.bRepeatNok = 0; By RF_cmdPropRx.pktConf.bRepeatNok = 1 ;, and now everything works perfectly.
    When you tell me that it is better to use the command for infinite rx, you mean use RUN instead of POST? .I do not understand what you mean by
    Use the RF_EventLastCmdDone callback event to determine when the command has finished. Could you tell me where I can see an example ?.
    Richard, your message to me has been a great help. Many thanks for sharing your knowledge with the people who are starting with this powerful cc1310 microcontroller.

    Best regards


    Luis Valseca

  • Hi,

    please read the RF driver section in the proprietary RF user's guide about the difference between RF_postCmd() and RF_runCmd(). RF_postCmd() allows you to start an RF operation on the RF core and to proceed with your task on the main MCU. RF_runCmd() blocks the current task and waits until the RF operation has finished.

    Usually, you want to ignore wrong packets and only receive valid packets. That's why RF_cmdPropRx.pktConf.bRepeatNok = 1 is a good idea. Using RF_postCmd() makes sense for an RX operation if you want your task to perform other work while the RF core is listening for a packet.