Skip to main content
Francesco_
Associate III
March 14, 2020
Solved

Board: NUCLEO F103RB I have this problem with UART, the serial monitor show: x⸮x⸮x⸮x⸮... Why i have this beaheviour? I use UART2 (PA2 - PA3 board pin) and I connect the board at the PC trought USB cable.

  • March 14, 2020
  • 13 replies
  • 5730 views

This is the code:

 /* USER CODE BEGIN WHILE */

 while (1)

 {

HAL_GPIO_WritePin(GPIOA , LED_Pin, GPIO_PIN_SET);

HAL_Delay(10);

HAL_GPIO_WritePin(GPIOA , LED_Pin, GPIO_PIN_RESET);

HAL_Delay(10);

char p[] = "128";

HAL_UART_Transmit(&huart2, (uint8_t*)p , sizeof(p), HAL_MAX_DELAY);

HAL_Delay(200);

 }

This is the UART config:

/* USER CODE END USART2_Init 1 */

 huart2.Instance = USART2;

 huart2.Init.BaudRate = 9600;

 huart2.Init.WordLength = UART_WORDLENGTH_8B;

 huart2.Init.StopBits = UART_STOPBITS_1;

 huart2.Init.Parity = UART_PARITY_NONE;

 huart2.Init.Mode = UART_MODE_TX_RX;

 huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart2.Init.OverSampling = UART_OVERSAMPLING_16;

 if (HAL_UART_Init(&huart2) != HAL_OK)

 {

  Error_Handler();

 }

The attachment show the clock configuration:0693W000000TwCNQA0.png

This topic has been closed for replies.
Best answer by Tesla DeLorean

You are hard to help. You have no test equipment, you don't post a complete compilable project.

Check that the solder bridges (SB) for the MCO / HSE are present. This may depend on board version in uses, and most of the HAL examples for the NUCLEO-F103RB use HSI to clock at 64 MHz. Boards MB1136 C-01 don't have HSE connected.

https://www.st.com/resource/en/user_manual/dm00105823-stm32-nucleo64-boards-mb1136-stmicroelectronics.pdf

Check

SB54 ON

SB55 OFF

SB16 ON

SB50 ON

>>HAL_UART_Transmit(&huart2, (uint8_t*)p , sizeof(p), HAL_MAX_DELAY);

Use strlen() or sizeof()-1 so you don't transmit the NUL characters

This uses USART1 via PA9 / PA10, clocks the board at 64 MHz, you could modify this

STM32Cube_FW_F1_V1.8.0\Projects\STM32F103RB-Nucleo\Examples\UART\UART_Printf

Would be usable with a USB-to-CMOS Serial type adapter from SiLabs, etc.

In the days prior to having a scope, I used a Logic Probe to identify High, Low, and Clocking signals.

13 replies

Francesco_
Associate III
March 24, 2020

Thanks clive1,

i have a MB1136 C-01 board and the oscillator HSE not present, I have read the document.

I had not pay attention because i thought use X1 oscillator.

I will satisfied of 64 MHz =)