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.

[参考译文] MSP430FR5994:如何检测 UART 传输结束?

Guru**** 2487425 points
Other Parts Discussed in Thread: MSP430FR5994

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

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1226584/msp430fr5994-how-to-detect-end-of-uart-transmission

器件型号:MSP430FR5994

你好
自动翻译。

使用 MSP430FR5994
在连接到实际输出485半双工端口的板载485适配器时、使用 UART。

在485适配器中、我需要通过 Tx 模式和 Rx 模式之间的 GPIO 引脚传输它。
我注意到、如果我这样进行广播:

//Set 485 Tx
GPIO_setOutputHighOnPin(GPIO_PORT_P4, GPIO_PIN0);
GPIO_setOutputHighOnPin(GPIO_PORT_P4, GPIO_PIN3);
EUSCI_A_UART_transmitData(EUSCI_A1_BASE, “1”);
//Set 485 Rx
GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN0);
GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);

所以在485时、我什么也得不到。
但是、如果我这样进行广播:
//Set 485 Tx
GPIO_setOutputHighOnPin(GPIO_PORT_P4, GPIO_PIN0);
GPIO_setOutputHighOnPin(GPIO_PORT_P4, GPIO_PIN3);
EUSCI_A_UART_transmitData(EUSCI_A1_BASE, “1”);
__delay_cycles(1000);
//Set 485 Rx
GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN0);
GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN3);

因此能够很好地接收字节。

我明白这是因为以及实际上在这个函数:EUSCI_A_UART_translData (EUSCI_A1_base、"1");
重复、这可能仍然不意味着发送已完成、因此当我立即将485适配器返回到 Rx 模式时、实际上证明 Tx 不完美、因此字节丢失。
我需要在发送后立即返回到 Rx、因为我希望收到回复、因此如果我将__delay_cycles 设置得过长、我将丢失返回的字节。

我的问题是、如何能够识别 UART 中的字节发送已完成?

谢谢。

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

    当 UART 空闲时、UCBUSY 变为低电平、 因此您希望等待 UCBUSY=0、使用类似的命令:

    > while (EUSCI_A_UART_queryStatusFlags (EUSCI_A1_BASE、EUSCI_A_UART_BUSY)/* empty*/;//等待 UART 进入空闲状态