AnsweredAssumed Answered

CubeMX's UART can not receive and transmit at the same time

Question asked by ll.hgyxb on May 4, 2017
Latest reply on May 8, 2017 by ll.hgyxb

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?

Outcomes