cancel
Showing results for 
Search instead for 
Did you mean: 

UART RX not working on Nucleo-H723

MHoop.1
Senior

I am trying to get the USART2 working on my Nucleo-H7 board. I am using HAL_UART_Transmit for the TX side. This works fine. But when I use HAL_UART_Receive on the RX side, there is never any RX data coming into the device. I have stepped through the HAL lower layers and watched the SFRs for any activity, but there is never any activity on the RX side (the RXNE bit never toggles). I'm starting to wonder if there is a hardware issue with the Nucleo board.

My project is an enhancement of the NX-TXP_Echo_Server example which receives 64 bytes received from the ethernet interface, and forwards the 64 byte command to the USART device to be used by another board. The remote board basically echoes the serial data received from the Nucleo board. Again the TX function of the Nucleo board works fine. But the RX side never sees any data received by the chip.

I have a scope on the TX and RX lines and can verify that the remote board is indeed receiving the data sent to if from the Nucleo, and it indeed does send a 64 byte response to the Nucleo board. It just never shows up in the Receive Data Register of the Nucleo USART2.

Since the TX side of the USART2 is working, I assume the USART is being properly initialized. And since I never see any data at the Receive Data Register (while monitoring the Special Function Registers in CubeIDE), I assume that I am missing some initialization of the RX side, or there is a hardware issue.

Can anyone offer some debugging suggestions?

Thanks

MikeH

3 REPLIES 3

Show the relevant code.. stuff initializing the peripheral and related pins.

Check clocks on GPIO

Check pins, and mode / AF settings

Check plumbing to edge of board, watch for schematic difference on differ models, check solder bridges, and conflicting usage.

Make sure to clear any noise, framing, overrun, or other reception errors which will block reception.

Make sure RX mode is enabled, the port can be configured as TX only.

RX has no depth, you can't use blocking HAL UART functions to TX and RX

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
MHoop.1
Senior

Figured it out. BITTEN AGAIN BY STM AND HAL. WASTED ~1 WEEK.

So it turns out that the example code generated by CubeIDE for the H7 Nucleo board creates code that does not work for the Nucleo board's USART2. The code allocates the USART2 RX line to PA3. The board layout connects USART2 RX to PD6! Once I changed this assignment, the RX data successfully makes its way to the USART RX buffer.

Bug City!

    /**USART2 GPIO Configuration
    PA3     ------> USART2_RX
    PD4     ------> USART2_DE
    PD5     ------> USART2_TX
    */
    GPIO_InitStruct.Pin = GPIO_PIN_3;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
    HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
 
    GPIO_InitStruct.Pin = GPIO_PIN_4|GPIO_PIN_5;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

>  BITTEN AGAIN BY STM AND HAL.

It is not STM and not HAL. The Cube has lost the linkage to the specific board context. This maybe should be a bug report.

> WASTED ~1 WEEK.

Congratulations for unlocking an experience level ))