Skip to main content
kiwironnie
Associate III
August 2, 2020
Solved

Nucleo-L433RC-P garbage from USARTs - why?

  • August 2, 2020
  • 17 replies
  • 4419 views

Using STM32CubeIDE to create a USART test project with default code generated, the USART is outputting garbage e.g. �)���?�+Ѵ# on a terminal (USB to PC).

Yet using exactly the same default code generation process and same simple test code on two other Nucleo boards Nucleo-L432 and Nucleo-L073RZ a "hello world" test string is printing fine.

Have tried various configuration changes, to clocks etc on the L433RC to no avail.

Have checked the output with a logic analyzer, which shows the same garbage. Have played with baud rates, word length etc to no avail.

Exactly the same problem with USART2 and with USART1. Strangly, carriage return and line feed are being output correctly as 0D and 0A (which is a pretty good indicator that baud rate etc is ok). The garbage ASCII is generally the same hex output but sometimes varies.

The main test programme is very simple. Default setup code generated by STM32CubeIDE plus the following:

#include <stdio.h>

#include <string.h>

char message[] = "Hello World\r\n";

HAL_UART_Transmit(&huart2, (uint8_t*) message, strlen(message), 10000);

HAL_Delay(1000);

Other functions on the board seem to be fine, e.g. comparators, DAC output etc. Going nuts! Is there anything else that might be worth trying?

This topic has been closed for replies.
Best answer by waclawek.jan

There have been issues with Cube-generated code setting incorrectly the HSI trim (https://community.st.com/s/question/0D50X00009XkfHp/erroneous-hsi-default-trim-value-in-datasheetcubemx https://community.st.com/s/question/0D50X00009XkfyS/stm32l452ceu6-hsi-problem posts were mingled by the botched migration between forum softwares, recently https://community.st.com/s/question/0D50X0000BYocRMSQZ/stm32h7-64mhz-hsi-is-off-by-4 ).

I personally wouldn't rely on an internal RC oscillator for UART at all, but YMMV. And I don't use Cube.

JW

17 replies

NKhan.7
Visitor II
September 11, 2020

Looks like a CubeID's but for STM32L432KC as well. I've been manually changing the value after genereating code. But I like your approach of the #define better.

 #define RCC_HSICALIBRATION_DEFAULT 0x10U 

kiwironnie
Associate III
September 11, 2020

Glad the workaround was of help. It would have been good to have done a bit more investigation, as per Jan's questions, but time is the enemy. Cheers Ron.