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.

CC1310: 0x3801 Error While Tx - Rx Radio Mode Switching

Part Number: CC1310

I have modified rfWakeOnRadioTx_CC1310_LAUNCHXL_tirtos_ccs  to stay in Normal Packet Rx and on button press it sends packet with WOR Tx.

Test Setup:

Module A  is connected to SmartRF Studio with 433.92032MHz, GFSK, 2.49939kbps, 0dBm, RXFB 59KHz, Dev 5KHz (Modified default 50Kbps Smart RF GFSK setting).

Module A Tx packet continuously at 150ms.

Module B runs  on attached firmware in which it receives RF packet and toggles LED and If I Press Puch Button it cancels Rx Mode Cmd and sends Tx packet and again goes back to Rx mode and stays there if button pressed again than process repeats.

It is working but after few button press On running  RF_runCmd(rfHandle, (RF_Op*)SR_RF_cmdPropRx, RF_PriorityNormal, rfCallback, 0xFFFFFFFF);  it do not stats there but it exit immediately and SR_RF_cmdPropRx->status is set to 0x3801. 

Project  and Log is attached.rfWakeOnRadioTx_CC1310_LAUNCHXL_tirtos_ccs.rar

15:32:14.120> SR CC1310 Test App...
15:32:17.496> Tx Loop Cntr = 0
15:32:18.118> TxterminationReason = 0x2, RF_cmdPropTxAdv.status = 0x3400
15:32:21.432> RxterminationReason = 0x2000000000000000, SR_RF_cmdPropRx->status = 0x3405
15:32:21.432> Tx Loop Cntr = 1
15:32:22.057> TxterminationReason = 0x2, RF_cmdPropTxAdv.status = 0x3400
15:32:24.870> RxterminationReason = 0x2000000000000000, SR_RF_cmdPropRx->status = 0x3405
15:32:24.870> Tx Loop Cntr = 2
15:32:25.557> TxterminationReason = 0x2, RF_cmdPropTxAdv.status = 0x3400
15:32:25.869> RxterminationReason = 0x2, SR_RF_cmdPropRx->status = 0x3801
15:32:25.869> eventLog[0] = 0x800000
15:32:25.869> eventLog[1] = 0x800000
15:32:25.869> eventLog[2] = 0x800000
15:32:25.869> eventLog[3] = 0x800000
15:32:25.869> eventLog[4] = 0x800000
15:32:25.869> eventLog[5] = 0x800000
15:32:25.869> eventLog[6] = 0x800000
15:32:25.869> eventLog[7] = 0x800000
15:32:25.869> eventLog[8] = 0x800000
15:32:25.869> eventLog[9] = 0x800000
15:32:25.869> eventLog[10] = 0x800000
15:32:25.869> eventLog[11] = 0x800000
15:32:25.869> eventLog[12] = 0x800000
15:32:25.869> eventLog[13] = 0x800000
15:32:25.869> eventLog[14] = 0x800000
15:32:25.869> eventLog[15] = 0x800000
15:32:25.869> eventLog[16] = 0x800000
15:32:25.869> eventLog[17] = 0x800000
15:32:25.869> eventLog[18] = 0x2000000000000000
15:32:25.869> eventLog[19] = 0x3
15:32:25.869> eventLog[20] = 0x810000
15:32:25.869> eventLog[21] = 0x810000
15:32:25.869> eventLog[22] = 0x810000
15:32:25.869> eventLog[23] = 0x810000
15:32:25.869> eventLog[24] = 0x810000
15:32:25.869> eventLog[25] = 0x810000
15:32:25.869> eventLog[26] = 0x810000
15:32:25.869> eventLog[27] = 0x810000
15:32:25.869> eventLog[28] = 0x810000
15:32:25.869> eventLog[29] = 0x810000
15:32:25.869> eventLog[30] = 0x810000
15:32:25.869> eventLog[31] = 0x810000
15:32:25.869> eventLog[32] = 0x810000
15:32:25.869> eventLog[33] = 0x810000
15:32:25.869> eventLog[34] = 0x810000
15:32:25.869> eventLog[35] = 0x810000
15:32:25.869> eventLog[36] = 0x810000
15:32:25.869> eventLog[37] = 0x810000
15:32:25.869> eventLog[38] = 0x2000000000000000
15:32:25.869> eventLog[39] = 0x3
15:32:25.869> eventLog[40] = 0x810000
15:32:25.869> eventLog[41] = 0x810000
15:32:25.869> eventLog[42] = 0x810000
15:32:25.869> eventLog[43] = 0x810000
15:32:25.869> eventLog[44] = 0x810000
15:32:25.869> eventLog[45] = 0x810000
15:32:25.869> eventLog[46] = 0x810000
15:32:25.869> eventLog[47] = 0x810000
15:32:25.869> eventLog[48] = 0x810000
15:32:25.869> eventLog[49] = 0x810000
15:32:25.869> eventLog[50] = 0x810000
15:32:25.869> eventLog[51] = 0x810000
15:32:25.869> eventLog[52] = 0x810000
15:32:25.869> eventLog[53] = 0x810000
15:32:25.869> eventLog[54] = 0x810000
15:32:25.869> eventLog[55] = 0x2000000000000000
15:32:25.869> eventLog[56] = 0x3
15:32:25.869> eventLog[57] = 0x400000
15:32:25.869> eventLog[58] = 0x3
15:32:33.995> Tx Loop Cntr = 3
15:32:34.681> TxterminationReason = 0x2, RF_cmdPropTxAdv.status = 0x3400
15:32:34.933> RxterminationReason = 0x2, SR_RF_cmdPropRx->status = 0x3801
15:32:34.933> eventLog[0] = 0x800000
15:32:34.933> eventLog[1] = 0x800000
15:32:34.933> eventLog[2] = 0x800000
15:32:34.933> eventLog[3] = 0x800000
15:32:34.933> eventLog[4] = 0x800000
15:32:34.933> eventLog[5] = 0x800000
15:32:34.933> eventLog[6] = 0x800000
15:32:34.933> eventLog[7] = 0x800000
15:32:34.933> eventLog[8] = 0x800000
15:32:34.933> eventLog[9] = 0x800000
15:32:34.933> eventLog[10] = 0x800000
15:32:34.933> eventLog[11] = 0x800000
15:32:34.933> eventLog[12] = 0x800000
15:32:34.933> eventLog[13] = 0x800000
15:32:34.933> eventLog[14] = 0x800000
15:32:34.933> eventLog[15] = 0x800000
15:32:34.933> eventLog[16] = 0x800000
15:32:34.933> eventLog[17] = 0x800000
15:32:34.933> eventLog[18] = 0x2000000000000000
15:32:34.933> eventLog[19] = 0x3
15:32:34.933> eventLog[20] = 0x810000
15:32:34.933> eventLog[21] = 0x810000
15:32:34.933> eventLog[22] = 0x810000
15:32:34.933> eventLog[23] = 0x810000
15:32:34.933> eventLog[24] = 0x810000
15:32:34.933> eventLog[25] = 0x810000
15:32:34.933> eventLog[26] = 0x810000
15:32:34.933> eventLog[27] = 0x810000
15:32:34.933> eventLog[28] = 0x810000
15:32:34.933> eventLog[29] = 0x810000
15:32:34.933> eventLog[30] = 0x810000
15:32:34.933> eventLog[31] = 0x810000
15:32:34.933> eventLog[32] = 0x810000
15:32:34.933> eventLog[33] = 0x810000
15:32:34.933> eventLog[34] = 0x810000
15:32:34.933> eventLog[35] = 0x810000
15:32:34.933> eventLog[36] = 0x810000
15:32:34.933> eventLog[37] = 0x810000
15:32:34.933> eventLog[38] = 0x2000000000000000
15:32:34.933> eventLog[39] = 0x3
15:32:34.933> eventLog[40] = 0x810000
15:32:34.933> eventLog[41] = 0x810000
15:32:34.933> eventLog[42] = 0x810000
15:32:34.933> eventLog[43] = 0x810000
15:32:34.933> eventLog[44] = 0x810000
15:32:34.933> eventLog[45] = 0x810000
15:32:34.933> eventLog[46] = 0x810000
15:32:34.933> eventLog[47] = 0x810000
15:32:34.933> eventLog[48] = 0x810000
15:32:34.933> eventLog[49] = 0x810000
15:32:34.933> eventLog[50] = 0x810000
15:32:34.933> eventLog[51] = 0x810000
15:32:34.933> eventLog[52] = 0x810000
15:32:34.933> eventLog[53] = 0x810000
15:32:34.933> eventLog[54] = 0x810000
15:32:34.933> eventLog[55] = 0x2000000000000000
15:32:34.933> eventLog[56] = 0x3
15:32:34.933> eventLog[57] = 0x400000
15:32:34.933> eventLog[58] = 0x3
15:32:34.933> eventLog[59] = 0x3
15:32:34.933> eventLog[60] = 0x400003
15:32:38.617> Tx Loop Cntr = 4
15:32:39.306> TxterminationReason = 0x2, RF_cmdPropTxAdv.status = 0x3400
15:32:39.493> RxterminationReason = 0x2, SR_RF_cmdPropRx->status = 0x3801
15:32:39.681> eventLog[0] = 0x800000
15:32:39.681> eventLog[1] = 0x800000
15:32:39.681> eventLog[2] = 0x800000
15:32:39.681> eventLog[3] = 0x800000
15:32:39.681> eventLog[4] = 0x800000
15:32:39.681> eventLog[5] = 0x800000
15:32:39.681> eventLog[6] = 0x800000
15:32:39.681> eventLog[7] = 0x800000
15:32:39.681> eventLog[8] = 0x800000
15:32:39.681> eventLog[9] = 0x800000
15:32:39.681> eventLog[10] = 0x800000
15:32:39.681> eventLog[11] = 0x800000
15:32:39.681> eventLog[12] = 0x800000
15:32:39.681> eventLog[13] = 0x800000
15:32:39.681> eventLog[14] = 0x800000
15:32:39.681> eventLog[15] = 0x800000
15:32:39.681> eventLog[16] = 0x800000
15:32:39.681> eventLog[17] = 0x800000
15:32:39.681> eventLog[18] = 0x2000000000000000
15:32:39.681> eventLog[19] = 0x3
15:32:39.681> eventLog[20] = 0x810000
15:32:39.681> eventLog[21] = 0x810000
15:32:39.681> eventLog[22] = 0x810000
15:32:39.681> eventLog[23] = 0x810000
15:32:39.681> eventLog[24] = 0x810000
15:32:39.681> eventLog[25] = 0x810000
15:32:39.681> eventLog[26] = 0x810000
15:32:39.681> eventLog[27] = 0x810000
15:32:39.681> eventLog[28] = 0x810000
15:32:39.681> eventLog[29] = 0x810000
15:32:39.681> eventLog[30] = 0x810000
15:32:39.681> eventLog[31] = 0x810000
15:32:39.681> eventLog[32] = 0x810000
15:32:39.681> eventLog[33] = 0x810000
15:32:39.681> eventLog[34] = 0x810000
15:32:39.681> eventLog[35] = 0x810000
15:32:39.681> eventLog[36] = 0x810000
15:32:39.681> eventLog[37] = 0x810000
15:32:39.681> eventLog[38] = 0x2000000000000000
15:32:39.681> eventLog[39] = 0x3
15:32:39.681> eventLog[40] = 0x810000
15:32:39.681> eventLog[41] = 0x810000
15:32:39.681> eventLog[42] = 0x810000
15:32:39.681> eventLog[43] = 0x810000
15:32:39.681> eventLog[44] = 0x810000
15:32:39.681> eventLog[45] = 0x810000
15:32:39.681> eventLog[46] = 0x810000
15:32:39.681> eventLog[47] = 0x810000
15:32:39.681> eventLog[48] = 0x810000
15:32:39.681> eventLog[49] = 0x810000
15:32:39.681> eventLog[50] = 0x810000
15:32:39.681> eventLog[51] = 0x810000
15:32:39.681> eventLog[52] = 0x810000
15:32:39.681> eventLog[53] = 0x810000
15:32:39.681> eventLog[54] = 0x810000
15:32:39.681> eventLog[55] = 0x2000000000000000
15:32:39.681> eventLog[56] = 0x3
15:32:39.681> eventLog[57] = 0x400000
15:32:39.681> eventLog[58] = 0x3
15:32:39.681> eventLog[59] = 0x3
15:32:39.681> eventLog[60] = 0x400003
15:32:39.681> eventLog[61] = 0x3
15:32:39.681> eventLog[62] = 0x400003

