器件型号: LP-MSPM0G3519
您好:
在我们的工程中、我们希望连接到半双工 UART 连接。 为避免在发送数据时写入 MCU UART RX FIFO、应将 UART 方向更改为 TX、并在传输结束时返回 TX_RX。
在 driverlib 中、我偶然发现了 DL_UART_ChangeConfig () 函数、在对 UART CTL0 寄存器进行任何更改之前应调用该函数、例如更改 UART 方向:
/**
* @brief Prepares the UART to change the configuration
*
* If the UART has already been enabled, then it is recommended to call this
* function before calling other APIs that make changes to the CTL0 register.
* If changes are made to the CTL0 register without disabling the UART, then
* results are unpredictable. This API performs the following:
* 1. Disable the UART.
* 2. Wait for the end of transmission or reception of the current character.
* 3. Flush the transmit FIFO by clearing bit FEN in the UART control
* register CTL0.
*
* @post After calling this API, the user must be re-enabled by calling
* @ref DL_UART_enable.
*
* @param[in] uart Pointer to the register overlay for the peripheral
*/
__STATIC_INLINE void DL_UART_changeConfig(UART_Regs *uart)
{
DL_UART_disable(uart);
while (DL_UART_isBusy(uart)) {
;
}
DL_UART_disableFIFOs(uart);
}
我想知道这是如何工作的、因为首先禁用 UART、这样会阻止传输任何数据、因此 TXFIFO 无法再被清除。 由于一旦 FIFO 或 TXDATA 不为空、就会设置状态繁忙、并且使能状态对状态繁忙没有任何影响(请参阅勘误表 UART_ERR_08)、因此在我看来只是时间问题、直到我永远回到 while 循环中。
如果有人可以确认这一点或向我解释我的错地方、那将是很好的。
提前感谢。