cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to display messages on Tera Term via USART1 on STM32F429I-Discovery

chachamaru
Associate III

Post edited by ST moderator to be inline with the community rules for the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code.

Hello,

I’m using the STM32F429I-Discovery board and trying to display “Hello World” on Tera Term via USART1 (PA9, PA10).

I configured the project in STM32CubeIDE as follows:

  • USART1 → Mode: Asynchronous

  • TX: PA9, RX: PA10

  • Baudrate: 115200, 8N1, No Flow Control

  • Using the ST-LINK Virtual COM Port (USB connector CN1)

 

main.c

HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_USART1_UART_Init();

const char msg[] = "Hello World\r\n";
HAL_UART_Transmit(&huart1, (uint8_t*)msg, sizeof(msg)-1, HAL_MAX_DELAY);
while (1)
{
HAL_UART_Transmit(&huart1, (uint8_t*)"Hello Again\r\n", 13, HAL_MAX_DELAY);
HAL_Delay(1000);
}

However, nothing appears on Tera Term.
The “ST-LINK Virtual COM Port (COMxx)” is visible in the Windows Device Manager, and I’ve selected the correct COM port in Tera Term.
Also, when I checked the PA9 pin with an oscilloscope, there was no signal output.

Has anyone successfully used USART1 on the F429I-Discovery board?
Any advice or examples on how to correctly enable UART output on this board would be greatly appreciated

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

Unfortunately I can't try with Tera Term right now but I can try with Hercule.

Attached a project where "Hello World" is printed in Hercule interface:

mALLEm_0-1762445770158.png

The HyperTerminal config:

mALLEm_1-1762445809340.png

PS: the code you shared in your last post should be used with two boards. You need to read the readme file of the example before to run the example. 

Ensure: SB11, SB15 are soldered and JP4 is not fitted.

mALLEm_2-1762446170486.png

Hope that helps

 

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

19 REPLIES 19
mƎALLEm
ST Employee

Hello,

Are you sure about the board reference you are using? Is it STM32F429I-Discovery or NUCLEO-F429 board?

When you are talking about USART1 (PA9, PA10) it seems you are using NUCLEO-F429 board.

So please clarify that point.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@mƎALLEm wrote:

When you are talking about USART1 (PA9, PA10) it seems you are using NUCLEO-F429 board.


The 32F429IDISCOVERY manual says they are the correct pins:

AndrewNeil_0-1762338646576.png

https://www.st.com/resource/en/user_manual/um1670-discovery-kit-with-stm32f429zi-mcu-stmicroelectronics.pdf#page=15

via: https://www.st.com/en/evaluation-tools/32f429idiscovery.html#documentation

 

@chachamaru are you sure that your board hasn't been reconfigured (SB11 and/or SB15)?

 

Also, are you sure it's actually a STM32F429I-DISC1, not the older STM32F429I-DISCO ?

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.
Andrew Neil
Super User

@chachamaru wrote:

I checked the PA9 pin with an oscilloscope, there was no signal output.


What about PA10 - ie, is stuff transmitted by the PC arriving at the STM32?

(beware that terminal software may buffer stuff)

 


@chachamaru wrote:

Any ... examples on how to correctly enable UART output on this board 


Have you tried the ready-made examples in STM32CubeIDE ?

 

PS:

Are you sure that your code has actually been built and downloaded to the board?

Have you tried stepping it in the debugger?

 

PPS:

Looking at your code, it has the MX_GPIO_Init() and MX_USART1_UART_Init() as typically generated by CubeMX, but none of the accompanying comments typically generated; eg,

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */
  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */
  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_SPI2_Init();
  MX_TIM6_Init();
  MX_USART2_UART_Init();
  MX_TIM16_Init();

  /* USER CODE BEGIN 2 */

 

In particular, you have none of the  /* USER CODE xxx */ comments - so all of your code will be deleted if you regenerate the project.

Could this be what's happened ... ?

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.

@Andrew Neil wrote:

 

Also, are you sure it's actually a STM32F429I-DISC1, not the older STM32F429I-DISCO ?


Need to confirm first if the used board is a DISCO board and NOT a Nucleo board!

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Thank you for replying.

I accidentally clicked "Accept as Solution".
I'm using the STM32F429I-Discovery board with STM32CubeIDE.

Bord is STM32F429I-DISC1.

Hello,


@chachamaru wrote:

I accidentally clicked "Accept as Solution".


I unmarked it.

In next time if you accidently mark as solution, you can do it from your side:

mALLEm_0-1762416610690.png

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

So please share your project so we could have a close look .

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

