UARTConfigSetExpClk(UART0_BASE, g_ui32SysClock, 19200,
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
UART_CONFIG_PAR_NONE));
UARTEnable(UART0_BASE);
//
// Put a character to show start of example. This will display on the
// terminal.
//
UARTCharPut(UART0_BASE, 0xaa);
//
// Enter a loop to read characters from the UART, and write them back
// (echo). When a line end is received, the loop terminates.
//
do
{
//
// Read a character using the blocking read function. This function
// will not return until a character is available.
//
// cThisChar = UARTCharGet(UART0_BASE);
while(!UARTCharsAvail(UART0_BASE))
{
}
cThisChar =UARTCharGetNonBlocking(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.
//
if(cThisChar==0xac)
{
for(i=0;i<25;i++)
{
UARTCharPut(UART0_BASE, i);
SysCtlDelay(SysCtlClockGet()/(1000*3));
}
}
else
{ UARTCharPut(UART0_BASE, 0xaa);
UARTCharPut(UART0_BASE, 0xaa);
UARTCharPut(UART0_BASE, cThisChar);
}
}
while(1);
请问我用这样的代码跑串口,发现发送没有问题,接收数据错误,芯片是 TM4C1294
还有将 g_ui32SysClock 改为 SysCtlClockGet(),连发送都不对,谢谢