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-CC1350: Transmit UART data over the air

Part Number: LAUNCHXL-CC1350

Tool/software: TI-RTOS

Hello All,

I want to transmit UART data over the air using sub-1GHZ. What changes I need to make in packet configuration of TX and Rx so that i can transmit uart data.

Thanks

shubham 

  • Hello Shubham,
    You can start with RF packet Tx example and add UART Echo example. You can then add a semaphore that will pend the Tx task. This semaphore can be posted once the UART data is ready. You can refer to the code posted here e2e.ti.com/.../2112785
    Regards,
    Prashanth
  • Hello Sir,

    Thanks for the reply but the file is not working after making changes. I am uploading the file over here. Can you please check and suggest necessary changes that are  required. The led is not blinking which shows the status of packets.

    2148.rfPacketTx.c
    /*
     * 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/runtime/System.h>
    #include <xdc/cfg/global.h>
    
    
    #include <ti/sysbios/BIOS.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/knl/Task.h>
    
    /* Drivers */
    #include <ti/drivers/rf/RF.h>
    #include <ti/drivers/PIN.h>
    #include <ti/drivers/UART.h>
    
    
    /* Board Header files */
    #include "Board.h"
    
    #include "smartrf_settings/smartrf_settings.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_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        PIN_TERMINATE
    };
    
    
    /***** Defines *****/
    #define TX_TASK_STACK_SIZE 1024
    #define TX_TASK_PRIORITY   2
    
    #define UART_TX_TASK_STACK_SIZE 1024
    #define UART_TX_TASK_PRIORITY   4
    
    /* ASCII values of some useful keys */
    #define CHAR_LINEFEED                         0x0A
    #define CHAR_LINE_END_1                       0x0D   // Enter
    #define CHAR_LINE_END_2                       0x03   // Enter on numpad
    #define CHAR_SPACE                            0x20
    #define CHAR_ZERO                             0x30
    #define CHAR_UPPERCASE_START                  0x40
    
    
    /* Packet TX Configuration */
    #define PAYLOAD_LENGTH      30
    #define PACKET_INTERVAL     (uint32_t)(4000000*0.5f) /* Set packet interval to 500ms */
    
    
    
    /***** Prototypes *****/
    static void txTaskFunction(UArg arg0, UArg arg1);
    static void uartTxTaskFunction(UArg arg0, UArg arg1);
    
    
    
    /***** Variable declarations *****/
    static Task_Params txTaskParams;
    Task_Struct txTask;    /* not static so you can see in ROV */
    static uint8_t txTaskStack[TX_TASK_STACK_SIZE];
    
    static Task_Params uartTxTaskParams;
    Task_Struct uartTxTask;    /* not static so you can see in ROV */
    static uint8_t uartTxTaskStack[UART_TX_TASK_STACK_SIZE];
    
    Semaphore_Struct semTxStruct;
    Semaphore_Handle semTxHandle;
    
    
    static RF_Object rfObject;
    static RF_Handle rfHandle;
    static RF_CmdHandle rfRxCmd;
    static RF_CmdHandle rfTxCmd;
    
    
    UART_Handle uart = NULL;
    UART_Params uartParams;
    
    
    uint32_t time;
    uint8_t packetReady = 0;
    
    static uint8_t txPacket[PAYLOAD_LENGTH];
    //static uint16_t seqNumber;
    static PIN_Handle pinHandle;
    
    
    /***** Function definitions *****/
    
    
    void UartTxTask_init(PIN_Handle ledPinHandle) {
        pinHandle = ledPinHandle;
    
        Task_Params_init(&uartTxTaskParams);
        uartTxTaskParams.stackSize = UART_TX_TASK_STACK_SIZE;
        uartTxTaskParams.priority = UART_TX_TASK_PRIORITY;
        uartTxTaskParams.stack = &uartTxTaskStack;
        uartTxTaskParams.arg0 = (UInt)1000000;
    
        Task_construct(&uartTxTask, uartTxTaskFunction, &uartTxTaskParams, NULL);
    }
    
    
    
    #define UART_TX_BUFFER_SIZE 256
    char uartTxBuffer[UART_TX_BUFFER_SIZE];
    
    static void uartTxTaskFunction(UArg arg0, UArg arg1)
    {
        char input;
        uint8_t charIndex;
    
        /* Open UART if not already open */
        if (uart == NULL) {
            /* Create a UART with data processing off. */
            UART_Params_init(&uartParams);
            uartParams.writeDataMode = UART_DATA_BINARY;
            uartParams.readDataMode = UART_DATA_BINARY;
            uartParams.readReturnMode = UART_RETURN_FULL;
            uartParams.readEcho = UART_ECHO_OFF;
            uartParams.baudRate = 115200;
            uart = UART_open(Board_UART0, &uartParams);
    
            if (uart == NULL) {
                System_abort("Error opening the UART");
            }
        }
    
        while (1) {
    
            UART_read(uart, &input, 1);
    
            /* Skip the line feed that appears after an enter as the first character of new line */
            if (input == (char)CHAR_LINEFEED)
                charIndex--;
    
    
            if ((input == (char)CHAR_LINE_END_1) | (input == (char)CHAR_LINE_END_2)) // (charIndex < UART_SERIAL_LINE_SIZE))
            {
    
                /* Cancel Rx */
                RF_cancelCmd(rfHandle, rfRxCmd, 0);
                Semaphore_post(semTxHandle);
                /* reset index to zero to point to begining of the line */
                charIndex = 0;
            }
            else
            {
                /* Store the input character */
                //uartTxBuffer[charIndex++] = input;
                txPacket[charIndex++] = input;
            }
    
        }
    }
    
    void TxTask_init(PIN_Handle inPinHandle)
    {
        pinHandle = inPinHandle;
    
        Task_Params_init(&txTaskParams);
        txTaskParams.stackSize = TX_TASK_STACK_SIZE;
        txTaskParams.priority = TX_TASK_PRIORITY;
        txTaskParams.stack = &txTaskStack;
        txTaskParams.arg0 = (UInt)1000000;
    
        Task_construct(&txTask, txTaskFunction, &txTaskParams, NULL);
    }
    
    
    static void txTaskFunction(UArg arg0, UArg arg1)
    {
        uint32_t time;
        RF_Params rfParams;
        RF_Params_init(&rfParams);
    
        RF_cmdPropTx.pktLen = PAYLOAD_LENGTH;
        RF_cmdPropTx.pPkt = txPacket;
        RF_cmdPropTx.startTrigger.triggerType = TRIG_ABSTIME;
        RF_cmdPropTx.startTrigger.pastTrig = 1;
        RF_cmdPropTx.startTime = 0;
    
        while(1)
            {
                Semaphore_pend(semTxHandle, BIOS_WAIT_FOREVER);
    
                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);
                }
    
        /* 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);
    
        /* Get current time */
        time = RF_getCurrentTime();
    /*    while(1)
        {
            /* Create packet with incrementing sequence number and random payload */
      /*      packet[0] = (uint8_t)(seqNumber >> 8);
            packet[1] = (uint8_t)(seqNumber++);
            uint8_t i;
            for (i = 2; i < PAYLOAD_LENGTH; i++)
            {
                packet[i] = rand();
            } */
    
            /* Set absolute TX time to utilize automatic power management */
            time += PACKET_INTERVAL;
            RF_cmdPropTx.startTime = time;
    
            /* Send packet */
    //        RF_EventMask result = RF_runCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
    
            rfTxCmd = RF_postCmd(rfHandle, (RF_Op*)&RF_cmdPropTx, RF_PriorityNormal, NULL, 0);
    
            RF_EventMask result = RF_pendCmd(rfHandle, rfTxCmd, (RF_EventCmdDone | RF_EventCmdError | RF_EventLastCmdDone |
                    RF_EventCmdAborted | RF_EventCmdCancelled | RF_EventCmdStopped));
    
    
    
    
            if (!(result & RF_EventLastCmdDone))
            {
                /* Error */
                while(1);
            }
    
            PIN_setOutputValue(pinHandle, Board_LED1,!PIN_getOutputValue(Board_LED1));
    
            /* clear txPacket buffer */
            memset(txPacket, 0, sizeof(txPacket));
        }
    }
    
    /*
     *  ======== main ========
     */
    int main(void)
    {
        Semaphore_Params semParams;
    
        /* Call board init functions. */
        Board_initGeneral();
    //    Board_initUart();
        Board_initUART();
    
        /* Open LED pins */
        ledPinHandle = PIN_open(&ledPinState, pinTable);
        if(!ledPinHandle)
        {
            System_abort("Error initializing board LED pins\n");
        }
    
        /* Construct a Semaphore object to be used as a resource lock, inital count 0 */
        Semaphore_Params_init(&semParams);
        Semaphore_construct(&semTxStruct, 0, &semParams);
        semTxHandle = Semaphore_handle(&semTxStruct);
    
    
        /* Initialize task */
        TxTask_init(ledPinHandle);
        UartTxTask_init(ledPinHandle);
    
        /* Start BIOS */
        BIOS_start();
    
        return (0);
    }
    

  • Hello Shubham, 

    The Tx is initiated after you type in few characters ( less than 30 characters) on the UART and hit enter. If there is no carriage return then there is no Tx. The LED toggles after every time you hit enter indicating transmission. 

    Also please make sure you are connecting the correct UART port (Check device manager, ports and pick XDS110 Class Application.User UART). Set buad rate to 115200 and enable local echo. 

    Regards,

    Prashanth

  • Hello Sir,
    Still I am not able to do it. After following all the steps, Nothing is happening. From the last four days, I am stuck at this program. Please suggest some alternative sir.
    Thank you
  • What is the potential volume for your project?
  • Potential volume will be in 100
    thanks