TM4C1294 使用 UART2 口, 接485 芯片, 使用直接写寄存器方式send 数据, 有时在 send 完数据后,会导致 UART 寄存器 RXFE 被置为 0 , 也即是接收到了数据,请问这是什么问题?
如果单步执行,还没有发现 RXFE 被置为0 ,如果全速运行,30% 的可能性。
代码里 send 第一步是设置 485 为发送模式。
void _UARTSend(uint8_t index,const uint8_t *pui8Data, uint32_t ui32Size)
{
HWREG(uart_normal_setting[index].UART_GPIO_Port + (GPIO_O_DATA + (uart_normal_setting[index].UART_GPIO_SR_PIN << 2))) = uart_normal_setting[index].UART_GPIO_SR_PIN;
while(ui32Size--)
{
//
// Make sure that the transmit FIFO is not full.
//
while((HWREG(uart_udma_setting[index].UART_BASE + UART_O_FR) & UART_FR_TXFF))
{
}
//
// Send out the next byte.
//
HWREG(uart_udma_setting[index].UART_BASE + UART_O_DR) = *pui8Data++;
}
//
// Wait until the UART is done transmitting.
//
_UARTFlush(index);
}
void _UARTFlush(uint8_t index)
{
//
// Wait for the UART FIFO to empty and then wait for the shifter to get the
// bytes out the port.
//
while(!(HWREG(uart_udma_setting[index].UART_BASE + UART_O_FR) & UART_FR_TXFE))
{
}
//
// Wait for the FIFO to not be busy so that the shifter completes.
//
while((HWREG(uart_udma_setting[index].UART_BASE + UART_O_FR) & UART_FR_BUSY))
{
}
}