/*
 * Copyright (c) 2016-2017, 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 <stdio.h>

/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/runtime/Assert.h>

/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <ti/sysbios/knl/Task.h>

/* TI-RTOS Header files */
#include <ti/drivers/rf/RF.h>
#include <ti/drivers/PIN.h>
#include <ti/drivers/UART.h>

#include <ti/devices/DeviceFamily.h>
#include DeviceFamily_constructPath(driverlib/cpu.h)

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

/* Application Header files */
#include "RFQueue.h"

/* RF settings */
#include "smartrf_settings/smartrf_settings.h"

/***** Defines *****/
#define RX_ADVANCE_DUAL_SYNC    0
#define LOG_RADIO_EVENTS        1

#define UART_TX_BUFFER_SIZE     256
#define UART_RX_BUFFER_SIZE     256

/* Wake-on-Radio configuration */
#define WOR_WAKEUPS_PER_SECOND 2

/* TX number of random payload bytes */
#define PAYLOAD_LENGTH 30

/* WOR Example configuration defines */
#define WOR_PREAMBLE_TIME_RAT_TICKS(x) \
        ((uint32_t)(4000000*(1.0f/(x))))

/* TX task stack size and priority */
#define TX_TASK_STACK_SIZE 1024
#define TX_TASK_PRIORITY   2

