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/CC3200-LAUNCHXL: using uart0 and uart1 at the same time

Part Number: CC3200-LAUNCHXL
Other Parts Discussed in Thread: CC3200, CC3200MOD

Tool/software: Code Composer Studio

Hi,

I had some doubts about uart communication and configuring.

1.i need to use uart1 and uart0 at the same time(i just tried so many in uart demo and read some threads eg:)

is there any code example for ccs ?

  • what is the difference between PIN_MODE_3 and other pin modes????

    (eg:
    PinTypeUART(PIN_55, PIN_MODE_3);
    PinTypeUART(PIN_57, PIN_MODE_3);
    PinTypeUART(PIN_58, PIN_MODE_6);
    PinTypeUART(PIN_59, PIN_MODE_6);)

    please answer the above questions.

  • Hi Aju,

    I don't believe there is any example for the CC3200 which uses both UART0 and UART1 at the same time, so this configuration would have to be set by the user.  The post you've attached above includes specific instructions on how to do this.

    Also, please see the below post for understanding the difference between the various PIN_MODES:

    https://e2e.ti.com/support/wireless_connectivity/simplelink_wifi_cc31xx_cc32xx/f/968/t/471553

  • Hi Austin Tanner,

    i write a code by the help of the thread that i posted,but it doesn't work,can explain why?,please suggest the errors

    my code posted below.

                                                                   **********************************************************************PIN MUX :

    void

    PinMuxConfig(void)

    {

       //

       // Enable Peripheral Clocks

       //

       MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);

       MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, 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);

       MAP_PinTypeUART(PIN_58, PIN_MODE_6);

       //

       // Configure PIN_59 for UART1 UART1_RX

       //

       MAP_PinTypeUART(PIN_59, PIN_MODE_6);

    }

                                                            ********************************************************************************************UART_IF.c

    // Standard includes

    #include <stdarg.h>

    #include <stdlib.h>

    #include <stdio.h>

    #include <string.h>

    // Driverlib includes

    #include "hw_types.h"

    #include "hw_memmap.h"

    #include "prcm.h"

    #include "pin.h"

    #include "uart.h"

    #include "rom.h"

    #include "rom_map.h"

    #if defined(USE_FREERTOS) || defined(USE_TI_RTOS)

    #include "osi.h"

    #endif

    #include "uart_if.h"

    #define IS_SPACE(x)       (x == 32 ? 1 : 0)

    //*****************************************************************************

    // Global variable indicating command is present

    //*****************************************************************************

    static unsigned long __Errorlog;

    //*****************************************************************************

    // Global variable indicating input length

    //*****************************************************************************

    unsigned int ilen=1;

    //*****************************************************************************

    //

    //! Initialization

    //!

    //! This function

    //!        1. Configures the UART to be used.

    //!

    //! \return none

    //

    //*****************************************************************************

    void

    InitTerm()

    {

    #ifndef NOTERM

     MAP_UARTConfigSetExpClk(CONSOLE,MAP_PRCMPeripheralClockGet(CONSOLE_PERIPH),

                     UART_BAUD_RATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |

                      UART_CONFIG_PAR_NONE));

     MAP_UARTConfigSetExpClk(DEVICE,MAP_PRCMPeripheralClockGet(DEVICE_PERIPH),

                       UART_BAUD_RATE, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |

                        UART_CONFIG_PAR_NONE));

    #endif

     __Errorlog = 0;

    }

    //*****************************************************************************

    //

    //!    Outputs a character string to the console

    //!

    //! \param str is the pointer to the string to be printed

    //!

    //! This function

    //!        1. prints the input string character by character on to the console.

    //!

    //! \return none

    //

    //*****************************************************************************

    void

    Message(const char *str)

    {

    #ifndef NOTERM

       if(str != NULL)

       {

           while(*str!='\0')

           {

               MAP_UARTCharPut(DEVICE,*str++);

           }

       }

    #endif

    }

    //*****************************************************************************

    //

    //!    Clear the console window

    //!

    //! This function

    //!        1. clears the console window.

    //!

    //! \return none

    //

    //*****************************************************************************

    void

    ClearTerm()

    {

       Message("\33[2J\r");

    }

    //*****************************************************************************

    //

    //! Error Function

    //!

    //! \param

    //!

    //! \return none

    //!

    //*****************************************************************************

    void

    Error(char *pcFormat, ...)

    {

    #ifndef NOTERM

       char  cBuf[256];

       va_list list;

       va_start(list,pcFormat);

       vsnprintf(cBuf,256,pcFormat,list);

       Message(cBuf);

    #endif

       __Errorlog++;

    }

    //*****************************************************************************

    //

    //! Get the Command string from UART

    //!

    //! \param  pucBuffer is the command store to which command will be populated

    //! \param  ucBufLen is the length of buffer store available

    //!

    //! \return Length of the bytes received. -1 if buffer length exceeded.

    //!

    //*****************************************************************************

    int

    GetCmd(char *pcBuffer, unsigned int uiBufLen)

    {

       char cChar;

       int iLen = 0;

       //

       // Wait to receive a character over UART

       //

       while(MAP_UARTCharsAvail(DEVICE) == false)

       {

    #if defined(USE_FREERTOS) || defined(USE_TI_RTOS)

        osi_Sleep(1);

    #endif

       }

       cChar = MAP_UARTCharGetNonBlocking(DEVICE);

       //

       // Echo the received character

       //

       MAP_UARTCharPut(DEVICE, cChar);

       iLen = 0;

       //

       // Checking the end of Command

       //

       while((cChar != '\r') && (cChar !='\n') )

       {

           //

           // Handling overflow of buffer

           //

           if(iLen >= uiBufLen)

           {

               return -1;

           }

           //

           // Copying Data from UART into a buffer

           //

           if(cChar != '\b')

           {

               *(pcBuffer + iLen) = cChar;

               iLen++;

           }

           else

           {

               //

               // Deleting last character when you hit backspace

               //

               if(iLen)

               {

                   iLen--;

               }

           }

           //

           // Wait to receive a character over UART

           //

           while(MAP_UARTCharsAvail(DEVICE) == false)

           {

    #if defined(USE_FREERTOS) || defined(USE_TI_RTOS)

            osi_Sleep(1);

    #endif

           }

           cChar = MAP_UARTCharGetNonBlocking(DEVICE);

           //

           // Echo the received character

           //

           MAP_UARTCharPut(DEVICE, cChar);

       }

       *(pcBuffer + iLen) = '\0';

       Report("\n\r");

       return iLen;

    }

    //*****************************************************************************

    //

    //!    Trim the spaces from left and right end of given string

    //!

    //! \param  Input string on which trimming happens

    //!

    //! \return length of trimmed string

    //

    //*****************************************************************************

    int TrimSpace(char * pcInput)

    {

       size_t size;

       char *endStr, *strData = pcInput;

       char index = 0;

       size = strlen(strData);

       if (!size)

           return 0;

       endStr = strData + size - 1;

       while (endStr >= strData && IS_SPACE(*endStr))

           endStr--;

       *(endStr + 1) = '\0';

       while (*strData && IS_SPACE(*strData))

       {

           strData++;

           index++;

       }

       memmove(pcInput,strData,strlen(strData)+1);

       return strlen(pcInput);

    }

    //*****************************************************************************

    //

    //!    prints the formatted string on to the console

    //!

    //! \param format is a pointer to the character string specifying the format in

    //!           the following arguments need to be interpreted.

    //! \param [variable number of] arguments according to the format in the first

    //!         parameters

    //! This function

    //!        1. prints the formatted error statement.

    //!

    //! \return count of characters printed

    //

    //*****************************************************************************

    int Report(const char *pcFormat, ...)

    {

    int iRet = 0;

    #ifndef NOTERM

     char *pcBuff, *pcTemp;

     int iSize = 256;

     va_list list;

     pcBuff = (char*)malloc(iSize);

     if(pcBuff == NULL)

     {

         return -1;

     }

     while(1)

     {

         va_start(list,pcFormat);

         iRet = vsnprintf(pcBuff,iSize,pcFormat,list);

         va_end(list);

         if(iRet > -1 && iRet < iSize)

         {

             break;

         }

         else

         {

             iSize*=2;

             if((pcTemp=realloc(pcBuff,iSize))==NULL)

             {

                 Message("Could not reallocate memory\n\r");

                 iRet = -1;

                 break;

             }

             else

             {

                 pcBuff=pcTemp;

             }

         }

     }

     Message(pcBuff);

     free(pcBuff);

    #endif

     return iRet;

    }

                                                                                                                        ************************uart_if.h**********************

    #ifndef __uart_if_H__

    #define __uart_if_H__

    //*****************************************************************************

    //

    // If building with a C++ compiler, make all of the definitions in this header

    // have a C binding.

    //

    //*****************************************************************************

    #ifdef __cplusplus

    extern "C"

    {

    #endif

    /****************************************************************************/

    /* MACROS */

    /****************************************************************************/

    #define UART_BAUD_RATE  115200

    #define SYSCLK          80000000

    #define DEVICE          UARTA1_BASE

    #define CONSOLE         UARTA0_BASE

    #define CONSOLE_PERIPH  PRCM_UARTA0

    #define DEVICE_PERIPH  PRCM_UARTA1

    //

    // Define the size of UART IF buffer for RX

    //

    #define UART_IF_BUFFER           64

    //

    // Define the UART IF buffer

    //

    extern unsigned char g_ucUARTBuffer[];

    /****************************************************************************/

    /* FUNCTION PROTOTYPES */

    /****************************************************************************/

    extern void DispatcherUARTConfigure(void);

    extern void DispatcherUartSendPacket(unsigned char *inBuff, unsigned short usLength);

    extern int GetCmd(char *pcBuffer, unsigned int uiBufLen);

    extern void InitTerm(void);

    extern void ClearTerm(void);

    extern void Message(const char *format);

    extern void Error(char *format,...);

    extern int TrimSpace(char * pcInput);

    extern int Report(const char *format, ...);

    //*****************************************************************************

    //

    // Mark the end of the C bindings section for C++ compilers.

    //

    //*****************************************************************************

    #ifdef __cplusplus

    }

    #endif

    #endif

                                                                                            ****************main.c*******************************


    // Driverlib includes
    #include "rom.h"
    #include "rom_map.h"
    #include "hw_memmap.h"
    #include "hw_common_reg.h"
    #include "hw_types.h"
    #include "hw_ints.h"
    #include "uart.h"
    #include "interrupt.h"
    #include "pinmux.h"
    #include "utils.h"
    #include "prcm.h"
    #include "common.h"
    // Common interface include
    #include "uart_if.h"

    //*****************************************************************************
    // MACROS
    //*****************************************************************************
    #define APPLICATION_VERSION "1.1.1"
    #define APP_NAME "UART Echo"
    #define CONSOLE UARTA0_BASE
    #define DEVICE UARTA1_BASE
    #define UartGetChar() MAP_UARTCharGet(DEVICE)
    #define UartPutChar(c) MAP_UARTCharPut(DEVICE,c)
    #define MAX_STRING_LENGTH 80


    //*****************************************************************************
    // 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
    //*****************************************************************************

    //*****************************************************************************
    // 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();
    }

    //*****************************************************************************
    //
    //! Main function handling the uart echo. It takes the input string from the
    //! terminal while displaying each character of string. whenever enter command
    //! is received it will echo the string(display). if the input the maximum input
    //! can be of 80 characters, after that the characters will be treated as a part
    //! of next string.
    //!
    //! \param None
    //!
    //! \return None
    //!
    //*****************************************************************************
    void main()
    {
    char cString[MAX_STRING_LENGTH+1];
    char cCharacter;
    int iStringLength = 0;
    //
    // Initailizing the board
    //
    BoardInit();
    //
    // Muxing for Enabling UART_TX and UART_RX.
    //
    PinMuxConfig();
    //
    // Initialising the Terminal.
    //
    InitTerm();
    //
    // Clearing the Terminal.
    //
    ClearTerm();
    DisplayBanner(APP_NAME);
    Message("\t\t****************************************************\n\r");
    Message("\t\t\t CC3200 UART Echo Usage \n\r");
    Message("\t\t Type in a string of alphanumeric characters and \n\r");
    Message("\t\t pressenter, the string will be echoed. \n\r") ;
    Message("\t\t Note: if string length reaches 80 character it will \n\r");
    Message("\t\t echo the string without waiting for enter command \n\r");
    Message("\t\t ****************************************************\n\r");
    Message("\n\n\n\r");
    Message("cmd#");
    while(1)
    {
    //
    // Fetching the input from the terminal.
    //
    cCharacter = UartGetChar();
    g_iCounter++;
    if(cCharacter == '\r' || cCharacter == '\n' ||
    (iStringLength >= MAX_STRING_LENGTH -1))
    {
    if(iStringLength >= MAX_STRING_LENGTH - 1)
    {
    UartPutChar(cCharacter);
    cString[iStringLength] = cCharacter;
    iStringLength++;
    }
    cString[iStringLength] = '\0';
    iStringLength = 0;
    //
    // Echoes the input string
    //
    UART_PRINT("hai");
    Report("\n\rcmd#%s\n\rcmd#", cString);
    }
    else
    {
    UartPutChar(cCharacter);
    cString[iStringLength] = cCharacter;
    iStringLength++;
    }
    }
    }

    //*****************************************************************************
    //
    // Close the Doxygen group.
    //! @}
    //
    //*****************************************************************************

     

  • Hi Austin Tanner,
    i had one more doubt ,is there any difference in cc3200 and cc3200mod(coding &pin)?i know the details only that one is ic and other one is module,please explain the difference,how to change codes of cc3200 to cc3200mod?hop you get my point,please answer soon.
  • Hi Aju,

    There should be no difference between the two from a code perspective. One thing to keep in the back of your mind is that the module already comes with serial flash.