2024-05-07 01:14 AM
static volatile bool g_sendDone;
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
g_sendDone = true;
}
static void EnterCritical() {
__HAL_UART_DISABLE_IT(&huart1, UART_IT_TC);
}
static void ExitCritical() {
__HAL_UART_ENABLE_IT(&huart1, UART_IT_TC);
}
void TrySend() { // run periodically
EnterCritical();
if (g_sendDone) {
// meant to send more
// doing nothing here also triggers HAL_UART_TxCpltCallback
}
ExitCritical(); // calls HAL_UART_TxCpltCallback after this line, even if there is no transmission
}
Is there a good way to disable and enable transmit complete interrupt, and leave other interrupts enabled, such as transmit register empty interrupt?
2024-05-07 01:20 AM
Well there's only One interrupt handler and all the UARTs interrupts will go thru that.
You can enable bits in the ISR.
What's signaling in the unexpected case? Interrupts will continue to occur if the source is not correctly cleared and serviced.
2024-05-07 05:33 PM
Thanks for the reply. I've done an experiment to read the USART's registers' values