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/TMS320F28388D: Make a UART communication with a terminal

Part Number: TMS320F28388D
Other Parts Discussed in Thread: C2000WARE,

Tool/software: Code Composer Studio

Hi

I am new to the programming. 

I want to know how to make a UART  communication with a terminal. 

I want to send a text to a terminal so i can see that i have a both TX and RX working.

i have used your example to config the GPIO for the c28 core.

hope you can help.

BR

Asbjørn Schram Anneberg

  • Hi Asbjorn,

    The main peripheral for serial communication on the C28x side of the F28388D is the SCI.  

    Please download C2000ware and have a look at the SCI examples and also read the SCI section of the TRM (https://www.ti.com/lit/ug/spruii0b/spruii0b.pdf).  In particular, the SCI echoback example demonstrates communication back and forth with a PC terminal.  

    To communicate with a PC, you will either need an RS-232 transceiver, or you will need to use a serial-to-USB bridge (e.g. FT2232 device) 

    The FTDI circuit is available on some C2000 development boards, so you can use that directly if it is on the board you are using.

    Otherwise, you will want to build up a RS-232 transceiver circuit (or serial-to-USB bridge circuit) on a protoboard or breadboard, then connect to the serial port on your PC.   

    To understand the need for a transceiver, this TI precision labs introduction to RS-485 may be worth watching.  RS-232 isn't exactly the same, but it is similar. (https://training.ti.com/ti-precision-labs-rs-485-what-rs-485

  • Hi Devin Cottier

    Is it possible to make an UART communication with the CM-core to a terminal of the TMS320F28388D board. I have the doing it with an old board F28m36x.

    Do i have to use SCI on TMS320F28388D or are there other ways to send to terminal on pc? Something simpler. There is an example where im setting up the GPIO's on the c28 (uart_config_c28x) and then making echoback with example uart_ex1_echoback. I just cant get it to work.

    I am using Realterm and i did config all the following:

    //!  -  Find correct COM port
    //!  -  Bits per second = 115200
    //!  -  Data Bits = 8
    //!  -  Parity = None
    //!  -  Stop Bits = 1
    //!  -  Hardware Control = None

    When it all is connected with Realterm and i push a keyboard botten in Realterm i see the D4 (TX pin for UART) blink.

    Mayby think i miss wrote before.

    Thank you

    BR
    Asbjørn Schram Anneberg

  • Hi Asbjorn,

    You can definitely use the CM-UART module to communicate with a terminal on a PC.  It should actually function the same as the UART on the M3 side of F28M36x as far as I know.  I think the main difference will just be pin muxing/pinout, so you may want to carefully read the documentation/examples on how to get the peripheral to the desired pins, then verify that this worked by scoping the pins in question.

    Everything related to using an FTDI or transceiver still applies to the CM-UART; you won't be able to directly connect the CMOS level pins straight to your PC.  

  • Also if i am just using the debug? I am just using the USB connection J1:A shown in the picture.

  • Hi Asbjorn,

    I don't think your image came through.  

    If you are using the ControlCard, it looks like only GPIO28 and GPIO29 can connect to the Serial-to-USB bridge (FTDI IC U2:A).  These GPIOs look like they only connect directly to SCI-A on the C28x side.  If you want to use this bridge, you may need to find out if you can jumper wire the M4-UART peripheral pins to these pins of U2:A.  

  • I do not understand why i can easely make the UART communacation on the old board F28M36P63 by using the example in given Control Suite.

    On the board i have now F28388D i am using following code:

    First set the GPIO on the C28 side using the "uart_config_c28x":

    //#############################################################################
    //
    // FILE:   cm_common_config_c28x.c
    //
    // TITLE:  C28x Common Configurations to be used for the CM Side.
    //
    //! \addtogroup driver_example_list
    //! <h1>C28x Common Configurations</h1>
    //!
    //! This example configures the GPIOs and Allocates the shared peripherals
    //! according to the defines selected by the users.
    //!
    //
    //#############################################################################
    // $TI Release: F2838x Support Library v3.02.00.00 $
    // $Release Date: Tue May 26 17:21:56 IST 2020 $
    // $Copyright:
    // Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
    //
    // 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.
    // $
    //#############################################################################
    
    //
    // Included Files
    //
    #include "driverlib.h"
    #include "device.h"
    
    void main(void)
    {
    
        //
        // Initialize device clock and peripherals
        //
        Device_init();
    
        //
        // Boot CM core
        //
    #ifdef _FLASH
        Device_bootCM(BOOTMODE_BOOT_TO_FLASH_SECTOR0);
    #endif
    
        //
        // Disable pin locks and enable internal pull-ups.
        //
        Device_initGPIO();
    
    
    
    #ifdef UART
        //
        // Configure GPIO85 as the UART Rx pin.
        //
        GPIO_setPinConfig(GPIO_85_CMUARTRXA);
        GPIO_setDirectionMode(85, GPIO_DIR_MODE_IN);
        GPIO_setPadConfig(85, GPIO_PIN_TYPE_STD);
        GPIO_setQualificationMode(85, GPIO_QUAL_ASYNC);
    
        //
        // Configure GPIO84 as the UART Tx pin.
        //
        GPIO_setPinConfig(GPIO_84_CMUARTTXA);
        GPIO_setDirectionMode(84, GPIO_DIR_MODE_OUT);
        GPIO_setPadConfig(84, GPIO_PIN_TYPE_STD);
        GPIO_setQualificationMode(84, GPIO_QUAL_ASYNC);
    #endif
    }
    

    /////Deleted all the inactive code that was grey in the example///////

    After i use the "uart_ex1_echoback":

    //#############################################################################
    //
    // FILE:   UART_ex1_echoback.c
    //
    // TITLE:  UART echoback example.
    //
    //! \addtogroup driver_example_cm_list
    //! <h1>UART Echoback</h1>
    //!
    //!  This test receives and echo-backs data through the UART0 port.
    //!
    //!  A terminal such as 'putty' can be used to view the data from
    //!  the CM-UART and to send information to the CM-UART. Characters 
    //!  received by the CM-UART port are sent back to the host.
    //!
    //!  \b Running \b the \b Application
    //!  Open a COM port with the following settings using a terminal:
    //!  -  Find correct COM port
    //!  -  Bits per second = 115200
    //!  -  Data Bits = 8
    //!  -  Parity = None
    //!  -  Stop Bits = 1
    //!  -  Hardware Control = None
    //!
    //!  The program will print out a greeting and then ask you to
    //!  enter a character which it will echo back to the terminal.
    //!
    //!  \b Watch \b Variables \n
    //!  - None
    //!
    //! \b External \b Connections \n
    //!  Connect the UART0 port to a PC via a transceiver and cable.
    //!  - GPIO85 is UART0RX/CMUARTRXA(Connect to Pin3, PC-TX, of serial DB9 cable)
    //!  - GPIO84 is UART0TX/CMUARTTXA(Connect to Pin2, PC-RX, of serial DB9 cable)
    //! 
    //!  \note The pin muxing for the UART0 port needs to be done by the master 
    //!  CPU1. The common configuration example provided in the C28x folder can be 
    //!  used for making GPIO85 as the UART Rx pin and GPIO84 as the UART Tx pin.
    //
    //#############################################################################
    // $TI Release: F2838x Support Library v3.02.00.00 $
    // $Release Date: Tue May 26 17:21:56 IST 2020 $
    // $Copyright:
    // Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
    //
    // 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.
    // $
    //#############################################################################
    
    //
    // Included Files
    //
    #include <stdint.h>
    #include <stdbool.h>
    
    #include "cm.h"
    
    //
    // Defines
    //
    #define NUM_UART_DATA    4
    
    //
    // Function Prototypes
    //
    __interrupt void UART_RX_IntHandler(void);
    
    //
    // Main
    //
    void main(void)
    {
    
        //
        // disable WD, enable peripheral clocks.
        //
        CM_init();
    
        //
        // Configure UART0 for echoback.Set up to transfer data at 115200 baud.
        //                                                        
        UART_setConfig(UART0_BASE,UART_CLK_FREQ , 115200,(UART_CONFIG_WLEN_8 | 
                       UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
    
        // 
        // Put a character to show start of example.  This will display on the
        // terminal.
        //
        UART_writeChar(UART0_BASE, '!');
    
        //
        // Enable the UART0 interrupt on the processor (NVIC).
        //
        UART_registerInterrupt(INT_UART0,UART_RX_IntHandler);
    
        //
        // FIFO enable
        //
        UART_enableFIFO(UART0_BASE);
    
        //
        // FIFO interrupt levels are set to generate an interrupt
        // when the TX FIFO is less than or equal to 7/8 empty and the
        // RX FIFO is greater than or equal to 1/8 full.
        //
        UART_setFIFOLevel(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);
    
        //
        // FIFO receive interrupt configuration
        //
        UART_clearInterruptStatus(UART0_BASE,UART_INT_RX | UART_INT_RT);   
        UART_enableInterrupt(UART0_BASE,UART_INT_RX);
    
        //
        // Loop forever echoing data through the UART.
        //
        while(1)
        {
        }
    }
    
    
    __interrupt void UART_RX_IntHandler(void)
    {
        uint32_t ui32Status;
    
        //
        // Get the interrupt status.
        //
        ui32Status = UART_getInterruptStatus(UART0_BASE, UART_RAW_INT);
    
        //
        // Clear the asserted interrupts.
        //
        UART_clearInterruptStatus(UART0_BASE, ui32Status);
    
        //
        // Loop while there are characters in the receive FIFO.
        //
        while(UART_isDataAvailable(UART0_BASE))
        {
            //
            // Read the next character from the UART and write it back to the UART.
            //
            UART_writeCharNonBlocking(UART0_BASE,
                                      UART_readCharNonBlocking(UART0_BASE));
        }
    }
    
    //
    // End of File
    //
    
    

    Hope it helps to see what the problem is?

    Just dont make any sence that i need to jumper wire?

    Regards Asbjørn Schram Anneberg

  • I think i understand what you mean. As i see in the schematic and datasheet the UART GPIO's are not connected with the SCI as they were on the old board F28M36. 
    I got the SCI communacation working on the C28 side with a terminal.

    The thing is that i have a Ethernet connection that i need to verify on the CM side. On the old board i used the UART to send messages on a terminal to check if the program was running as it should.

    Is there a way i can use the SCI on c28 to send a messege to a terminal, but by calling it on the CM side.

  • Hi Asbjorn,

    Understand the situation.  

    Your options would be to:

    • Build a transceiver for the CM UART on some protoboard or use jumper wires to connect to the existing FTDI based Serial-to-USB bridge
    • Use the IPC (inter-processor communication) hardware to pass messages from the CM to the C28x. Steps are (1) CM puts the message into CM-to-C28x message RAM and invokes an IPC trigger to C28x.  (2) In the C28x IPC ISR, copy the message from the CM-to-C28x message RAM to the C28x SCI TX (3) Acknowledge the IPC flags so that the next message can be sent
    • Try to route CM UART TX in via the input X-BAR and then out via output X-BAR line OUTPUTXBAR6 which is on the same GPIO as the C28x SCI TX that is connected to the Serial-to-USB bridge

  • Hi and sorry for the late response!

    Thank you for the answer! it helped a lot.

    When i look at the schematic for the F28388D the GPIO for SCI, connected to the FTDI, communication are GPIO-28 and 29. And the UART communication are connected to GPIO are GPIO-84 and 85.

    So i see what you mean by jump wire the board.

    I also got it working using the shared memory and the SCI on the C28 side. 

    Regards

    Asbjørn

  • Hi Asbjorn,

    Great to hear you got the solution working!