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.

CC2650 Trying to add Simple to Uart to Simple Peripheral Example

Other Parts Discussed in Thread: CC2650

I am trying to add a simple Uart capability to the SimplePerfipheral and not having much luck

If I add these Uart commands the code compiles OK but the Debug will not run

I have looked a the wiki examples

If I comment out the Uart open the application runs

I am using the SmartRF06 board and the 5XD EM board

1. Do I need the Uart init API ??

2. In the Uart Open API do a put Board_UART or just an index of 0 ??

What am I missing from this simple example ??

Thanks Much

Brian Donlan

/* UART Board */
#define Board_UART_RX                       IOID_1          /* RF1.7  */
#define Board_UART_TX                       IOID_0          /* RF1.9  */
#define Board_UART_CTS                      PIN_UNASSIGNED
#define Board_UART_RTS                      PIN_UNASSIGNED

 

UART_Handle handle;
UART_Params params;
uint8_t txBuf[]={"Hello_World"};

/*
 *  ======== main ========
 */
int main()
{

    // initialize I/O pins
    PIN_init(BoardGpioInitTable);

    //UART_init() ;

    UART_Params_init(&params);  // To initialize UART drivers
    params.baudRate=115200;
    params.writeDataMode=UART_DATA_BINARY;

    handle = UART_open(Board_UART,&params);

  • Hello Brian,

    The examples on the wiki use the default CC2650EM_7ID module's board file. Since you are using the 5XD module, did you configure your project to use that board file? Also, which wiki example did you try. Please be as specific as possible!

    Best wishes
  • Yes, I modified the project to use the 5XD module

    The basic application is working well without the Uart Enabled

    I looked at the Wiki examples

    Most of what I have came from the TI_RTOS echo example, which is not tailored to the CC2650

    I could not find the basic Uart setup code in the NPI and TL examples.

    Do you have a simple Uart setup example for the CC2650 ??

    Thanks very much
    Brian Donlan
  • Hi Brian,

    You should specifically look at this page (processors.wiki.ti.com/.../CC26xx_Serial_Communication). From there, click on the Transport Layer wiki which adds UART echo to SimpleBLEPeripheral. Try this out, and let me know if you have any questions
  • Thanks much

    I found the basic Uart setup routine

    I will study it tonight and try in the morning

    Thanks much

    Brian Donlan

    oid NPITLUART_initializeTransport(Char *tRxBuf, Char *tTxBuf, npiCB_t npiCBack)
    {
        UART_Params params;

        TransportRxBuf = tRxBuf;
        TransportTxBuf = tTxBuf;
        npiTransmitCB = npiCBack;

        // Configure UART parameters.
        UART_Params_init(&params);
        params.baudRate = NPI_UART_BR;
        params.readDataMode = UART_DATA_BINARY;
        params.writeDataMode = UART_DATA_BINARY;
        params.dataLength = UART_LEN_8;
        params.stopBits = UART_STOP_ONE;
        params.readMode = UART_MODE_CALLBACK;
        params.writeMode = UART_MODE_CALLBACK;
        params.readEcho = UART_ECHO_OFF;

        params.readCallback = NPITLUART_readCallBack;
        params.writeCallback = NPITLUART_writeCallBack;

        // Open / power on the UART.
        uartHandle = UART_open(Board_UART, &params);
        //Enable Partial Reads on all subsequent UART_read()
        UART_control(uartHandle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE,  NULL);

       
    #ifndef POWER_SAVING
        // This call will start repeated Uart Reads when Power Savings is disabled
        NPITLUART_readTransport();
    #endif //!POWER_SAVING
       
        return;
    }

    oid NPITLUART_initializeTransport(Char *tRxBuf, Char *tTxBuf, npiCB_t npiCBack)
    {
        UART_Params params;
    
        TransportRxBuf = tRxBuf;
        TransportTxBuf = tTxBuf;
        npiTransmitCB = npiCBack;
    
        // Configure UART parameters.
        UART_Params_init(&params);
        params.baudRate = NPI_UART_BR;
        params.readDataMode = UART_DATA_BINARY;
        params.writeDataMode = UART_DATA_BINARY;
        params.dataLength = UART_LEN_8;
        params.stopBits = UART_STOP_ONE;
        params.readMode = UART_MODE_CALLBACK;
        params.writeMode = UART_MODE_CALLBACK;
        params.readEcho = UART_ECHO_OFF;
    
        params.readCallback = NPITLUART_readCallBack;
        params.writeCallback = NPITLUART_writeCallBack;
    
        // Open / power on the UART.
        uartHandle = UART_open(Board_UART, &params);
        //Enable Partial Reads on all subsequent UART_read()
        UART_control(uartHandle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE,  NULL);
    
        
    #ifndef POWER_SAVING
        // This call will start repeated Uart Reads when Power Savings is disabled
        NPITLUART_readTransport();
    #endif //!POWER_SAVING
        
        return;
    }

  • Brian,

    You are correct that the above function opens the UART port and sets up the parameters. Remeber that our Network Processor Interface (NPI) is a fully scoped protocol that works with UART and SPI. It is intended to be called from an NPI task. I would advise against calling these functions in your main as it may throw off the internal state of the NPI layer. Instead, we have abstracted all this away for you: please read the wiki at processors.wiki.ti.com/.../Cc2640_Adding_a_UART_or_SPI_driver_to_a_Sample_Project

    The API for opening a UART port and sending data is described there. Specifically what you want to do is call:
    void TLinit(ICall_Semaphore *pAppSem, TLCBs_t *appCallbacks, uint16_t TX_DONE_EVENT, uint16_t RX_EVENT, uint16_t MRDY_EVENT)
  • Sean

    I was not able to get either of the NPI add ons to work

    They just add way to much stuff I did not need or want

    I did take bits and pieces and now have a very simple Uart working

    I would like to clean this up so you have a very simple Uart setup example

    Here is my primitive code that works

    I will next add a receiver and handlers

    Thanks much

    Brian Donlan

    Below are two lines to add to simple peripheral project

    SimpleUART_initialize(URxBuf, UTxBuf) ;

    I added this line to the periodic clock handler so it keeps printing

    Write_Hello() ;

    /******************************************************************************
    //! \file           Simple_uart.c
    //! \brief         Simple Module for UART
    //
    
    //******************************************************************************
    
    // ****************************************************************************
    // includes
    // ****************************************************************************
    #include <string.h>
    #include <xdc/std.h>
    #include <ti/sysbios/family/arm/m3/Hwi.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_ints.h"
    #include "ICall.h"
    #include "Board.h"
    #include "hal_types.h"
    #include <ti/sysbios/knl/Task.h>
    #include <ti/sysbios/knl/Swi.h>
    
    //#include "inc/npi_config.h"
    #include "Simple_uart.h"
    #include <ti/drivers/UART.h>
    #include <ti/drivers/uart/UARTCC26XX.h>
    
    // ****************************************************************************
    // defines
    // ****************************************************************************
    
    // ****************************************************************************
    // typedefs
    // ****************************************************************************
    
    //*****************************************************************************
    // globals
    //*****************************************************************************
    
    static UART_Handle uartHandle;
    
    
    //! \brief Pointer to NPI TL RX Buffer
    static Char* TransportTxBuf;
    
    //! \brief UART Object. Initialized in board specific files
    extern UARTCC26XX_Object uartCC26XXObjects[];
    
    
    // -----------------------------------------------------------------------------
    //! \brief      This routine initializes the transport layer and opens the port
    //!             of the device.
    //!
    //! \param[in]  tRxBuf - pointer to NPI TL Tx Buffer
    //! \param[in]  tTxBuf - pointer to NPI TL Rx Buffer
    //! \param[in]  npiCBack - NPI TL call back function to be invoked at the end of
    //!             a UART transaction
    //!
    //! \return     void
    // -----------------------------------------------------------------------------
    void SimpleUART_initialize(Char *tRxBuf, Char *tTxBuf)
    {
    	int tempstatus ;
    
        UART_Params params;
    
        //TransportRxBuf = tRxBuf;
        TransportTxBuf = tTxBuf;
    
        // Configure UART parameters.
        UART_Params_init(&params);
        params.baudRate = 9600;
        params.readDataMode = UART_DATA_BINARY;
        params.writeDataMode = UART_DATA_BINARY;
        params.dataLength = UART_LEN_8;
        params.stopBits = UART_STOP_ONE;
        //params.readMode = UART_MODE_CALLBACK;
        //params.writeMode = UART_MODE_CALLBACK;
        params.readEcho = UART_ECHO_OFF;
    
        //params.readCallback = NPITLUART_readCallBack;
        //params.writeCallback = NPITLUART_writeCallBack;
    
        // Open / power on the UART.
        uartHandle = UART_open(Board_UART, &params);
        //Enable Partial Reads on all subsequent UART_read()
        UART_control(uartHandle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE,  NULL);
    
    
        tempstatus =  UART_write(uartHandle, TransportTxBuf, 13) ;
    
        return;
    }
    
    void Write_Hello(void)
    {
    	int tempstatus ;
    
    	  tempstatus =  UART_write(uartHandle, TransportTxBuf, 13) ;
    }
    

  • Hi Brian! 

    I am currently working with CC2650 BLE module and I have configured it as a Peripheral + Observer. I plan on retrieving the AdvData of beacons that are received and sending this data to PC using UART. For this, I require a UART setup. 

    I have managed to write a code similar to yours, however one thing is missing.

    For the UART communication to work, the UART init() must be called. And for UART_init() to work, UART_Config must be initialized. I am having difficulty in initializing UART_Config. Could you help me out and tell me how you did it?

    Thank you in advance!