2023-08-14 07:10 AM
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:
hardware parte:
2023-08-14 07:33 AM
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.
2023-08-14 07:34 AM
I'm not sure you can connect Arduino UNO directly:
Caution: The I/Os of the STM32 microcontroller are +3V3 compatible instead of 5 V for ARDUINO ®
Uno V3.
2023-08-14 07:54 AM
i need to conect gnd with 2 board?
2023-08-14 07:55 AM
how to solve this problem
2023-08-14 08:18 AM
:eyes::backhand_index_pointing_right:https://randomnerdtutorials.com/how-to-level-shift-5v-to-3-3v/
2023-08-14 08:29 AM - edited 2023-08-14 09:07 AM
I will try it
2023-08-14 08:42 AM
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
2023-08-14 08:47 AM
Not sure what school of electronics you went too, but yes, the two boards need to share a common ground.
Arduino users are mostly self-taught, only looking for a school as a last resort.
2023-08-14 08:58 AM - edited 2023-08-14 09:05 AM
i have conect GND where a liittle higher than D13 to GND ELEGOO UNO where up to 13 and D1 stm32 to d0 ELEGOO UNO R3 ,two board are conect to pc with usb ,Arduino still no have message.If those two boards are charge by USB of pc, still need to conect GND?