/* RX task stack size and priority */
#define RX_TASK_STACK_SIZE 1024
#define RX_TASK_PRIORITY   2

/* TX 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 txTaskFunction(UArg arg0, UArg arg1);
static void initializeTxAdvCmdFromTxCmd(rfc_CMD_PROP_TX_ADV_t* RF_cmdPropTxAdv, rfc_CMD_PROP_TX_t* RF_cmdPropTx);

/***** Variable declarations *****/
/* TX task objects and task stack */
static Task_Params txTaskParams;
Task_Struct txTask;    /* not static so you can see in ROV */
static uint8_t txTaskStack[TX_TASK_STACK_SIZE];

/* Buffer which contains all Data Entries for receiving data.
 * Pragmas are needed to make sure this buffer is aligned to a 4 byte boundary
 * (requirement from the RF core)
 */
#pragma DATA_ALIGN(rxDataEntryBuffer, 4)
static uint8_t rxDataEntryBuffer[RF_QUEUE_DATA_ENTRY_BUFFER_SIZE(NUM_DATA_ENTRIES,
                                                                 MAX_LENGTH,
                                                                 NUM_APPENDED_BYTES)];
/* 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;

/* TX packet payload (length +1 to fit length byte) and sequence number */
static uint8_t packet[PAYLOAD_LENGTH +1];
static uint16_t seqNumber;

