Skip to content

Commit 1794463

Browse files
jamike0xc0170
authored andcommitted
[STM32F3]: fix for uart baudrate.
1 parent 17693ac commit 1794463

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hal/targets/hal/TARGET_STM/TARGET_STM32F3/serial_api.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "pinmap.h"
3737
#include <string.h>
3838
#include "PeripheralPins.h"
39+
#include "mbed_error.h"
3940

4041
#define UART_NUM (5)
4142

@@ -69,8 +70,12 @@ static void init_uart(serial_t *obj)
6970
// Disable the reception overrun detection
7071
UartHandle.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT;
7172
UartHandle.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE;
72-
73-
HAL_UART_Init(&UartHandle);
73+
/* uAMR & ARM: Call to UART init is done between reset of pre-initialized variables */
74+
/* and before HAL Init. SystemCoreClock init required here */
75+
SystemCoreClockUpdate();
76+
if (HAL_UART_Init(&UartHandle) != HAL_OK) {
77+
error("Cannot initialize UART\n");
78+
}
7479
}
7580

7681
void serial_init(serial_t *obj, PinName tx, PinName rx)

0 commit comments

Comments
 (0)