cancel
Showing results for 
Search instead for 
Did you mean: 

I have STM32F407VG Discovery Board with me But i am not able to see any output on Teraterm for UART program

APuri.1
Associate

#include "main.h"

UART_HandleTypeDef huart3;

uint8_t data[]="Hello world\n";

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_USART3_UART_Init(void);

int main(void)

{

 HAL_Init();

 SystemClock_Config();

 MX_GPIO_Init();

 MX_USART3_UART_Init();

 while (1)

 {

 HAL_UART_Transmit(&huart3, data, sizeof(data), 100);

 HAL_Delay(500);

 }

}

void SystemClock_Config(void)

{

 RCC_OscInitTypeDef RCC_OscInitStruct = {0};

 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 __HAL_RCC_PWR_CLK_ENABLE();

 __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);

 /** Initializes the CPU, AHB and APB busses clocks 

 */

 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;

 RCC_OscInitStruct.HSEState = RCC_HSE_ON;

 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;

 RCC_OscInitStruct.PLL.PLLM = 4;

 RCC_OscInitStruct.PLL.PLLN = 50;

 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

 RCC_OscInitStruct.PLL.PLLQ = 4;

 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 {

  Error_Handler();

 }

 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;

 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)

 {

  Error_Handler();

 }

}

static void MX_USART3_UART_Init(void)

{

 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;

 if (HAL_UART_Init(&huart3) != HAL_OK)

 {

  Error_Handler();

 }

}

static void MX_GPIO_Init(void)

{

 __HAL_RCC_GPIOH_CLK_ENABLE();

 __HAL_RCC_GPIOB_CLK_ENABLE();

}

void Error_Handler(void)

{

 /* User can add his own implementation to report the HAL error return state */

}

#ifdef USE_FULL_ASSERT

void assert_failed(uint8_t *file, uint32_t line)

 /* User can add his own implementation to report the file name and line number,

   tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

}

#endif

2 REPLIES 2

Where are the pins actually configured?

What pins are used?

What are they connected too and how?

VCP on this DISCO board is not wired.

UART pin are CMOS levels and not directly RS232 compatible.​

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

PB10 and PB11 pins are used as TX and RX of USART3

PB10(TX) is connected to RX of CH340 USB to serial device

PB11(RX) is connected to TX of CH340 USB to serial device

And I was looking for "Hello world" message to be printed on the serial monitor

Help me out

pleaseeeeeeeeee