cancel
Showing results for 
Search instead for 
Did you mean: 

UART printing gibbersh to TeraTerm

NicRoberts
Senior II

NUCLEO F767ZI, CubeIDE 2.1.1, CubeMX 6.17.0

I'm trying to set up UART with printf()

#include <stdio.h>

UART_HandleTypeDef huart3;
static void MX_USART3_UART_Init(void);

int __io_putchar(int ch)
{
    HAL_UART_Transmit(&huart3, (uint8_t *)ch, 1, 10);
    return ch;
}

....
// in main
// in while
prinf("UART test\r\n");

// MX generated USART3 init
static void MX_USART3_UART_Init(void)
{

  /* USER CODE BEGIN USART3_Init 0 */

  /* USER CODE END USART3_Init 0 */

  /* USER CODE BEGIN USART3_Init 1 */

  /* USER CODE END USART3_Init 1 */
  huart3.Instance = USART3;
  huart3.Init.BaudRate = 115200;
  huart3.Init.WordLength = UART_WORDLENGTH_8B;
  huart3.Init.StopBits = UART_STOPBITS_1;
  huart3.Init.Parity = UART_PARITY_NONE;
  huart3.Init.Mode = UART_MODE_TX_RX;
  huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart3.Init.OverSampling = UART_OVERSAMPLING_16;
  huart3.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
  huart3.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
  if (HAL_UART_Init(&huart3) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN USART3_Init 2 */

  /* USER CODE END USART3_Init 2 */

}

 

Clock tree from MX

MX_CLK_Tree.jpg

 

Output in Tera Term window

TT_window.png

 

TT is set up exactly the same as the UART init in the code.

Anyone know whats going on here?

21 REPLIES 21

@CTapp.1 wrote:


GCC does generate a warning for it:


@NicRoberts  did you not get a warning, then?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

No warnings.