RS485 Modbus communication baudrate limitation
Context
While trying to create an RS485 communication using Zephyr, we came across a limitation of the driver.
Description
The ModBus driver calls a baudrate function defined in uart_stm32.c
.
static void uart_stm32_usart_set_baud_rate(struct device *dev,
u32_t clock_rate, u32_t baud_rate)
{
USART_TypeDef *UartInstance = UART_STRUCT(dev);
LL_USART_SetBaudRate(UartInstance,
clock_rate,
#ifdef USART_PRESC_PRESCALER
LL_USART_PRESCALER_DIV1,
#endif
#ifdef USART_CR1_OVER8
LL_USART_OVERSAMPLING_16,
#endif
baud_rate);
}
It is possible to see that oversampling is always set to 16, which is not compatible with a 20MHz operation.
Solution
Either do an LL call and solve this issue internally or make a new version of the driver and upstream it.