打印
[CC3200]

CC32xx UART 串口应用实例

[复制链接]
683|13
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
沙发
gaoke231|  楼主 | 2019-7-31 18:37 | 只看该作者
应用说明
这个应用的目的是为了展示 UART 的用处,包括获取来自用户的输入信息和在终端上显
示信息,下面这个例子输入一行字,按 enter,然后原样显示出来。

使用特权

评论回复
板凳
gaoke231|  楼主 | 2019-7-31 18:37 | 只看该作者
原理图如下:

使用特权

评论回复
地板
gaoke231|  楼主 | 2019-7-31 18:38 | 只看该作者
设置一个串行通信程序(超级终端/ TeraTerm)。终端设置如下

使用特权

评论回复
5
gaoke231|  楼主 | 2019-7-31 18:39 | 只看该作者
运行参考程序(Flashing the bin/IAR/CCS)。 观察终端上的状态信息理解应用程序执行的顺序。 运行结果如下图所示:

使用特权

评论回复
6
gaoke231|  楼主 | 2019-7-31 18:39 | 只看该作者
应用说明
这个应用程序的目的是展示中断抢占和 tail-chaining 能力。当中断有相同的优先级时
会合成嵌套中断。 高优先级情况下, 优先级抢占发生:在其他两个情况下 tail-chaining 将
发生

使用特权

评论回复
7
gaoke231|  楼主 | 2019-7-31 18:40 | 只看该作者
设置一个串行通信程序(超级终端/ TeraTerm)。终端设置如下:

使用特权

评论回复
8
gaoke231|  楼主 | 2019-7-31 18:40 | 只看该作者
运行参考程序(Flashing the bin/IAR/CCS)。观察终端上的状态信息理解应用程序执行的顺序。运行结果如下图所示:

使用特权

评论回复
9
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

使用特权

评论回复
10
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");
}

使用特权

评论回复
11
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();
}

使用特权

评论回复
12
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++;
        }
    }
}

使用特权

评论回复
13
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

粉丝