l4568527193 发表于 2013-6-5 15:55:41

Cotex-3串口调试只能发送数据不能接受是在回事!!!!!

#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/gpio.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/uart.h"



void
UARTIntHandler(void)
{
    unsigned long ulStatus;
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
    //
    // 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.
    //
    while(UARTCharsAvail(UART0_BASE))
    {
      //
      // Read the next character from the UART and write it back to the UART.
      //
      UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE));
    }
}                                       

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++);
    }
}                              
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.
    //

    IntMasterEnable();
        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);

    //
    // Prompt for text to be entered.
    //
    UARTSend((unsigned char *)"Enter text: ", 12);

    //
    // Loop forever echoing data through the UART.
    //
    while(1)
    {              
    }
}


UARTIntHandler(void)函数进不去,求大神指教

gnocy 发表于 2013-6-5 16:14:24

中断触发信号貌似没有看到,

NJ8888 发表于 2013-6-5 16:24:35

你的中断程序,没有处理接收中断部分

l4568527193 发表于 2013-6-5 16:48:33

NJ8888 发表于 2013-6-5 16:24 static/image/common/back.gif
你的中断程序,没有处理接收中断部分

    while(UARTCharsAvail(UART0_BASE))
    {
      //
      // Read the next character from the UART and write it back to the UART.
      //
      UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE));
    }

这是中断执行部分,是不是你说的呢

l4568527193 发表于 2013-6-5 16:49:35

gnocy 发表于 2013-6-5 16:14 static/image/common/back.gif
中断触发信号貌似没有看到,

中断触发信号是硬件给的还是软件给的

NJ8888 发表于 2013-6-5 16:49:51

l4568527193 发表于 2013-6-5 16:48 static/image/common/back.gif
while(UARTCharsAvail(UART0_BASE))
    {
      //


奥,开始没看到,断点能到吗?

l4568527193 发表于 2013-6-5 16:51:53

NJ8888 发表于 2013-6-5 16:49 static/image/common/back.gif
奥,开始没看到,断点能到吗?

断电不能到,在中断程序入口地方加led灯的,也不能指示

NJ8888 发表于 2013-6-5 16:55:33

l4568527193 发表于 2013-6-5 16:51 static/image/common/back.gif
断电不能到,在中断程序入口地方加led灯的,也不能指示

我查了下与你类似的代码,UARTCharPutNonBlocking(UART1_BASE,G_scitxbuf);他是用在发送中,那段接收上面的注释好像对不上

NJ8888 发表于 2013-6-5 16:58:29

ulStatus = UARTIntStatus(UART0_BASE, true);

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

        // Loop        while        there        are        characters in        the        receive        FIFO.
        //if ((ulStatus        &        UART_INT_RX) ||        (ulStatus        &        UART_INT_RT))
        if (ulStatus        &        UART_INT_RX)
        {
    G_commtime=GETSYSCLK;
        ...........................在我的串口中断是这样处理的

l4568527193 发表于 2013-6-5 17:02:26

NJ8888 发表于 2013-6-5 16:55 static/image/common/back.gif
我查了下与你类似的代码,UARTCharPutNonBlocking(UART1_BASE,G_scitxbuf);他是用在发送中,那段接收上 ...

这个应该怎么修改呢

l4568527193 发表于 2013-6-5 17:03:43

NJ8888 发表于 2013-6-5 16:58 static/image/common/back.gif
ulStatus = UARTIntStatus(UART0_BASE, true);

        // Clear the asserted        interrupts.


现在不是说是中断程序的处理问题,而是根本就进入不了接受数据的中断里面

tiancaigao7 发表于 2013-6-5 19:05:59

没有用过你这个型号的MCU(话说到现在还真不知道你是哪个型号的,看起来不像是STM32的)。不过我没有看到你使能接收呀?

severewinner 发表于 2013-6-5 19:28:00

tiancaigao7 发表于 2013-6-5 19:05 static/image/common/back.gif
没有用过你这个型号的MCU(话说到现在还真不知道你是哪个型号的,看起来不像是STM32的)。不过我没有看到你 ...

这个芯片不熟,不过同意楼上,

要是不能进中断无外乎几个问题,
时钟不对/没使能/代码有问题,主要这几个
即使波特率不对也可能会进中断的,先检查初始化

NJ8888 发表于 2013-6-8 21:43:12

本帖最后由 NJ8888 于 2013-6-8 21:44 编辑

tiancaigao7 发表于 2013-6-5 19:05 static/image/common/back.gif
没有用过你这个型号的MCU(话说到现在还真不知道你是哪个型号的,看起来不像是STM32的)。不过我没有看到你 ...

楼主使能过中断收发,他这代码我看与我用的TI LM3S很像,不过我重写了中断处理,他说的没进中断很奇怪,这个问题完全可以挂调试器查看相关寄存器来排除配置问题
IntEnable(INT_UART0);
    UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT);
页: [1]
查看完整版本: Cotex-3串口调试只能发送数据不能接受是在回事!!!!!