/* RF driver objects and handles */
static RF_Object rfObject;
static RF_Handle rfHandle = NULL;

/* Pin driver objects and handles */
static PIN_Handle ledPinHandle;
static PIN_Handle buttonPinHandle;
static PIN_State ledPinState;
static PIN_State buttonPinState;

/* TX Semaphore */
static Semaphore_Struct txSemaphore;
static Semaphore_Handle txSemaphoreHandle;

/* Advanced TX command for sending long preamble */
static rfc_CMD_PROP_TX_ADV_t RF_cmdPropTxAdv;

volatile uint8_t TxActive = 0;

/* UART driver handle*/
UART_Handle         SR_UART_Handle = NULL;
UART_Params         uartParams;

/*
 * Application LED pin configuration table:
 *   - All LEDs board LEDs are off.
 */
PIN_Config pinTable[] =
{
 Board_PIN_LED0 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
#if defined Board_CC1352R1_LAUNCHXL
 Board_DIO30_RFSW | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX,
#endif    
 PIN_TERMINATE
};

/*
 * Application button pin configuration table:
 *   - Buttons interrupts are configured to trigger on falling edge.
 */
PIN_Config buttonPinTable[] = {
                               Board_PIN_BUTTON0 | PIN_INPUT_EN | PIN_NOPULL | PIN_IRQ_NEGEDGE,
                               PIN_TERMINATE
};

