# UART Communication with PuTTY

I am struggling to understand how to work with UART interface between microcontrollers. I don't know if this happens because I can't understand how it works or because I manipulate it in a wrong way. In any case,I try to be hands on ,trying to understand how it works quickly and get the taste of it but so far I am unsuccessful.I have read several tutorials about the "theory" but I am having difficulties being hands-on.

Here is what I am trying to do: I have a MCU (CC1310 on a launchpad) with a UART port. I try to see if I can make this MCU talk to my PC first by sending some data. Later I need to make this MCU talk with another MCU.

First, I have to mention that this launchpad has a XDS 1100 Debugger linked to the computer via USB.There are some jumpers on the board with RX TX so I suppose this allows the XDS110 to act as FTDI converter USB to UART directly via a USB port (I also have a special cable from Prolific to probe signals without going through the debugger).

In Code Composer Studio, I have imported and built a project named uart_echo for the CC1310. I found this example in Ti Resources Explorer. I managed to build the project (as I didn't change anything and this code was written by Texas Instruments) and load it into the chip by using the debugging button.

The code in this file is the following:

    /*
* Copyright (c) 2015-2016, Texas Instruments Incorporated
*
* 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.
*/

/*
*  ======== uartecho.c ========
*/

#include <xdc/std.h>
#include <xdc/runtime/System.h>

#include <ti/sysbios/BIOS.h>

#include <ti/drivers/PIN.h>
#include <ti/drivers/UART.h>

#include "Board.h"

#include <stdint.h>

/* Global memory storage for a PIN_Config table */
static PIN_State ledPinState;

/*
* Application LED pin configuration table:
*   - All LEDs board LEDs are off.
*/
PIN_Config ledPinTable[] = {
Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
PIN_TERMINATE
};

/*
*  ======== echoFxn ========
*  Task for this function is created statically. See the project's .cfg file.
*/
Void echoFxn(UArg arg0, UArg arg1)
{
char input;
UART_Handle uart;
UART_Params uartParams;
const char echoPrompt[] = "\fEchoing characters:\r\n";

/* Create a UART with data processing off. */
UART_Params_init(&uartParams);
uartParams.writeDataMode = UART_DATA_BINARY;
uartParams.baudRate = 9600;
uart = UART_open(Board_UART0, &uartParams);

if (uart == NULL) {
System_abort("Error opening the UART");
}

UART_write(uart, echoPrompt, sizeof(echoPrompt));

/* Loop forever echoing */
while (1) {
UART_write(uart, &input, 1);
}
}

/*
*  ======== main ========
*/
int main(void)
{
PIN_Handle ledPinHandle;

/* Call board init functions */
Board_initGeneral();
Board_initUART();

/* Construct BIOS objects */

/* Open LED pins */
ledPinHandle = PIN_open(&ledPinState, ledPinTable);
if(!ledPinHandle) {
System_abort("Error initializing board LED pins\n");
}

PIN_setOutputValue(ledPinHandle, Board_LED1, 1);

/* This example has logging and many other debug capabilities enabled */
System_printf("This example does not attempt to minimize code or data "
"footprint\n");
System_flush();

System_printf("Starting the UART Echo example\nSystem provider is set to "
"SysMin. Halt the target to view any SysMin contents in "
"ROV.\n");
/* SysMin will only print to the console when you call flush or exit */
System_flush();

/* Start BIOS */
BIOS_start();

return (0);
}


Then I used PuTTY. I looked at my COM port in Windows and found out :

Class Application / USER UART : COM 10 Class Auxiliary Data: COM 9

I opened PuTTY and selected Serial communication, COM 10 / COM 9 and input 9600 in the baud rate.

It opened the PuTTY console but there was nothing inside. I could not even type anything.

What I am doing wrong ?

• Make sure software and hardware flow control are disabled in the terminal program. – David Schwartz Sep 3 '16 at 7:03
• Com9,10... Sounds like a USB to rs232 converter – JonRB Sep 3 '16 at 7:18
• @JonRB this is the debugger – chris Sep 3 '16 at 7:35
• It's "PuTTY" where the TTY is a reference to the old TeleTYpe. – Transistor Sep 3 '16 at 7:42
• PuTTY diagnosis: just short pin 2 to 3 on your DB9 serial output and check whatever you type is echoed back. – carloc Sep 3 '16 at 8:19