[CC3200] CC32xx UART 串口应用实例

[复制链接]
1238|13
 楼主| gaoke231 发表于 2019-7-31 18:37 | 显示全部楼层 |阅读模式
概述
对 UART 功能设备的支持,它有各种标准,比如可编程波特率、单独传送和接收 FIFO、
完全可编程单独接口特性等。  

评论

感谢分享  发表于 2019-7-31 21:03
 楼主| gaoke231 发表于 2019-7-31 18:37 | 显示全部楼层
应用说明
这个应用的目的是为了展示 UART 的用处,包括获取来自用户的输入信息和在终端上显
示信息,下面这个例子输入一行字,按 enter,然后原样显示出来。
 楼主| gaoke231 发表于 2019-7-31 18:37 | 显示全部楼层
原理图如下:
483835d416f833c803.png
 楼主| gaoke231 发表于 2019-7-31 18:38 | 显示全部楼层
设置一个串行通信程序(超级终端/ TeraTerm)。终端设置如下
43095d416fa50319a.png
 楼主| gaoke231 发表于 2019-7-31 18:39 | 显示全部楼层
运行参考程序(Flashing the bin/IAR/CCS)。 观察终端上的状态信息理解应用程序执行的顺序。 运行结果如下图所示:
702435d416fd4440b7.png
 楼主| gaoke231 发表于 2019-7-31 18:39 | 显示全部楼层
应用说明
这个应用程序的目的是展示中断抢占和 tail-chaining 能力。当中断有相同的优先级时
会合成嵌套中断。 高优先级情况下, 优先级抢占发生:在其他两个情况下 tail-chaining 将
发生
 楼主| gaoke231 发表于 2019-7-31 18:40 | 显示全部楼层
设置一个串行通信程序(超级终端/ TeraTerm)。终端设置如下:
730675d41700920255.png
 楼主| gaoke231 发表于 2019-7-31 18:40 | 显示全部楼层
运行参考程序(Flashing the bin/IAR/CCS)。观察终端上的状态信息理解应用程序执行的顺序。运行结果如下图所示:
686145d417035d02ce.png
 楼主| gaoke231 发表于 2019-7-31 19:19 | 显示全部楼层
volatile int g_iCounter = 0;

#if defined(ccs)
extern void (* const g_pfnVectors[])(void);
#endif
#if defined(ewarm)
extern uVectorEntry __vector_table;
#endif
 楼主| gaoke231 发表于 2019-7-31 19:24 | 显示全部楼层
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");
}
 楼主| gaoke231 发表于 2019-7-31 19:24 | 显示全部楼层
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();
}
 楼主| gaoke231 发表于 2019-7-31 19:24 | 显示全部楼层
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
            //
            Report("\n\rcmd#%s\n\rcmd#", cString);
        }
        else
        {
            UartPutChar(cCharacter);
            cString[iStringLength] = cCharacter;
            iStringLength++;
        }
    }
}
 楼主| gaoke231 发表于 2019-7-31 19:25 | 显示全部楼层
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);
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

54

主题

1310

帖子

5

粉丝
快速回复 在线客服 返回列表 返回顶部