cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4+ issues when using UART with interrupts

zous
Associate II

Dear community,

I am using the Nucleo-L4R5ZI board with STM32L4R5ZI chip embedded to experiment UART.

Unfortunately, I am facing an issue when using interrupts.

I looked up through the BSP (STM32Cube_FW_L4_V1.15.1) provided by ST if examples were using the UART but I did find examples for my board ...

I have configured my UART as follow (115200-8N1). My UART instance is LPUART1. Interrupts are enabled like below whithin the

HAL_UART_MspInit function :

   /* LPUART1 interrupt Init */

   HAL_NVIC_SetPriority(LPUART1_IRQn, 0, 0);

   HAL_NVIC_EnableIRQ(LPUART1_IRQn);

I used STM32CubeMX to generate the code.

I am using the same UART to print "debug" traces and the STLINK.

When I use a printf(...) I got my traces without any problems.

Now, I would like to send from my terminal, for example, an "Hello World!", once the transfer is done, I send from the board a TxBuffer containing "****UART_TwoBoards_ComIT**** ****UART_TwoBoards_ComIT**** ****UART_TwoBoards_ComIT****".

The problem is that I never got the UART ready to step forward and send the TxBuffer.

When using the debugger I always got at the end of HAL_UART_Receive_IT function a HAL_OK ...

The Rxbuffer is not populated and the HAL_UART_RxCpltCallback is never called.

I don't understand what's happening and I am stuck with this issue...

On the other side, when I use HAL_UART_Receive without interrupts, everything works well.

Who has already faced this kind of issue and tips are very appreciated to help me to step forward.

PS: I attached to the post my test project if it could help.

Thank you n advance for your help,

Regards

1 REPLY 1
Jack Peacock_2
Senior III

I came across this problem on STM32F1s and F4s. If you are waiting for a TXNE interrupt to start right after initializing the USART it won't occur. TXE is edge triggered, the output buffer has to transition from data to empty. If there's no initial data loaded the IRQ never occurs.

What I do is check for TXE empty first. If so I load the first output character before switching to DMA for the rest of the buffer. If TXE isn't asserted go directly to DMA since it's sending data already. In your case you should see TXEs after each byte.

Jack Peacock