2017-05-03 11:47 PM
CubeMX V1.12.0
I write below code to receive one bye and one bye:
HAL_UART_Receive_IT(&huart1, (T_U8*)&g_uart_receive_byte, 1);
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{ if(huart == &huart1) { //get the byte DrvUartOnReceiveOneByteAtInterupt(g_uart_receive_byte); //receive next byte HAL_UART_Receive_IT(huart, &g_uart_receive_byte, 1); }}and in the main I use HAL_UART_Transmit to transmit data.
but when HAL_UART_Transmit is doing, a new buffer is received and
HAL_UART_RxCpltCallback will be called, then HAL_UART_Receive_IT will be fail because HAL_UART_Transmit has call __HAL_LOCK(huart).
I think HAL_UART_Transmit and
HAL_UART_Receive_IT should not use the same lock, they should can use at same time.
Is it right?
#cubemx #uart2017-05-04 02:42 AM
Hi
ll.hgyxb
,There is examples describing UART transmission (transmit/receive) by using an interrupt: data buffers transmission/reception are done simultaneously.
Khouloud.
2017-05-07 10:11 PM
Sorry, there is a mistake, the version is STM32Cube_FW_F4_V1.12.0 and
CubeMX 4.18.0 I used.
The example is use a flag at interrupt to notify the receive event and check the flag at main task.
But I think we can handle it at the interrupt and it can handle at once.