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/CC3220SF-LAUNCHXL: UART_read function reads from terminal window, but not from another development board

Intellectual 375 points

Replies: 5

Views: 311

Part Number: CC3220SF-LAUNCHXL

Tool/software: TI-RTOS

Hi everyone!

Problem statement

I have a problem with reading bytes from UART. I can successfully write data, but I can't read. It's twice strange, because communication worked several times and bytes were received while reading, but it was another program, modified "portable" example, but it was like a lottery, sometimes it worked, sometimes not.

In my test case I expect LED toggling by pressing a button of adjacent board. This board should write one byte to UART, and another one should read this byte from UART. Also their own LED toggle by pressing own buttons. When I press button on a board, its own LED toggles, one byte sends to UART, but another board read nothing for some reason. If I open a terminal windows on PC, connected to development boards throw USB, I will be able to send an appropriate byte to there and these board read them successfully, and hence their LEDs will be toggle. Also I can see this byte read by terminal windows when I push buttons.

Please, indicate possible problems with my configuration and code. I need to arrange UART connection with sending and receiving data between boards, not with terminal windows. I will be very appreciated for any help.

Hardware settings

I set up CC3220SF-LAUNCHXL to LAUNCHXL-CC3235SF connection by UART without flow control (RTS/CTS). And what I did for that, I connected devices something like that:

GND           <->    GND
TX (Pin 3)    <->    RX (Pin 4)
RX (Pin 4)    <->    TX (Pin 3)

You can visually see my configuration on photos:



Software settings

I utilize modified your TI Drivers "uartecho" example. I modified "uartecho.c" in this manner (the same code for both boards):

/*
 *  ======== uartecho.c ========
 */
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

/* Driver Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/UART.h>

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


bool gpio_led0_on = false;
bool flag_send_msgByte = false;


void gpioButtonFxn1(uint_least8_t index) {
    flag_send_msgByte = true;

    /* Toggle LED state */
    gpio_led0_on = (gpio_led0_on == true) ? false : true;
}


/*
 *  ======== mainThread ========
 */
void *mainThread(void *arg0)
{
    char        input;
    const char  msgByte = '@';
    UART_Handle uartHandle;
    UART_Params uartParams;

    /* Call driver init functions */
    GPIO_init();
    UART_init();

    /* Configure the LED pin */
    GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);

    /* Turn on user LED */
    GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);

    /* install Button callback */
    GPIO_setCallback(Board_GPIO_BUTTON1, gpioButtonFxn1);

    /* Enable interrupts */
    GPIO_enableInt(Board_GPIO_BUTTON1);

    /* 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;
    uartParams.readTimeout = 1000;  // 1 second

    uartHandle = UART_open(Board_UART0, &uartParams);
    if (uartHandle == NULL) {
        /* UART_open() failed */
        while (1);
    }

    /* Loop forever echoing */
    while (1)
    {
        /* Switch LED to appropriate state */
        if (gpio_led0_on)
        {
            GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
        }
        else
        {
            GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
        }

        /* Send msgByte to UART */
        if (flag_send_msgByte)
        {
            UART_write(uartHandle, &msgByte, 1);
            flag_send_msgByte = false;
        }

        /* Waiting for msgByte from UART */
        UART_read(uartHandle, &input, 1);
        if (input == msgByte)
        {
            /* Toggle LED state */
            gpio_led0_on = (gpio_led0_on == true) ? false : true;
        }
    }
}

Also I set up UART pins in "UART configuration structure" of "CC3220SF_LAUNCHXL.c" (similarly for "CC3235SF_LAUNCHXL.c") file like so:

/* UART configuration structure */
const UARTCC32XX_HWAttrsV1 uartCC3235SHWAttrs[CC3235SF_LAUNCHXL_UARTCOUNT] = {
    {
        .baseAddr = UARTA0_BASE,
        .intNum = INT_UARTA0,
        .intPriority = (~0),
        .flowControl = UARTCC32XX_FLOWCTRL_NONE,
        .ringBufPtr  = uartCC3235SRingBuffer[CC3235SF_LAUNCHXL_UART0],
        .ringBufSize = sizeof(uartCC3235SRingBuffer[CC3235SF_LAUNCHXL_UART0]),
        .rxPin = UARTCC32XX_PIN_04_UART0_RX,
        .txPin = UARTCC32XX_PIN_03_UART0_TX,
        .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
        .rtsPin = UARTCC32XX_PIN_UNASSIGNED,
        .errorFxn = NULL
    },
    {
        .baseAddr = UARTA1_BASE,
        .intNum = INT_UARTA1,
        .intPriority = (~0),
        .flowControl = UARTCC32XX_FLOWCTRL_NONE,
        .ringBufPtr  = uartCC3235SRingBuffer[CC3235SF_LAUNCHXL_UART1],
        .ringBufSize = sizeof(uartCC3235SRingBuffer[CC3235SF_LAUNCHXL_UART1]),
        .rxPin = UARTCC32XX_PIN_57_UART1_RX,
        .txPin = UARTCC32XX_PIN_55_UART1_TX,
        .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
        .rtsPin = UARTCC32XX_PIN_UNASSIGNED,
        .errorFxn = NULL
    }
};



