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.

CCS/CC2640R2F: how to add uart to a project ?

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC3220SF

Tool/software: Code Composer Studio

hi there

i am new to TI SDK and hope that i get help. Having a project using BLE that compiles files with IAR. I need to add uart logging to it and i dont know how. I would appreciate if somebody have this experience to help me. Over the past couple of days, i was trying with different approaches with no sucess.

Please help me step by step

thank you in advance

regards,

Sherif

  • Sherif,

    I suggest you look into SimpleLink Academy to start out with the CC2640R2F and the SimpeLink SDK.

    dev.ti.com/.../

    SimpleLink™ Academy provides a comprehensive set of training tools that allow users from beginners to experienced developers to learn about the SimpleLink MCU Platform. The academy delivers training modules that span a breadth of topics including fundamental SDK components such as an introduction to TI-RTOS and leading up to 'Getting Started' labs for all products in the SimpleLink MCU family. It is intended to be used by anyone wanting to get familiar with the SimpleLink MCU SDK of their choice and the development boards and tools associated with it.

    Also, with regards to your specific concern, you will find that many of our examples in the SDK as well as the labs in SimpleLink Academy include something called the Display driver. You can find information and API's on that driver and many others here.
    dev.ti.com/.../index.html
  • Hi Sherif,

    I suggest you see the uart doxygen documentation in the SDK folders. You can try the example UART codes there.

    -kel
  • dear community

    please don't give me ridiculous, misleading, improper answers, i am aware of the sdk and i am working with it. My question is clear, i need to add uart debug logs to a project using IAR, please give me a step by step guide. if you don't know the answer, please don't comment.

    thank you
  • hi Kel,
    i tried to import many of them but for some reason, they don't work. I don't get the log into the uart.
  • dear community

    please don't give me ridiculous, misleading, improper answers, i am aware of the sdk and i am working with it. My question is clear, i need to add uart debug logs to a project using IAR, please give me a step by step guide. if you don't know the answer, please don't comment.

    thank you
  • Hi Sherif,

         If uart debugs only you can use Display_printf(). You can see sample use at i2ctmp006 example program located at "C:\ti\simplelink_cc32xx_sdk_2_10_00_04\examples\rtos\CC3220SF_LAUNCHXL\drivers\i2ctmp006"

         Here below is code snippet using Display_printf()

    /*
     *    ======== i2ctmp006.c ========
     */
    #include <stdint.h>
    #include <stddef.h>
    #include <unistd.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/I2C.h>
    #include <ti/display/Display.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    static Display_Handle display;
    
    #define TMP006_DIE_TEMP     0x0001  /* Die Temp Result Register */
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        unsigned int    i;
        uint16_t        temperature;
        uint8_t         txBuffer[1];
        uint8_t         rxBuffer[2];
        I2C_Handle      i2c;
        I2C_Params      i2cParams;
        I2C_Transaction i2cTransaction;
    
        /* Call driver init functions */
        Display_init();
        GPIO_init();
        I2C_init();
    
        /* Configure the LED pin */
        GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
    
        /* Open the HOST display for output */
        display = Display_open(Display_Type_UART, NULL);
        if (display == NULL) {
            while (1);
        }
    
        /* Turn on user LED */
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
        Display_printf(display, 0, 0, "Starting the i2ctmp006 example\n");
    
        /* Create I2C for usage */
        I2C_Params_init(&i2cParams);
        i2cParams.bitRate = I2C_400kHz;
        i2c = I2C_open(Board_I2C_TMP, &i2cParams);
        if (i2c == NULL) {
            Display_printf(display, 0, 0, "Error Initializing I2C\n");
            while (1);
        }
        else {
            Display_printf(display, 0, 0, "I2C Initialized!\n");
        }

    -kel

  • Hi Sherif,

         Disregard my previous reply. See, sample Display_printf() use at i2ctmp007 example program located at "C:\ti\simplelink_cc2640r2_sdk_1_50_00_58\examples\rtos\CC2640R2_LAUNCHXL\drivers\i2ctmp007"

         Here is code snippet below.

    /*
     *    ======== i2ctmp007.c ========
     */
    #include <stdint.h>
    #include <stddef.h>
    #include <unistd.h>
    
    /* Driver Header files */
    #include <ti/drivers/GPIO.h>
    #include <ti/drivers/I2C.h>
    #include <ti/display/Display.h>
    
    /* Example/Board Header files */
    #include "Board.h"
    
    #define TASKSTACKSIZE       640
    
    #define TMP007_DIE_TEMP     0x0001  /* Die Temp Result Register */
    #define TMP007_OBJ_TEMP     0x0003  /* Object Temp Result Register */
    
    static Display_Handle display;
    
    /*
     *  ======== mainThread ========
     */
    void *mainThread(void *arg0)
    {
        unsigned int    i;
        uint16_t        temperature;
        uint8_t         txBuffer[1];
        uint8_t         rxBuffer[2];
        I2C_Handle      i2c;
        I2C_Params      i2cParams;
        I2C_Transaction i2cTransaction;
    
        /* Call driver init functions */
        Display_init();
        GPIO_init();
        I2C_init();
    
        /* Open the HOST display for output */
        display = Display_open(Display_Type_UART, NULL);
        if (display == NULL) {
            while (1);
        }
    
        /* Turn on user LED */
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
        Display_printf(display, 0, 0, "Starting the i2ctmp007 example\n");
    
        /* Create I2C for usage */
        I2C_Params_init(&i2cParams);
        i2cParams.bitRate = I2C_400kHz;
        i2c = I2C_open(Board_I2C_TMP, &i2cParams);
        if (i2c == NULL) {
            Display_printf(display, 0, 0, "Error Initializing I2C\n");
            while (1);
        }
        else {
            Display_printf(display, 0, 0, "I2C Initialized!\n");
        }

    -kel

  • thank you for the comment, I have a compiler error in #include <unistd.h>, I am using IAR
  • Hi Sherif,

    Maybe you do not need it so just comment it out. Also I suggest you use the simple peripheral from latest SDK version as base for whatever you are doing. That is if you need BLE. At simple peripheral there is already Display_open(). You just need to set Display_open() parameter "Display_Type_UART".

    Also at end product normally logging to UART is disabled because it consumes current.

    -kel
  • Sherif,

    With regards to your need for UART Debug logs, can you describe why Display_printf() won't work for your application? In all of our sample applications (simple_peripheral for example), there is a UART debug log occuring thorughout the program. This is done via the Display driver that I mentioned in my first post.

    In simple_peripheral, you can see how it's first includeded via:
    #include <ti/display/Display.h>

    And then there are some #defines that define which Board Display to be used. You can later specify to use Display_Type_UART as Kel has mentioned in posts above.

    Create a handle:
    // Display Interface
    Display_Handle dispHandle = NULL;

    This handle is used along with the Display Type to open the driver.
    dispHandle = Display_open(SBP_DISPLAY_TYPE, NULL);

    Then it's a matter of calling the various Display_print API's
    Display_print0(dispHandle, 2, 0, "Initialized");
    Display_print1(dispHandle, 2, 0, "Num Conns: %d", (uint16_t)numActive);
    etc.

    dev.ti.com/.../index.html

    The specific Display Driver API page has a ton more about how to use it with the various display options, including UART
    dev.ti.com/.../_display_8h.html

    This doesn't matter if you are using IAR or CCS. It's tested on both platforms.

    This lab may be of use as well:
    dev.ti.com/.../

    Please let us know if this doesn't meet your needs.

  • thank you guys for your comments, however, the display_print 0 prints at a certain line, but i need it to be continuous in a log format. I am using simple_peripheral. How can i do it?
  • In order to receive packets as a log, disable the ANSI interface for the UART Driver. Do this by right clicking the project > properties > build > ARM compiler > predefined symbols > set BOARD_DISPLAY_USE_UART_ANSI = 0.