Post edited by ST moderator to be inline with the community rules for the code sharing. In next time please use </> button to paste your code. Please read this post: How to insert source code.

Thank you for your reply.
I’m currently working with the official STM32 example project “UART_TwoBoards_ComPolling”, and I’m trying to display “Hello” on Tera Term.

/**

******************************************************************************

* @file UART/UART_TwoBoards_ComPolling/Src/main.c

* @author MCD Application Team

* @brief This sample code shows how to use STM32F4xx UART HAL API to transmit

* and receive a data buffer with a communication process based on

* polling transfer.

* The communication is done using 2 Boards.

******************************************************************************

* @attention

*

* Copyright (c) 2017 STMicroelectronics.

* All rights reserved.

*

* This software is licensed under terms that can be found in the LICENSE file

* in the root directory of this software component.

* If no LICENSE file comes with this software, it is provided AS-IS.

*

******************************************************************************

*/



/* Includes ------------------------------------------------------------------*/

#include "main.h"







/** @addtogroup STM32F4xx_HAL_Examples

* @{

*/



/** @addtogroup UART_TwoBoards_ComPolling

* @{

*/



/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

//#define TRANSMITTER_BOARD



/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

/* UART handler declaration */

UART_HandleTypeDef UartHandle;



/* Buffer used for transmission */

uint8_t aTxBuffer[] = " **** UART_TwoBoards_ComPolling **** **** UART_TwoBoards_ComPolling **** **** UART_TwoBoards_ComPolling **** ";



/* Buffer used for reception */

uint8_t aRxBuffer[RXBUFFERSIZE];



/* Private function prototypes -----------------------------------------------*/

static void SystemClock_Config(void);

static void Error_Handler(void);

static uint16_t Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength);



/* Private functions ---------------------------------------------------------*/



/**

* @brief Main program

* @PAram None

* @retval None

*/

int main(void)

{



/* STM32F4xx HAL library initialization:

- Configure the Flash prefetch, instruction and Data caches

- Configure the Systick to generate an interrupt each 1 msec

- Set NVIC Group PriorityU to 4

- Global MSP (MCU Support Package) initialization

*/

HAL_Init();



/* Configure LED3 and LED4 */

BSP_LED_Init(LED3);

BSP_LED_Init(LED4);



/* Configure the system clock to 180 MHz */

SystemClock_Config();



__HAL_RCC_GPIOA_CLK_ENABLE();

__HAL_RCC_USART1_CLK_ENABLE();



GPIO_InitTypeDef GPIO_InitStruct = {0};

GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_10; // TX=PD8, RX=PD9

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_PULLUP;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF7_USART1;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);



/*##-1- Configure the UART peripheral ######################################*/

/* Put the USART peripheral in the Asynchronous mode (UART Mode) */

/* UART1 configured as follow:

- Word Length = 8 Bits

- Stop Bit = One Stop bit

- Parity = None

- BaudRate = 9600 baud

- Hardware flow control disabled (RTS and CTS signals) */

UartHandle.Instance = USART1;

UartHandle.Init.BaudRate = 115200;

UartHandle.Init.WordLength = UART_WORDLENGTH_8B;

UartHandle.Init.StopBits = UART_STOPBITS_1;

UartHandle.Init.Parity = UART_PARITY_NONE;

UartHandle.Init.HwFlowCtl = UART_HWCONTROL_NONE;

UartHandle.Init.Mode = UART_MODE_TX_RX;

UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;



if(HAL_UART_Init(&UartHandle) != HAL_OK)

{

Error_Handler();

}



#ifdef TRANSMITTER_BOARD



/* Configure USER Button */

BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);

/* Wait for USER Button press before starting the Communication */

while (BSP_PB_GetState(BUTTON_KEY) == RESET)

{

}



/* The board sends the message and expects to receive it back */



/*##-2- Start the transmission process #####################################*/

/* While the UART in reception process, user can transmit data through

"aTxBuffer" buffer */

if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)

{

Error_Handler();

}



/* Turn LED3 on: Transfer in transmission process is correct */

/* then Off for next transmission */

BSP_LED_On(LED3);

HAL_Delay(200);

BSP_LED_Off(LED3);



/*##-3- Put UART peripheral in reception process ###########################*/

if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 5000) != HAL_OK)

{

Error_Handler();

}



/* Turn LED3 on: Transfer in transmission process is correct */

/* then Off for next transmission */

BSP_LED_On(LED3);

HAL_Delay(200);

BSP_LED_Off(LED3);



#else



/* The board receives the message and sends it back */



/*##-2- Put UART peripheral in reception process ###########################*/

