Skip to content

Commit 1ab98de

Browse files
authored
Merge pull request #15286 from pilotak/master
STM32G4: Fix serial port at low speed baud
2 parents 15d1b93 + 58e6bf7 commit 1ab98de

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

targets/TARGET_STM/serial_api.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,12 @@ HAL_StatusTypeDef init_uart(serial_t *obj)
629629
#if defined(UART_ONE_BIT_SAMPLE_DISABLE) // F0/F3/F7/G0/H7/L0/L4/L5/WB
630630
huart->Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
631631
#endif
632-
#if defined(UART_PRESCALER_DIV1) // G0/H7/L4/L5/WB
633-
huart->Init.ClockPrescaler = UART_PRESCALER_DIV1;
632+
#if defined(UART_PRESCALER_DIV1) // G0/G4/H7/L4/L5/U5/WB/WL
633+
if (obj_s->baudrate < 4800) {
634+
huart->Init.ClockPrescaler = UART_PRESCALER_DIV16;
635+
} else {
636+
huart->Init.ClockPrescaler = UART_PRESCALER_DIV1;
637+
}
634638
#endif
635639
#if defined(UART_ADVFEATURE_NO_INIT) // F0/F3/F7/G0/H7/L0/L4//5/WB
636640
huart->AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

0 commit comments

Comments
 (0)