l4568527193 发表于 2013-8-31 17:12:07

单步调试串口输出正常,全速运行就只能输出17个字符,是...

#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"

#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/timer.h"
#include "driverlib/uart.h"

unsigned char str_receive;
unsigned char pr=0,flag_valid_data=0,flag_complete_data=0;
void
UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
{
    //
    // Loop while there are more characters to send.
    //
    while(ulCount--)
    {       
      //
      // Write the next character to the UART.
      //
      UARTCharPutNonBlocking(UART0_BASE, *pucBuffer++);
    }
}

void
UARTIntHandler(void)
{

    unsigned long ulStatus;
       
    //
    // Get the interrrupt status.
    //
    ulStatus = UARTIntStatus(UART0_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    UARTIntClear(UART0_BASE, ulStatus);

    //
    // Loop while there are characters in the receive FIFO.
    //
        str_receive=UARTCharGetNonBlocking(UART0_BASE);
        if((str_receive==0xcf)&&(flag_valid_data==0))
        {
                flag_valid_data=1;
        }
        if(flag_valid_data)
        {
                if(str_receive==0xfc)
                {
                        pr=0;flag_complete_data=1;flag_valid_data=0;
                }
                else pr++;
        }
        else pr=0;
        if(flag_complete_data==1)
        {
                UARTSend(str_receive,3);
                flag_complete_data=0;
        }
/*        if(str_receive=='a')
        {
                GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);       
        }
        else if(str_receive=='b')
        {
                GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
        }*/
}                                       
void
Timer0IntHandler(void)
{
        TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
        IntMasterDisable();
        UARTSend((unsigned char *)"This is Time interrup!\n",sizeof("This is Time interrup!\n"));
        IntMasterEnable();
}
                              
int                                           
main(void)
{
    //
    // Set the clocking to run directly from the crystal.
    //
    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
                   SYSCTL_XTAL_8MHZ);

    //
    // Enable the peripherals used by this example.
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    //
    // Enable processor interrupts.
    //
   
        GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
    //
    // Set GPIO A0 and A1 as UART pins.
    //
        GPIOPinConfigure(GPIO_PA0_U0RX);
        GPIOPinConfigure(GPIO_PA1_U0TX);
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

    //
    // Configure the UART for 115,200, 8-N-1 operation.
    //
    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
                        (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
                         UART_CONFIG_PAR_NONE));

    //
    // Enable the UART interrupt.
    //
    IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);


        SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
        TimerConfigure(TIMER0_BASE, TIMER_CFG_32_BIT_PER);
        TimerLoadSet(TIMER0_BASE, TIMER_A, SysCtlClockGet());
        IntEnable(INT_TIMER0A);
        TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT);
        TimerEnable(TIMER0_BASE, TIMER_A);
        IntMasterEnable();
    //
    // Prompt for text to be entered.
    //
    UARTSend((unsigned char *)"It is start!\n", sizeof("It is start!\n"));
    //
    // Loop forever echoing data through the UART.
    //
    while(1)
    {              
    }
}

l4568527193 发表于 2013-8-31 17:14:33

串口助手上显示的是
It is start!
This is Time inte

wye11083 发表于 2013-8-31 17:50:09

从现象分析,必然是MCU没做延时处理。

l4568527193 发表于 2013-8-31 18:01:31

wye11083 发表于 2013-8-31 17:50 static/image/common/back.gif
从现象分析,必然是MCU没做延时处理。

在哪个地方加延时

wye11083 发表于 2013-8-31 18:14:52

目测在这里面UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
{
    //
    // Loop while there are more characters to send.
    //
    while(ulCount--)
    {      
      //
      // Write the next character to the UART.
      //
      UARTCharPutNonBlocking(UART0_BASE, *pucBuffer++);
    }
}加个标志判断。

mitchell 发表于 2013-8-31 18:17:45

NonBlocking...
buffer溢出了呗

l4568527193 发表于 2013-8-31 19:27:48

wye11083 发表于 2013-8-31 18:14 static/image/common/back.gif
目测在这里面UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
{
    //


什么标志位,什么用途的?

ulCount不就是发送的数据个数么?如果没有了就为0
页: [1]
查看完整版本: 单步调试串口输出正常,全速运行就只能输出17个字符,是...