if(HAL_UART_Receive(&UartHandle, (uint8_t *)aRxBuffer, RXBUFFERSIZE, 5000) != HAL_OK)

{

Error_Handler();

}



/* Turn LED3 on: Transfer in transmission process is correct */

/* then Off for next transmission */

BSP_LED_On(LED3);

HAL_Delay(200);

BSP_LED_Off(LED3);



/*##-3- Start the transmission process #####################################*/

/* While the UART in reception process, user can transmit data through

"aTxBuffer" buffer */

if(HAL_UART_Transmit(&UartHandle, (uint8_t*)aTxBuffer, TXBUFFERSIZE, 5000)!= HAL_OK)

{

Error_Handler();

}



/* Turn LED3 on: Transfer in transmission process is correct */

/* then Off for next transmission */

BSP_LED_On(LED3);

HAL_Delay(200);

BSP_LED_Off(LED3);



#endif /* TRANSMITTER_BOARD */



/*##-4- Compare the sent and received buffers ##############################*/

if(Buffercmp((uint8_t*)aTxBuffer,(uint8_t*)aRxBuffer,RXBUFFERSIZE))

{

Error_Handler();

}



/* 無限ループでHello送信 */

const char msg[] = "Hello\r\n";



/* Infinite loop */

while (1)

{

HAL_UART_Transmit(&UartHandle, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);

/* Toggle LED3 */

BSP_LED_Toggle(LED3);



/* Wait for 40ms */

HAL_Delay(40);

}

}



/**

* @brief System Clock Configuration

* The system Clock is configured as follow :

* System Clock source = PLL (HSE)

* SYSCLK(Hz) = 180000000

* HCLK(Hz) = 180000000

* AHB Prescaler = 1

* APB1 Prescaler = 4

* APB2 Prescaler = 2

* HSE Frequency(Hz) = 8000000

* PLL_M = 8

* PLL_N = 360

* PLL_P = 2

* PLL_Q = 7

* VDD(V) = 3.3

* Main regulator output voltage = Scale1 mode

* Flash Latency(WS) = 5

* @PAram None

* @retval None

*/

static void SystemClock_Config(void)

{

RCC_ClkInitTypeDef RCC_ClkInitStruct;

RCC_OscInitTypeDef RCC_OscInitStruct;



/* Enable Power Control clock */

__HAL_RCC_PWR_CLK_ENABLE();



/* The voltage scaling allows optimizing the power consumption when the device is

clocked below the maximum system frequency, to update the voltage scaling value

regarding system frequency refer to product datasheet. */

__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);



/* Enable HSE Oscillator and activate PLL with HSE as source */

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 = 8;

RCC_OscInitStruct.PLL.PLLN = 360;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = 7;

if(HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

Error_Handler();

}



/* Activate the Over-Drive mode */

HAL_PWREx_EnableOverDrive();



/* Select PLL as system clock source and configure the HCLK, PCLK1 and PCLK2

clocks dividers */

RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;

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

{

Error_Handler();

}

}



/**

* @brief UART error callbacks

* @PAram UartHandle: UART handle

* @note This example shows a simple way to report transfer error, and you can

* add your own implementation.

* @retval None

*/

void HAL_UART_ErrorCallback(UART_HandleTypeDef *UartHandle)

{

/* Turn LED4 on: Transfer error in reception/transmission process */

BSP_LED_On(LED4);

}



/**

* @brief Compares two buffers.

* @PAram pBuffer1, pBuffer2: buffers to be compared.

* @PAram BufferLength: buffer's length

* @retval 0 : pBuffer1 identical to pBuffer2

* >0 : pBuffer1 differs from pBuffer2

*/

static uint16_t Buffercmp(uint8_t* pBuffer1, uint8_t* pBuffer2, uint16_t BufferLength)

{

while (BufferLength--)

{

if ((*pBuffer1) != *pBuffer2)

{

return BufferLength;

}

pBuffer1++;

pBuffer2++;

}



return 0;

}



/**

* @brief This function is executed in case of error occurrence.

* @PAram None

* @retval None

*/

static void Error_Handler(void)

{

/* Turn LED4 on */

BSP_LED_On(LED4);

while(1)

{

}

}



#ifdef USE_FULL_ASSERT

/**

* @brief Reports the name of the source file and the source line number

* where the assert_param error has occurred.

* @PAram file: pointer to the source file name

* @PAram line: assert_param error line source number

* @retval None

*/

void assert_failed(uint8_t* file, uint32_t line)

{

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

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



/* Infinite loop */

while (1)

{

}

}

#endif



/**

* @}

*/



/**

* @}

*/