TI中文支持网
TI专业的中文技术问题搜集分享网站

tm4c123gxl的串口问题

效仿uart_echo的uart0通信,采用uart3,请问为什么发可以,但是收不可以

//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void
UARTIntHandler(void)
{
uint32_t ui32Status;

//
// Get the interrrupt status.
//
ui32Status = ROM_UARTIntStatus(UART3_BASE, true);

//
// Clear the asserted interrupts.
//
ROM_UARTIntClear(UART3_BASE, ui32Status);
//
// Loop while there are characters in the receive FIFO.
// while(ROM_UARTCharsAvail(UART3_BASE))
{
//
// Read the next character from the UART and write it back to the UART.
//
ROM_UARTCharPutNonBlocking(UART3_BASE,
ROM_UARTCharGetNonBlocking(UART3_BASE)); //
// Blink the LED to show a character transfer is occuring.
//
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
//
// Delay for 1 millisecond. Each SysCtlDelay is about 3 clocks.
//
SysCtlDelay(SysCtlClockGet() / (1000 * 3));
//
// Turn off the LED
//
GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);

}
}

//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
//
// Loop while there are more characters to send.
//
while(ui32Count–)
{
//
// Write the next character to the UART.
//
ROM_UARTCharPutNonBlocking(UART3_BASE, *pui8Buffer++);
}
}

//*****************************************************************************
//
// This example demonstrates how to send a string of data to the UART.
//
//*****************************************************************************
int
main(void)
{
//ʹÄÜFPU
ROM_FPUEnable();
ROM_FPULazyStackingEnable();

//ÉèÖÃʱÖÓÖ±½ÓʹÓÃÍⲿ¾§ÕñÔ´
ROM_SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_16MHZ);

//ʹÄÜLEDËùÓö˿Ú
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

//ʹÄÜÒý½Å
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

//ʹÄÜÍâÉè
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART3);
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);

//ʹÄÜÖÕ¶Ë
ROM_IntMasterEnable();

//ÅäÖô®¿Úuart3µÄÒý½Å
GPIOPinConfigure(GPIO_PC6_U3RX);
GPIOPinConfigure(GPIO_PC7_U3TX);
ROM_GPIOPinTypeUART(GPIO_PORTC_BASE, GPIO_PIN_6 | GPIO_PIN_7);

//115,200, 8-N-1 operation.
ROM_UARTConfigSetExpClk(UART3_BASE, ROM_SysCtlClockGet(), 115200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));

//ʹÄÜUART
ROM_IntEnable(INT_UART3);
ROM_UARTIntEnable(UART3_BASE, UART_INT_RX | UART_INT_RT);
//
// Prompt for text to be entered.
//
UARTSend((uint8_t *)"TEST ", 55);

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

xyz549040622:

ROM_UARTCharPutNonBlocking(UART3_BASE,

少个括号,竟然都没检查出来。用的什么编译器呀

weiqiu Chen:

回复 xyz549040622:

没少吧,

xyz549040622:

回复 weiqiu Chen:

看到了,崩溃,一个语句分两行,失误失误。

weiqiu Chen:

回复 xyz549040622:

这是我的.c文件,刚学不大会,那个uart0和其他uart有什么不一样吗

HG:

回复 weiqiu Chen:

大同小异,有的UART是第一功能的,不要SEL,有的是第二功能或者第三功能的,用的时候要注意

xyz549040622:

回复 weiqiu Chen:

没看到你写串口的接收函数,你是怎么判断不能接收的呢?接收函数类似这样的,把接收到的数据发送出去

do{//// Read a character using the blocking read function.This function// will not return until a character is available.//cThisChar = UARTCharGet(UART0_BASE);//// Write the same character using the blocking write function.This// function will not return until there was space in the FIFO and// the character is written.//UARTCharPut(UART0_BASE, cThisChar);}

xyz549040622:

回复 weiqiu Chen:

这么明显的错误,以后小心点。

赞(0)
未经允许不得转载:TI中文支持网 » tm4c123gxl的串口问题
分享到: 更多 (0)