cancel
Showing results for 
Search instead for 
Did you mean: 

stm32h747i-disco HAL_UART_Init(&huart8) problem

wjian.2
Associate II

 when i run if "(HAL_UART_Init(&huart8) != HAL_OK)" get blocked this code which part of code could wrong (RCC? SystemClock_Config?) ?(In stmcube ide no hay error en principio).

static void MX_USART8_UART_Init(void)
{

/* 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.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 (HAL_UART_Init(&huart8) != HAL_OK)
{
Error_Handler();
}

4 REPLIES 4
TDK
Guru

Step through the HAL_UART_Init function to see where it fails specifically.

If you feel a post has answered your question, please click "Accept as Solution".

You have access to ALL the source code, pin the failure down.

Does it return HAL_ERROR, and you bomb into Error_Handler() never to return?

Are the clocks enabled? Are the clocks and dividers capable of getting to the baud rate in question? Output info on the APB/AHB clocks as the running system sees them. Check APB clocks, and Peripheral Clock enabling and sourcing.

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

something seem to be wrong? when i need to use Peripheral Clock enabling ?

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

where could i see this value if i use toggle break point , it turn to start_upstm32h7h7xx.s

Reset_Handler:
ldr sp, =_estack /* set stack pointer */

/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit