Skip to main content
TKopp.67
Associate III
June 3, 2022
Solved

NUCLEO STM32L073 USART2 RX doesn't work

  • June 3, 2022
  • 4 replies
  • 2625 views

Hi everyone,

I'm currently trying to implement USART2 in the Nucleo STM32L073, but despite i see frames coming from the other chip, i can't have any interrupt in RX (configured to get byte by byte). I also tried the polling method but it doesn't work better. I may be missing something obvious.

Here is my code :

init code :

0693W00000Nr9fkQAB.pngthe interrupt init (called before to get any byte) :

0693W00000Nr9g9QAB.pngthe interrupt routine (of course usart interrupt activated in IOC file) :

0693W00000Nr9giQAB.png 

UART2 pins are mapped as PA2/PA3 and so if i understood well the RX pin should be the bottom left pin of the CN10 (when you look at the board from over).

Here is the USART2 registers when waiting for the byte :

0693W00000Nr9iFQAR.pngDo i miss something or someone has any idea ?

Thanks in advance for your answer,

Best Regards,

Thomas

This topic has been closed for replies.
Best answer by Guenael Cadier

Dear @TKopp.67​ 

ISR at 0x6000d0 indicate that RXNE bit is 0, so nothing received from UART point of view yet. RXNE interrupts will be triggered when RXNE will raise to 1.

I think it could be related to HW configuration of your NUCLEO L073, with PA2/PA3 not connected to CN10.

0693W00000Nr9nAQAR.jpg(OFF in bold indicates it is the default setting).

Please have a look at UM1724, available here

Hope this helps.

Regards

4 replies

Guenael Cadier
Guenael CadierBest answer
ST Employee
June 3, 2022

Dear @TKopp.67​ 

ISR at 0x6000d0 indicate that RXNE bit is 0, so nothing received from UART point of view yet. RXNE interrupts will be triggered when RXNE will raise to 1.

I think it could be related to HW configuration of your NUCLEO L073, with PA2/PA3 not connected to CN10.

0693W00000Nr9nAQAR.jpg(OFF in bold indicates it is the default setting).

Please have a look at UM1724, available here

Hope this helps.

Regards

Mike_ST
ST Technical Moderator
June 3, 2022

Hello,

PA2/PA3 are the ST-Link's UART pins, so you probably want to remove SB14/SB13.

Please check the schematic, you'll see on page 1 that USART_RX is connected to STLK_RX.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. 
Pavel A.
June 3, 2022

@TKopp.67​ This line: __HAL_UART_GET_IT_SOURCE(&huart2, UART_IT_RXNE)

is suspicious, because when RxCpltCallback is called, the received byte is already moved so the RX interrupt bit clears.

Generally the UART HAL routines are not good for anything beyond quick tests, especially one byte RX.

Roll your own, or use DMA.

TKopp.67
TKopp.67Author
Associate III
June 3, 2022

Thanks that was indeed my problem, now i just in the callback but get's overrun error. Anyway i will try to understand why it happens now.

Have a nice day,

Best Regards,

Thomas