This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] LP-MSPM0G3519:关于 UART_ERR_08 和 DL_UART_changeConfig () 的混淆

Guru**** 2872490 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1638652/lp-mspm0g3519-confusion-regarding-uart_err_08-and-dl_uart_changeconfig

器件型号: 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 循环中。

如果有人可以确认这一点或向我解释我的错地方、那将是很好的。  

提前感谢。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Timon、

    我认为你的理解是正确的。 这也是我们建议客户在 UART 传输结束时更改 UART 配置的原因 我认为这个 API 可能需要进行一些修改。

    此致、

    Janz Bai

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好 Janz、  

    感谢您的答复并确认我的想法。 然后、我将实施的修改型号  DL_UART_changeConfig().

    我认为修改 API 以进行澄清是不错的。  

    此致