2021-07-09 05:40 AM
I am using stm32f4xx, and I am using UART with DMA normal mode.
I have a problem with the Transmit Completed state, When I using the TxCompletedCallbacks I get hard fault error so I learned it does not using with normal mode so I am trying the Transmit Completed fnished with TC flag as I look the referance manual.
I enabled this interrupt:
__HAL_UART_ENABLE_IT(&huart2, UART_IT_TC)
Than I set the flag when the TC is set like this in USART2 interrupts;
void USART2_IRQHandler(void)
{
if( (__HAL_UART_GET_FLAG(&huart2, UART_FLAG_TC) == SET))
{
txCmp = 1;
// __HAL_UART_CLEAR_FLAG(&huart2, UART_FLAG_TC);
// }
}
}
when the txCmp = 1 than I check this flag in main.c loop than, I set the rs485 tranceiver to receiver mode but again I get Hardfault error how can I detect Transmit completed and set the transceiver receive mode correctly ?
2021-07-09 01:56 PM
Usually the DMA stream transfer complete interrupt is the one that is used here. I'm not sure if the USART TC will behave similarly here.
What's the reason for the hard fault? Observe SCB registers.
2021-07-11 10:40 PM
when I use the if( (__HAL_UART_GET_FLAG(&huart2, UART_FLAG_TC) == SET) line detect the transmit completed, but this line does not detect correctly, sometimes this line does not work, but when I use HAL_UART_TxCpltCallback working correctly and detects all transmit completed flags why this happening ?
2021-07-12 07:12 AM
Did you read what I wrote? HAL doesn't use this flag.