Skip to content

Commit

Permalink
stm32/uart: Fix H7 UART clock source configuration.
Browse files Browse the repository at this point in the history
Previously to this commit, Usart16ClockSelection was overwritten and
Usart234578ClockSelection was not set.
  • Loading branch information
iabdalkader authored and dpgeorge committed Apr 27, 2021
1 parent 4dc8024 commit a708848
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions ports/stm32/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,10 @@ STATIC const pyb_uart_irq_map_t mp_uart_irq_map[] = {
void uart_init0(void) {
#if defined(STM32H7)
RCC_PeriphCLKInitTypeDef RCC_PeriphClkInit = {0};
// Configure USART1/6 clock source
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART16;
// Configure USART1/6 and USART2/3/4/5/7/8 clock sources
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART16 | RCC_PERIPHCLK_USART234578;
RCC_PeriphClkInit.Usart16ClockSelection = RCC_USART16CLKSOURCE_D2PCLK2;
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
__fatal_error("HAL_RCCEx_PeriphCLKConfig");
}

// Configure USART2/3/4/5/7/8 clock source
RCC_PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART234578;
RCC_PeriphClkInit.Usart16ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
RCC_PeriphClkInit.Usart234578ClockSelection = RCC_USART234578CLKSOURCE_D2PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInit) != HAL_OK) {
__fatal_error("HAL_RCCEx_PeriphCLKConfig");
}
Expand Down

0 comments on commit a708848

Please sign in to comment.