cancel
Showing results for 
Search instead for 
Did you mean: 

STM32h755 USART3

Francesco3
Associate II

Hi everyone, I'm a student who was assigned to make an ESP32 NodeMCU WiFi CP2102
communicate with the magnificent STM32h755zqi board via usart, simply I wanted to start by writing a simple
sentence on the terminal (I know how to use putty) to actually realize that I'm using it correctly usart
communication.

also reading on the forum and from the schematics, usart3 is recommended to do these things as
you can use virtual COM.

I attach my file directly, there is certainly something wrong since I am a beginner, for now
on putty it prints indecipherable Chinese characters, I state that I am reading at the same baud rate
and all the various configurations that I have entered.

During the course I was told to use the M4 core but I was told to write a part of code on M7 to start
only the M4 (in the boot sequence) but I don't know what that meant at all so I wrote the code directly on M7,
if anyone can help me in this aspect too, I'd appreciate it.

PS: I also accept any other link that I can view for a tutorial or otherwise. Thanks to anyone who helps me.

1 ACCEPTED SOLUTION

Accepted Solutions
Francesco3
Associate II

I thank those who answered me, I wanted to announce that after various tests and attempts I
understood that the problem was a code that did not depend on what I selected but something more,
I proceeded with uninstalling the IDE and all the folders I had created , so I did a fresh install
and solved the problem, I can correctly manage usart2, usart3 and send them to the ESP.

View solution in original post

5 REPLIES 5

The ESP32 NodeMCU WiFi CP2102 doesn't look entirely appropriate to connect to another MCU, it's designed to connect to a PC. There's perhaps pin level connectivty, you'll have to check the documentation

The example you attached has more CubeMX than I care for, but does look to set up the USART3 PD8/PD9 at 9600 baud.

>>on putty it prints indecipherable Chinese characters

Please illustrate this with an in-line picture.

Perhaps try STM32Cube_FW_H7_V1.11.2\Projects\NUCLEO-H745ZI-Q\Examples\UART\UART_WakeUpFromStopUsingFIFO

UART_HandleTypeDef huart3;

void InitUSART3(void)
{
  GPIO_InitTypeDef GPIO_InitStruct = {0};

  /* Peripheral clock enable */
  __HAL_RCC_USART3_CLK_ENABLE();
  __HAL_RCC_GPIOD_CLK_ENABLE();

  /**USART3 GPIO Configuration
  PD8     ------> USART3_TX
  PD9     ------> USART3_RX
  */
  GPIO_InitStruct.Pin       = GPIO_PIN_8|GPIO_PIN_9;
  GPIO_InitStruct.Mode      = GPIO_MODE_AF_PP;
  GPIO_InitStruct.Pull      = GPIO_NOPULL;
  GPIO_InitStruct.Speed     = GPIO_SPEED_FREQ_LOW;
  GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
  HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

  huart3.Instance                     = USART3;
  huart3.Init.BaudRate                = 9600;
  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.Init.ClockPrescaler          = UART_PRESCALER_DIV1;
  huart3.AdvancedInit.AdvFeatureInit  = UART_ADVFEATURE_NO_INIT;

  if (HAL_UART_Init(&huart3) != HAL_OK)
  {
    Error_Handler();
  }

  if (HAL_UARTEx_SetTxFifoThreshold(&huart3, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK)
  {
    Error_Handler();
  }

  if (HAL_UARTEx_SetRxFifoThreshold(&huart3, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK)
  {
    Error_Handler();
  }

  if (HAL_UARTEx_DisableFifoMode(&huart3) != HAL_OK)
  {
    Error_Handler();
  }
}

void OutString(char *string)
{
	HAL_UART_Transmit(&huart3, (uint8_t *)string, strlen(string), HAL_MAX_DELAY);
}

int main(void)
{
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  // .. Let system run from 64 MHz HSI

  InitUSART3();

  while(1)
  {
    OutString("Prova diretta UART\r\n");
    HAL_Delay(2000); // 2 Second Pause
  }

  return(0);
}

.  

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

Yes, I understand your thoughts but unfortunately it is a project that does not depend on me.
I inserted in the zip folder what I get on two terminals, putty and termite, I correctly verified that
my device is on COM5. for the rest I will also show you the settings I made.

the extra code could be given by the fact that on another thread I had read about enabling RCC,
even though I didn't actually understand what it was for.

The folder on github that you inserted is the same one that I was viewing last night, only that
the code seemed very difficult to me given how little I know at the moment, I will try to read it.

Where do you think it would be best to insert the code you brought me here instead? because I noticed
that the function I have in my code is completely different even the name.

In the meantime, thank you for your reply.

I also have two questions, given that in other threads I have also seen a lot of focus on PD8 and PD9,
I seem to have understood that they are internal pins right?
that is, for now I'm simply loading the program onto the stm board, and I obviously connect the
USB from the CN1 connector side and open the terminal, is everything correct??

They are pins on the H755 that connect to the ST-LINK/V3 (F723) on-board, that in turn provides a COM port on the PC via the ST-LINK's driver

Go to the NUCLEO-H755ZI-Q home page, go to the "CAD Resources" page, and pull a copy of the schematic.

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

Yes, I have all the necessary schematics, pinouts and datasheets.

It is from there that I saw that the usart3 uses those pins and is connected to the vcp

Francesco3
Associate II

I thank those who answered me, I wanted to announce that after various tests and attempts I
understood that the problem was a code that did not depend on what I selected but something more,
I proceeded with uninstalling the IDE and all the folders I had created , so I did a fresh install
and solved the problem, I can correctly manage usart2, usart3 and send them to the ESP.