2020-09-07 07:10 PM
Hi
I'm doing a project to detect collision on UART, when I get data from Rx, I will compare it with the data I transmitted, if there aren't the same, means collision occurred, then I will immediately stop my transmitting interrupt to stop sources waste on the bus.
I am using
HAL_UART_Transmit_IT(&huart1, Message1.data, length);
to transmit data,
I tried
UART_EndTransmit_IT(huart);
, but this function is not declared in main, so I directly write
CLEAR_BIT(huart1.Instance->CR1, USART_CR1_TCIE);
huart1.gState = HAL_UART_STATE_READY;
but the result is when I detected collision, the transmit yes stop, but then I recall HAL_UART_Transmit_IT(&huart1, Message1.data, length); transmit is not working, is there any more register I need to clear? or are there any other way to stop transmit interrupt during transmitting?
Solved! Go to Solution.
2020-09-08 12:58 AM
Dear @Olly Kao ,
Indeed, UART_EndTransmit_IT() is not expected to be called in Application code.
In order to abort transmit sequence, and to allow further calls to HAL_UART_Transmit_IT(), I would recommend use of dedicated HAL UART API, in blocking mode :
Similar primitives exist in non blocking mode, with execution of callbacks when Abort operations is completed ;
Regards
2020-09-08 12:58 AM
Dear @Olly Kao ,
Indeed, UART_EndTransmit_IT() is not expected to be called in Application code.
In order to abort transmit sequence, and to allow further calls to HAL_UART_Transmit_IT(), I would recommend use of dedicated HAL UART API, in blocking mode :
Similar primitives exist in non blocking mode, with execution of callbacks when Abort operations is completed ;
Regards