cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Francesco_
Associate II

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

13 REPLIES 13
Francesco_
Associate II

Below, i show RCC and USART2 registers. I see in RCC->CR register that HSE not ready (17th bit) and in CFGR HCLK divided by 16 (bit [13:8]). Someone can tell me another test for check of the clock functionality? I used uVision.

0693W000000UbKwQAK.png0693W000000UbKrQAK.png

Francesco_
Associate II

Someone can help me? I don't find the problem.

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.

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

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 =)