5 Replies

  • Roman,

    What is reason for the resistors on your UART lines?

    VR
  • In reply to Vincent Rodriguez:

    Good evening, Vincent!

    Thanks for you answer. They are not very high-power resistors. These are just 470 Ohm. I can't say actual intention of these resistors right now. And unfortunately, I will be able to exactly know that from engineers on Monday. I didn't write in my post, but we physically checked signals by an oscilloscope. TX pins correctly produce signals and these signals come to RX pins. It seems like on physical layer everything works fine. Signals really come to RX pins. As I understand, that's the reason, why you asked me about extra resistors, wasn't it?

    Regards,

    Roman

  • In reply to Vincent Rodriguez:

    We have removed these resistors from UART lines and tried again. The result was the same, nothing changed, unfortunately.

    Regards,
    Roman

  • If I use another UART pins setting in "UART configuration structure" of "CC32XXSF_LAUNCHXL.c" file and "Board_UART1" instead of "Board_UART0" in "uartecho.c", then everything works well. See below.

    In "uartecho.c" file one string has changed, I use "Board_UART1" instead of "Board_UART0":

    uartHandle = UART_open(Board_UART1, &uartParams);

    In "CC32XXSF_LAUNCHXL.c" file "UART configuration structure" has changed, now I use other pins for UARTs:

    /* UART configuration structure */
    const UARTCC32XX_HWAttrsV1 uartCC3235SHWAttrs[CC3235SF_LAUNCHXL_UARTCOUNT] = {
        {
            .baseAddr = UARTA0_BASE,
            .intNum = INT_UARTA0,
            .intPriority = (~0),
            .flowControl = UARTCC32XX_FLOWCTRL_NONE,
            .ringBufPtr  = uartCC3235SRingBuffer[CC3235SF_LAUNCHXL_UART0],
            .ringBufSize = sizeof(uartCC3235SRingBuffer[CC3235SF_LAUNCHXL_UART0]),
            .rxPin = UARTCC32XX_PIN_57_UART0_RX,
            .txPin = UARTCC32XX_PIN_55_UART0_TX,
            .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
            .rtsPin = UARTCC32XX_PIN_UNASSIGNED,
            .errorFxn = NULL
        },
        {
            .baseAddr = UARTA1_BASE,
            .intNum = INT_UARTA1,
            .intPriority = (~0),
            .flowControl = UARTCC32XX_FLOWCTRL_NONE,
            .ringBufPtr  = uartCC3235SRingBuffer[CC3235SF_LAUNCHXL_UART1],
            .ringBufSize = sizeof(uartCC3235SRingBuffer[CC3235SF_LAUNCHXL_UART1]),
            .rxPin = UARTCC32XX_PIN_08_UART1_RX,
            .txPin = UARTCC32XX_PIN_07_UART1_TX,
            .ctsPin = UARTCC32XX_PIN_UNASSIGNED,
            .rtsPin = UARTCC32XX_PIN_UNASSIGNED,
            .errorFxn = NULL
        }
    };

    I connected my devices in the following way:

    GND           <->    GND
    TX (Pin 7)    <->    RX (Pin 8)
    RX (Pin 8)    <->    TX (Pin 7)

    I removed resistors in this case to confuse no one. But in previous configuration I also tried without them, it didn't help. You can visually see my new pin connections on the photo below:

    I would like to work out the problem for myself, how to reassign pins for communication interfaces. What should I configure to assign UART interface by pin 3 and pin 4 (not pin 7 and pin 8), as I mentioned in my initial question?

    Regards,
    Roman

  • In reply to Roman Alexeev:

    Roman,

    Pin 04 is also being used by SW2, which has a pulldown Resistor of 10k on the line. There then could be a few things going on here. 1. ) You are using that SW2, and are trying to figure a pin to two different modes. 2. ) That pulldown is effecting your UART signal.

    I would suggest making sure that you are not configuring that switch in your example, and de-solder R141 and see if that helps.

    Best Regards,
    VInce

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.