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.
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: