Trouble getting RX to work on USART's

Not sure yet. BTW that ret variable maps to error codes:

HAL_OK       = 0x00,
HAL_ERROR    = 0x01,
HAL_BUSY     = 0x02,
HAL_TIMEOUT  = 0x03

I’m getting HAL_BUSY when I introduce the 1ms delay. If we look at the receive code that tells us that we are failing this check huart->RxState == HAL_UART_STATE_READY.
The comment there says Check that a Rx process is not already ongoing.

Running the debug probe confirms we’re in state HAL_UART_STATE_BUSY_RX.

Ok so we’re hitting the timeout when you introduce the 1ms delay. That then causes the cascade effect of the busy state.

So there’s one bug to fix. One timeout shouldn’t cause the code to then be stuck in the busy state forever.
The question still remains, why does an extra ms delay cause the code to fail to read any more data and just timeout repeatedly?

Edit: Stephen will be back in soon if I’m unable to find a solution before then. Definitely found something interesting!

1 Like