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.

Configuring CC3200 UART-1 to EXT device

Other Parts Discussed in Thread: CC3200Hi Abhishek,

I want to connect external device to cc3200 via UART. So I was checking it through , connecting a USB to UART board to CC3200 and by typing on hyper terminal like Putty and getting the characters in UART interrupt handler. But there is no document which would explain how to configure UARTA1 and how the external emulator board (USB to UART) is connected to cc3200 and at that time how should be the jumper setting.

Can guide me on above three point? I would appreciate if anyone help me on this.

Thanks.
  • Hi Techinspired,

    To use UART1, you need to do the following steps in your code:

    1. In your PinMuxConfig(), enable the clocks to the UART1 peripheral, and mux the UART1 signals to the external pins of your choice.
    2. Setup the UART1 interface with a UARTConfigSetExpClk() call with your setup-specific values. You can take a look at the init_term() function of uart_if.c in the /example/common/ folder of the SDK for an example of how to use that. 
    3. You can then setup a DMA transfers to/from UART1 to some buffer in your code. See the uart_dma demo in the SDK for an example of how to do this.
    4. You need to also setup an interrupt handler for UART1 to handle the DMA completion events and keep the DMA transfers going. The code in your interrupt handler basically needs to check the interrupt source, requeue the just-completed DMA transfer, and then clear the interrupt source. Take a look at the udma example for a reference of how to do this.

    With that in place, you will be able to use UART1 with DMA to transfers as much data as you would want.

    Alternatively, if you are fine with not having UART0 connected to your computer, is to simply move the J6/7 jumpers from 'FLASH' to 'BP'. This routes the UART0 signals to the launchpad headers instead of the onboard USB->UART chip. The UART0 signals will then be available at pins 55 and 57.

    One other quicker method of using UART1 is to copy the uart_if.c and uart_if.h files, define an EXT_UART symbol as UARTA1_BASE, and then replace every instance of CONSOLE with EXT_UART. You would also have to adjust a few other things such as changing all of the function names to be different from the originals, but this would allow you to use all of the UART helper functions you get in uart_if.c with UART1.

    Let me know if you need more help, or if you have a question on what I explained.

    Regards,

    Michael

  • Hi Michael,

    Thanks a lot for your elaborated reply! You always try to cover every minute detail of query.

    I tried suggestion given by you, and gone through the sample examples like uart_demo,uart_dma,udma etc. Right now I'm using only UARTA0 and I need to connect an external device to cc3200 through UART :

    1) So my PinMuxConfig() function look like this:

    void
    PinMuxConfig(void)
    {
        //
        // Enable Peripheral Clocks 
        //
        MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    
        //
        // Configure PIN_55 for UART0 UART0_TX
        //
        MAP_PinTypeUART(PIN_55, PIN_MODE_3);
    
        //
        // Configure PIN_57 for UART0 UART0_RX
        //
        MAP_PinTypeUART(PIN_57, PIN_MODE_3);
    }

    2)

    Michael Reymond said:
    Setup the UART1 interface with a UARTConfigSetExpClk() call with your setup-specific values.

    In my case

    #define CONSOLE         UARTA0_BASE
    #define CONSOLE_PERIPH  PRCM_UARTA0

    MAP_UARTConfigSetExpClk(CONSOLE,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH), UART_BAUD_RATE,
                (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));

    3) As of now ,I don't want DMA transfer, I only want to receive some string in UART interrupt Handler, so I wrote code like this:

    //*****************************************************************************
    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    
    #include <stdbool.h>
    #include <stdint.h>
    
    // Driverlib includes
    #include "rom.h"
    #include "rom_map.h"
    #include "hw_memmap.h"
    #include "hw_common_reg.h"
    #include "hw_uart.h"
    #include "hw_types.h"
    #include "hw_ints.h"
    #include "uart.h"
    #include "udma.h"
    #include "interrupt.h"
    #include "utils.h"
    #include "prcm.h"
    #include "pin.h"
    
    // Common interface includes
    #include "uart_if.h"
    #include "udma_if.h"
    
    #include "pinmux.h"
    
    //*****************************************************************************
    //                          MACROS
    //*****************************************************************************
    #define APPLICATION_VERSION  "1.1.1"
    #define APP_NAME            "UART DMA"
    
    //*****************************************************************************
    //                 GLOBAL VARIABLES -- Start
    //*****************************************************************************
    volatile int g_iCounter = 0;
    
    #if defined(ccs)
    extern void (* const g_pfnVectors[])(void);
    #endif
    #if defined(ewarm)
    extern uVectorEntry __vector_table;
    #endif
    //*****************************************************************************
    //                 GLOBAL VARIABLES -- End
    //*****************************************************************************
    //static unsigned char ucTextBuff[50];
    //volatile static tBoolean bRxDone;
    unsigned char ucCharBuffer[50];
    uint16_t ui16CharCounter=0;
    
    //*****************************************************************************
    //                      LOCAL DEFINITION
    //*****************************************************************************
    
    //*****************************************************************************
    //
    //! Application startup display on UART
    //!
    //! \param  none
    //!
    //! \return none
    //!
    //*****************************************************************************
    static void
    DisplayBanner(char * AppName)
    {
    
        Report("\n\n\n\r");
        Report("\t\t *************************************************\n\r");
        Report("\t\t        CC3200 %s Application       \n\r", AppName);
        Report("\t\t *************************************************\n\r");
        Report("\n\n\n\r");
    }
    
    //*****************************************************************************
    //
    //! Board Initialization & Configuration
    //!
    //! \param  None
    //!
    //! \return None
    //
    //*****************************************************************************
    static void
    BoardInit(void)
    {
        /* In case of TI-RTOS vector table is initialize by OS itself */
    #ifndef USE_TIRTOS
        //
        // Set vector table base
        //
    #if defined(ccs)
        MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);
    #endif
    #if defined(ewarm)
        MAP_IntVTableBaseSet((unsigned long)&__vector_table);
    #endif
    #endif
        //
        // Enable Processor
        //
        MAP_IntMasterEnable();
        MAP_IntEnable(FAULT_SYSTICK);
    
        PRCMCC3200MCUInit();
    }
    
    //*****************************************************************************
    //
    //! Interrupt handler for UART interupt 
    //!
    //! \param  None
    //!
    //! \return None
    //!
    //*****************************************************************************
    static void UARTIntHandler()
    {
    
        unsigned long ulStatus;
        // unsigned long ulMode;
        //    unsigned long i;
        //
        // Read the interrupt status of the UART.
        //
        ulStatus = MAP_UARTIntStatus(UARTA0_BASE, 1);
        //
        // Clear any pending status, even though there should be none since no UART
        // interrupts were enabled.
        //
        MAP_UARTIntClear(UARTA0_BASE, ulStatus);
        //
        // loop while there are characters in the receive FIFO.
    
        //   i=0;
        while(UARTCharsAvail(UARTA0_BASE))
        {
            ucCharBuffer[ui16CharCounter]= UARTCharGet(UARTA0_BASE);
            UARTCharPut(UARTA0_BASE,ucCharBuffer[ui16CharCounter]);
            ui16CharCounter++;
        }
    
    }
    
    //*****************************************************************************
    //
    //! Main function handling the UART and DMA configuration. It takes 8 
    //! characters from terminal without displaying them. The string of 8 
    //! caracters will be printed on the terminal as soon as 8th character is
    //! typed in.
    //!
    //! \param  None
    //!
    //! \return None
    //!
    //*****************************************************************************
    void main()
    {
        //
        // Initailizing the board
        //
        BoardInit();
    
        //
        // Clear terminal
        //
        ClearTerm();
    
    
        //
        // Display Banner
        //
        DisplayBanner(APP_NAME);
    
    
        //
        // Initialize the RX done flash
        //
        // bRxDone = false;
    
        //
        // Initialize uDMA
        //
        //  UDMAInit();
    
        //
        // Muxing for Enabling UART_TX and UART_RX.
        //
        PinMuxConfig();
    
        //
        // Initialising the Terminal.
        //
        MAP_UARTConfigSetExpClk(CONSOLE,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH), UART_BAUD_RATE,
                (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));
    
    
        MAP_PinTypeUART(PIN_55,PIN_MODE_3);
        MAP_PinTypeUART(PIN_57,PIN_MODE_3);
    
    
        //
        // Register interrupt handler for UART
        //
        MAP_UARTIntRegister(UARTA0_BASE,UARTIntHandler);
    
        //
        // Enable uart interrupts for uart
        //
        MAP_UARTIntEnable(UARTA0_BASE,UART_INT_RX|UART_INT_TX);
    
        UARTFIFODisable(UARTA0_BASE);
        //
        // Set the message
        //
        Message("Type in 8 characters:");
    
        //
        // Configure the UART Tx and Rx FIFO level to 1/8 i.e 2 characters
        //
         UARTFIFOLevelSet(UARTA0_BASE,UART_FIFO_TX1_8,UART_FIFO_RX1_8);
    
    
        //
        // Enable Rx DMA request from UART
        //
        //  MAP_UARTDMADisable(UARTA1_BASE,UART_DMA_RX|UART_DMA_RX);
    
    
        while(1)
        {
            //
            // Inifite loop
            //
        }
    }
    
    //*****************************************************************************
    //
    // Close the Doxygen group.
    //! @}
    //
    //*****************************************************************************
    

    4)  I've connected USB to UART chip's TX to pin-55 and RX to pin-57 and jumper J6 and J7 are on BP mode, In my case,COM ports for CC3200LP is COM10 and USB serial port is COM3. SO I open Putty terminal with COM3, But then I get a message: Error Connecting to target in CCS. It seems like, it can't route the UARTA0 signals to Launchpad headers.

    5) But when I open Putty with Virtual COM10 with jumper on FLASH mode it works fine ( Works on only UARTA0)

    6) In hardware guide of cc3200 they clearly metioned that on  pin-3 and pin-4 you can get UARTA0 signal( this is something bit confusing as you also get UARTA0 signal on pin-55 and pin-57) but what should be the jumper setting in each case?

    7) Could you please explain, how to connect external USB to UART board / or external device to CC3200 to see output on PUTTY(which should be the COM Port while opening the hyper terminal, whether it should be Launchpad's or USB Serial's COM?

    Best Regards,

    Techinspired

  • Hi Techinspired,

    The UART0 signals are assigned in the pinmux.c file like the other peripherals on the CC3200. You can check in your local pinmux.c to see what are the pin assignments for UART0, but for all of the SDK examples the UART0 signals are muxed out to pin 55/57.

    Once you have moved the UART jumpers (J6/J7) to BP, you should no longer use the CC3200's COM port in your terminal emulator. You should only be using your USB serial COM port. Your USB->UART device should be connected to the launchpad header pins where you muxed out the UART0 signals.

    Regards,
    Michael
  • Hi Michael,

    Thanks a lot for your reply!

    It is now working perfectly. I am able to get UARTA0 signals on Launchpad's pin-55 and pin-57.

    Best Regards,
    Techinspired