#ifdef LOG_RADIO_EVENTS
static volatile RF_EventMask eventLog[255];
static volatile uint8_t evIndex = 0;
#endif // LOG_RADIO_EVENTS

/***** Function definitions *****/

//*****************************************************************************
// @brief     Configures UART and sets Uart Handler
// @param     None
// @return    return SUCCESS on success otherwise returns ERROR
//*****************************************************************************
int SR_UartInit(void)
{
    if(NULL == SR_UART_Handle)
    {
        UART_init();

        // Create a UART with data processing off.
        UART_Params_init(&uartParams);
        uartParams.readMode = UART_MODE_BLOCKING;
        uartParams.writeDataMode = UART_DATA_BINARY;
        uartParams.readDataMode = UART_DATA_BINARY;
        uartParams.readReturnMode = UART_RETURN_FULL;
        uartParams.readEcho = UART_ECHO_OFF;
        uartParams.baudRate = 115200;

        // Open an instance of the UART drivers
        SR_UART_Handle = UART_open(Board_UART0, &uartParams);

        if (SR_UART_Handle == NULL)
        {
            return -1;
        }
    }
    return 0;
}

//*****************************************************************************
// @brief     Deinitialize UART
// @param     None
// @return    return SUCCESS on success otherwise returns ERROR
//*****************************************************************************
void SR_UartDeInit(void)
{
    if(NULL != SR_UART_Handle)
    {
        UART_readCancel(SR_UART_Handle);
        UART_close(SR_UART_Handle);
        SR_UART_Handle = NULL;
    }
}

//*****************************************************************************
// @brief     Prints Given string to UART
// @param     Data Buffer
// @return    return SUCCESS on success otherwise returns ERROR
//*****************************************************************************
void SR_UartWriteString(char *l_BufUartTx)
{
    if(NULL != SR_UART_Handle)
    {
        UART_write(SR_UART_Handle, l_BufUartTx, strlen(l_BufUartTx));
    }
}

//*****************************************************************************
// @brief     UART write
// @param     Data Buffer, Data len
// @return    return SUCCESS on success otherwise returns ERROR
//*****************************************************************************
void SR_UartWriteBytes(char *l_BufUartTx, size_t l_BufLen)
{
    if(NULL != SR_UART_Handle)
    {
        UART_write(SR_UART_Handle, l_BufUartTx, l_BufLen);
    }
}

//*****************************************************************************
// @brief     UART write
// @param     Data Buffer, Data len
// @return    return SUCCESS on success otherwise returns ERROR
//*****************************************************************************
void SR_UartWriteHex(char *l_BufUartTx, size_t l_BufLen)
{
    if(NULL != SR_UART_Handle)
    {
        char l_Buf[4] = {0};

        uint32_t i;
        for(i = 0; i < l_BufLen; i++)
        {
            sprintf(l_Buf, "%02X.", l_BufUartTx[i]);
            UART_write(SR_UART_Handle, l_Buf, 3);
        }
    }
}

/* Pin interrupt Callback function board buttons configured in the pinTable. */
void buttonCallbackFunction(PIN_Handle handle, PIN_Id pinId) {

    /* Simple debounce logic, only toggle if the button is still pushed (low) */
    CPUdelay((uint32_t)((48000000/3)*0.050f));
    if (!PIN_getInputValue(pinId))
    {
        /* Post TX semaphore to TX task */
        if(rfHandle)
        {
            if(!TxActive)
            {
                TxActive = 1;

                uint8_t lu8_RF_Stat = RF_cancelCmd(rfHandle, RF_CMDHANDLE_FLUSH_ALL, 0x00);

                if(lu8_RF_Stat !=  RF_StatSuccess)
                {
                    // Error Handle
                    lu8_RF_Stat = 0; //Debug Breakpoint
                }
                Semaphore_post(txSemaphoreHandle);
            }

        }
    }
}


void rfCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
#ifdef LOG_RADIO_EVENTS
    eventLog[evIndex++ & 0xFF] = e;
