Skip to main content
wjian.2
Associate III
August 14, 2023
Question

stm32h747-Disco uart8 sending trouble

I'm use uart8 to send data to arduino, but arduino no receive nothing, all the program is right complier,and the D1/D0 should be right(only have uart8).https://community.st.com/t5/stm32-mcu-products/stm32h747i-disco-virtual-com-via-usart-to-arduino/m-p/578727#M219845. which parte of code should be wrong?

uart part:

static void MX_UART8_Init(void)
{
__HAL_RCC_UART8_CLK_ENABLE();

//__HAL_UART_CLEAR_IDLEFLAG(&huart8);
/* USER CODE BEGIN USART1_Init 0 */

/* USER CODE END USART1_Init 0 */

/* USER CODE BEGIN USART1_Init 1 */

/* USER CODE END USART1_Init 1 */
huart8.Instance = UART8;
//huart8.Init.BaudRate = 115200;
huart8.Init.BaudRate = 115200;
huart8.Init.WordLength = UART_WORDLENGTH_8B;
huart8.Init.StopBits = UART_STOPBITS_1;
huart8.Init.Parity = UART_PARITY_NONE;
huart8.Init.Mode = UART_MODE_TX_RX;
huart8.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart8.Init.OverSampling = UART_OVERSAMPLING_16;
huart8.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart8.Init.ClockPrescaler = UART_PRESCALER_DIV1;
huart8.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if(contadoruart=0){
HAL_UART_Init(&huart8);
if (HAL_UART_Init(&huart8) != HAL_OK)
{
Error_Handler();
}
contadoruart=contadoruart+1;
}

rcc setting:

System Clock Configuration
* The system Clock is configured as follow :
* System Clock source = PLL (HSE)
* SYSCLK(Hz) = 400000000 (Cortex-M7 CPU Clock)
* HCLK(Hz) = 200000000 (Cortex-M4 CPU, Bus matrix Clocks)
* AHB Prescaler = 2
* D1 APB3 Prescaler = 2 (APB3 Clock 100MHz)
* D2 APB1 Prescaler = 2 (APB1 Clock 100MHz)
* D2 APB2 Prescaler = 2 (APB2 Clock 100MHz)
* D3 APB4 Prescaler = 2 (APB4 Clock 100MHz)
* HSE Frequency(Hz) = 25000000
* PLL_M = 5
* PLL_N = 160
* PLL_P = 2
* PLL_Q = 4
* PLL_R = 2
* VDD(V) = 3.3
* Flash Latency(WS) = 4

gpio part:

static void MX_GPIO_Init(void)

{

GPIO_InitTypeDef GPIO_InitStruct;

/* GPIO Ports Clock Enable */

__HAL_RCC_GPIOJ_CLK_ENABLE();
__HAL_RCC_UART8_CLK_ENABLE();
/*Configure GPIO pin: PJ8 For D1 pin for TX */
// GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9;

//GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

//GPIO_InitStruct.Pull = GPIO_NOPULL; //pullup
GPIO_InitStruct.Pull = GPIO_PULLUP; //pullup
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF8_UART8;
if(contadorgpio=0){
HAL_GPIO_Init(GPIOJ, &GPIO_InitStruct);
contadorgpio=contadorgpio+1;
}

sending parte: both not work:

//HAL_UART_Transmit(&huart8,(uint8_t*)msg,strlen(msg),100);
HAL_UART_Transmit(&huart8,"mesaage",10,1000);

scope parte:

wjian2_1-1692022116594.png

hardware parte:

wjian2_0-1692021766457.jpeg

 

This topic has been closed for replies.

17 replies

Tesla DeLorean
Guru
August 14, 2023

You'll need a common ground

Check if you need to swap the RX/TX sense. Get a scope on the signals if that's helpful to confirm.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
wjian.2
wjian.2Author
Associate III
August 14, 2023

i need to conect gnd with 2 board?

Tesla DeLorean
Guru
August 14, 2023

Not sure what school of electronics you went too, but yes, the two boards need to share a common ground.

On the H747I-DISCO D0 is UART8_RX PJ9, D1 is UART8_TX PJ8

On the ELEGOO UNO R3 D0 is Serial RX, D1 is Serial TX you'll need to cross-over the TX from the STM32 to the RX on the ATMega

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
RhSilicon
Lead
August 14, 2023

I'm not sure you can connect Arduino UNO directly:

UM2411:

Caution: The I/Os of the STM32 microcontroller are +3V3 compatible instead of 5 V for ARDUINO ®
Uno V3.

wjian.2
wjian.2Author
Associate III
August 14, 2023

how to solve this problem

RhSilicon
Lead
August 14, 2023