cancel
Showing results for 
Search instead for 
Did you mean: 

Possible bug in HAL USART Driver

andrewtholt60
Associate
Posted on September 11, 2016 at 16:41

I am experimenting with FreeRTOS and the HAL layer using an STM32F4 DISCO board.

I have two threads.  One reads from the serial port and send the byte read, in a message to a second task.

The second task, blocking on a message reads it and sends the byte out through the same serial port.

What I get is that the second task always get HAL_BUSY.  If my reading of the code is correct this means that the USART is locked. ( ?)

On inspection of the code for HAL_UART_Receive I have noticed that __HAL_LOCK(huart) returns if it can't acquire the lock.  However if it succeeds in acquiring the lock but later times out then a return is made whilst the lock is still held.

Any subsequent call to either HAL_UART_Receive or HAL_UART_Transmit will fail with HAL_BUSY.  I would like to suggest two potential fixes.

1) TX & RX each has it's only lock.  So I can send whilst receive is busy and vice-versa.

2) The receive and transmit routines need restructuring to set a status and return it to the caller AFTER the lock has been released.

or has all this been fixed already and I'm running something old ?

Regards,

Andrew

2 REPLIES 2
Walid FTITI_O
Senior II
Posted on September 20, 2016 at 18:15

Hi holt.andrew,

I suggest that you run and teston the UART example of the last version of STM32cube firmware package relevant to the device that you are using. Try the for example the

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-embedded-software/stm32cubef4.html

for STM32F4xx device at this path:

STM32Cube_FW_F4_V1.13.0\Projects\STM324xG_EVAL\Examples\UART

And come back with the feedbacks then .

-Hannibal-

anjana087
Associate II
Posted on September 24, 2016 at 07:59