#endif// LOG_RADIO_EVENTS
    if (e & RF_EventRxEntryDone)
    {
        /* Toggle pin to indicate RX */
        PIN_setOutputValue(ledPinHandle, Board_PIN_LED0,!PIN_getOutputValue(Board_PIN_LED0));

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

        RFQueue_nextEntry();
    }
}

/* TX task initialization function. Runs once from main() */
void 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);
}

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

    SR_UartWriteString("SR CC1310 Test App...\r\n");

    static char printBuff[512] = {0};
    uint32_t lu32_Cntr = 0;
    RF_EventMask TxterminationReason = 0, RxterminationReason = 0;


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

#if(RX_ADVANCE_DUAL_SYNC)
    rfc_CMD_PROP_RX_ADV_t * SR_RF_cmdPropRx = &RF_cmdPropRxAdv;
#else
    rfc_CMD_PROP_RX_t * SR_RF_cmdPropRx = &RF_cmdPropRx;
#endif

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

    if (!rfHandle) {
        /* 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);
    }

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

//    RF_cmdPropTxAdv.pNextOp = (rfc_radioOp_t *)SR_RF_cmdPropRx;
//    RF_cmdPropTxAdv.condition.rule = 0;

    /* Enter RX mode and stay forever in RX */
    RF_runCmd(rfHandle, (RF_Op*)SR_RF_cmdPropRx, RF_PriorityNormal, rfCallback, IRQ_RX_ENTRY_DONE);

    /* Enter main TX loop */
    while(1)
    {
        /* Wait for a button press */
        Semaphore_pend(txSemaphoreHandle, BIOS_WAIT_FOREVER);
        sprintf(printBuff, "Tx Loop Cntr = %u\r\n", lu32_Cntr++);
        SR_UartWriteString(printBuff);

        if(rfHandle != NULL)
        {
            /* Create packet with incrementing sequence number and random payload */
            packet[0] = PAYLOAD_LENGTH;
            packet[1] = (uint8_t)(seqNumber >> 8);
            packet[2] = (uint8_t)(seqNumber++);
            uint8_t i;
            for (i = 3; i < PAYLOAD_LENGTH +1; i++)
            {
                packet[i] = rand();
            }

            /* Send packet */
            TxterminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, rfCallback, 0xFFFFFFFF);

            sprintf(printBuff, "TxterminationReason = 0x%llx, RF_cmdPropTxAdv.status = 0x%04x\r\n", TxterminationReason , RF_cmdPropTxAdv.status);
            SR_UartWriteString(printBuff);

            TxActive = 0;

            /* Enter RX mode and stay forever in RX */
            RxterminationReason =  RF_runCmd(rfHandle, (RF_Op*)SR_RF_cmdPropRx, RF_PriorityNormal, rfCallback, 0xFFFFFFFF);

            sprintf(printBuff, "RxterminationReason = 0x%llx, SR_RF_cmdPropRx->status = 0x%04x\r\n", RxterminationReason, SR_RF_cmdPropRx->status);
            SR_UartWriteString(printBuff);

            if(0x3801 == SR_RF_cmdPropRx->status)
            {
                uint8_t i = 0;
                for(; i < evIndex; i++)
                {
                    sprintf(printBuff, "eventLog[%d] = 0x%llx\r\n", i, eventLog[i]);
                    SR_UartWriteString(printBuff);
                }
            }
            PIN_setOutputValue(ledPinHandle, Board_PIN_LED0,!PIN_getOutputValue(Board_PIN_LED0));
        }
    }
}

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

    SR_UartInit();

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

    /* Start BIOS */
    BIOS_start();

    return (0);
}

  • 0x3801 indicates that there is no RX buffer large enough for the received data available at the start of a packet. This can for example happen if you have not managed to empty the data entry, set it to IDLE again, etc. before the next packet comes along, and this again can be because your code is occupied with a higher priority interrupt for example.
    I would strongly recommend that you break down your code to try to figure out what is going on.
    Implement only RX, and see that this works In a stable manner over a longer period of time.
    When you are sure that this is OK, you can implement the interrupt that will cancel RX, and see that you get this to work. Next, implement TX.
    When everything works fine, add the UART code.
    Another thing, why are you setting the RF_EventMask to 0xFFFFFFFF?

    Siri
  • Thanks for quick reply.

    0x3801 indicates that there is no RX buffer large enough for the received data available at the start of a packet. Yes I found that info from forum but I am unable to find why that is happening. I am sending from "Module-A" using Smart RF Studio with 20 byte data length.

    As you can see from my code If I do not press button on Module-B it will stay in Rx Mode for forever. In this case even Smart RF studio packet interval is just 100ms LED toggles as expected on Module-B it never stops.

    Without UART same issue observed using LED as Rx feedback. I do not need UART code it is added to code for debug this issue.

    Regarding RF_EventMask to 0xFFFFFFFF , Earlier it was set to RF_EventRxEntryDone in Rx Mode Cmd and no callback registered on Tx Cmd same issue was observed in that case. For log every event from RF I have changed it to 0xFFFFFFFF so In log you can see what event is reported.


    I have changed Queue parameter,
    -----------------------------------------------------------
    Case 1:
    #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 */

    >> Issue Observed.
    -----------------------------------------------------------
    Case 2:
    #define MAX_LENGTH 128/* Max length byte the radio will accept */
    #define NUM_DATA_ENTRIES 20 /* NOTE: Only two data entries supported at the moment */

    >> Issue still persist
    -------------------------------------------------------------

    -----------------------------------------------------------

    On setting 1 sec packet interval in smart Rf studio

    >> Issue still persist
    -------------------------------------------------------------



    Requirement:
    This code is for mains power device which act as Gateway and other low power END device will be in WOR mode.
    So GW will always stays in normal Rx Mode(without WOR) and on any message from server It will change Its mode to WOR Tx and sends down-link message to End Device.
    On event in End Device will send Normal Tx message(without WOR) to GW.

    We require Dual Sync on GW Rx and I verfied it. Its working as expected.

    Can you verify RF CMD flow Or Prop CMD value? If is there any suggestion kindly let me know.

  • Code is working now after adding this lines in RF callback, Is it right way to handle Rx Cancel Cmd in terms of RFQueue Handling ?

     

    else if ((e & RF_EventLastCmdDone) || (e & RF_EventCmdStopped) || (e & RF_EventCmdAborted) || (e & RF_EventCmdCancelled))
        {
            RFQueue_getDataEntry();
            RFQueue_nextEntry();
        }


     

    /* Pin interrupt Callback function board buttons configured in the pinTable. */
    void buttonCallbackFunction(PIN_Handle handle, PIN_Id pinId) {
    
        /* Simple debounce logic, only toggle if the button is still pushed (low) */
        CPUdelay((uint32_t)((48000000/3)*0.050f));
        if (!PIN_getInputValue(pinId))
        {
            /* Post TX semaphore to TX task */
            if(rfHandle)
            {
                if(!TxActive)
                {
                    TxActive = 1;
    
                    uint8_t lu8_RF_Stat = RF_cancelCmd(rfHandle, RF_CMDHANDLE_FLUSH_ALL, 0x00);
    
                    if(lu8_RF_Stat !=  RF_StatSuccess)
                    {
                        // Error Handle
                        lu8_RF_Stat = 0; //Debug Breakpoint
                    }
                    Semaphore_post(txSemaphoreHandle);
                }
    
            }
        }
    }
    
    
    void rfCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
    {
    #ifdef LOG_RADIO_EVENTS
        eventLog[evIndex++ & 0xFF] = e;
    #endif// LOG_RADIO_EVENTS
        if (e & RF_EventRxEntryDone)
        {
            /* Toggle pin to indicate RX */
            PIN_setOutputValue(ledPinHandle, Board_PIN_LED0,!PIN_getOutputValue(Board_PIN_LED0));
    
            /* 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));
    
            RFQueue_nextEntry();
        }
        else if ((e & RF_EventLastCmdDone) || (e & RF_EventCmdStopped) || (e & RF_EventCmdAborted) || (e & RF_EventCmdCancelled))
        {
            RFQueue_getDataEntry();
            RFQueue_nextEntry();
        }
    }
    
    /* 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);
    
        SR_UartWriteString("SR CC1310 Test App...\r\n");
    
        static char printBuff[512] = {0};
        uint32_t lu32_Cntr = 0;
        RF_EventMask TxterminationReason = 0, RxterminationReason = 0;
    
    
        /* Initialize the radio */
        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);
        }
    
    #if(RX_ADVANCE_DUAL_SYNC)
        rfc_CMD_PROP_RX_ADV_t * SR_RF_cmdPropRx = &RF_cmdPropRxAdv;
    #else
        rfc_CMD_PROP_RX_t * SR_RF_cmdPropRx = &RF_cmdPropRx;
    #endif
    
        /* Modify CMD_PROP_RX command for application needs */
        SR_RF_cmdPropRx->pQueue = &dataQueue;           /* Set the Data Entity queue for received data */
        SR_RF_cmdPropRx->rxConf.bAutoFlushIgnored = 1;  /* Discard ignored packets from Rx queue */
        SR_RF_cmdPropRx->rxConf.bAutoFlushCrcErr = 1;   /* Discard packets with CRC error from Rx queue */
        SR_RF_cmdPropRx->maxPktLen = MAX_LENGTH;        /* Implement packet length filtering to avoid PROP_ERROR_RXBUF */
        SR_RF_cmdPropRx->pktConf.bRepeatOk = 1;
        SR_RF_cmdPropRx->pktConf.bRepeatNok = 1;
    
        if (!rfHandle) {
            /* 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);
        }
    
        /* 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);
    
    
        /* Enter RX mode and stay forever in RX */
        RF_runCmd(rfHandle, (RF_Op*)SR_RF_cmdPropRx, RF_PriorityNormal, rfCallback, IRQ_RX_ENTRY_DONE);
    
        /* Enter main TX loop */
        while(1)
        {
            /* Wait for a button press */
            Semaphore_pend(txSemaphoreHandle, BIOS_WAIT_FOREVER);
            sprintf(printBuff, "Tx Loop Cntr = %u\r\n", lu32_Cntr++);
            SR_UartWriteString(printBuff);
    
            if(rfHandle != NULL)
            {
                /* Create packet with incrementing sequence number and random payload */
                packet[0] = PAYLOAD_LENGTH;
                packet[1] = (uint8_t)(seqNumber >> 8);
                packet[2] = (uint8_t)(seqNumber++);
                uint8_t i;
                for (i = 3; i < PAYLOAD_LENGTH +1; i++)
                {
                    packet[i] = rand();
                }
    
                /* Send packet */
                TxterminationReason = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTxAdv, RF_PriorityNormal, NULL, 0);
    
                sprintf(printBuff, "TxterminationReason = 0x%llx, RF_cmdPropTxAdv.status = 0x%04x\r\n", TxterminationReason , RF_cmdPropTxAdv.status);
                SR_UartWriteString(printBuff);
    
                TxActive = 0;
    
                /* Enter RX mode and stay forever in RX */
                RxterminationReason =  RF_runCmd(rfHandle, (RF_Op*)SR_RF_cmdPropRx, RF_PriorityNormal, rfCallback, RF_EventRxEntryDone | RF_EventLastCmdDone | RF_EventCmdStopped | RF_EventCmdAborted | RF_EventCmdCancelled);
    
                sprintf(printBuff, "RxterminationReason = 0x%llx, SR_RF_cmdPropRx->status = 0x%04x\r\n", RxterminationReason, SR_RF_cmdPropRx->status);
                SR_UartWriteString(printBuff);
    
                if(0x3801 == SR_RF_cmdPropRx->status)
                {
                    uint8_t i = 0;
                    for(; i < evIndex; i++)
                    {
                        sprintf(printBuff, "eventLog[%d] = 0x%llx\r\n", i, eventLog[i]);
                        SR_UartWriteString(printBuff);
                    }
                }
                PIN_setOutputValue(ledPinHandle, Board_PIN_LED0,!PIN_getOutputValue(Board_PIN_LED0));
            }
        }
    }

  • Glad you were able to figure it out. I guess that it is necessary if the radio has detected a sync word and are in the process of filling the data entries when you abort the command.

    BR

    Siri