cancel
Showing results for 
Search instead for 
Did you mean: 

stm32h747-Disco uart8 sending trouble

wjian.2
Associate II

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

 

17 REPLIES 17

Get a scope on the signals, you CAN'T connect two transmit pins together and expect it to work.

The OUTPUT of one board needs to got to the INPUT of the second board. Both these boards have similar wiring due to them taking shields.

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

tx_rx_shield.jpg

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

Maybe RS485, CAN, I2C 😅

I have change the pin before but not work, does anyother reason could be?

It shouldn't be this hard to walk through the SW and HW and get a scope on the signals, confirming the presence of the signal, the bit rate.

Perhaps you can do a simple loop-back test at each end, seeing that transmit and receive work. Send 'U' characters, continuously, scope the signal

HAL_UART_Transmit() blocks, it will block reception, unless you use IT / callback methods.

If you wired TWO OUTPUTs together, you might have damage one or both of the pins.

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

The next question will surely be if a ground needs to be connected for the loopback to work...  :rolling_on_the_floor_laughing:


@David Littell wrote:

The next question will surely be if a ground needs to be connected for the loopback to work...  :rolling_on_the_floor_laughing:


We've all asked these questions at some point 😅

if D1 only have noise no have 0/5v/3.3v which part should be wrong?