Page 1 of 1

STM32 USART v.2 Serial Driver Reinit error

Posted: Mon Jan 31, 2022 12:53 am
by alexblack
Hi.
In stable branch 21.11.x and 21.6.x (and maybe in earler) reconfiguration the baudrate scenario is broken because in function serial_lld_start is called the function usart_init with variable clock which is not setted when serial driver already is in READY state:

Code: Select all

 \stable_21.11.x\os\hal\ports\STM32\LLD\USARTv2\hal_serial_lld.c
694 /**
965  * @brief   Low level serial driver configuration and (re)start.
996  *
697  * @param[in] sdp       pointer to a @p SerialDriver object
698  * @param[in] config    the architecture-dependent serial driver configuration.
699  *                      If this parameter is set to @p NULL then a default
700  *                      configuration is used.
701  *
702  * @notapi
703  */
704 void sd_lld_start(SerialDriver *sdp, const SerialConfig *config) {
705   uint32_t clock = 0U;
706
707   if (config == NULL)
708     config = &default_config;
709
710   if (sdp->state == SD_STOP) {
711 #if STM32_SERIAL_USE_USART1
712     if (&SD1 == sdp) {
713       clock = STM32_USART1CLK;
714       rccEnableUSART1(true);
715     }
716 #endif
...
765   }
766   usart_init(sdp, config, clock);
767 }

Re: STM32 USART v.2 Serial Driver Reinit error

Posted: Mon Jan 31, 2022 11:16 am
by Giovanni
Hi,

Thanks for finding, it affects Serial, SIO and UART in both USARTv2 and USARTv3. USARTv1 is fine.

Giovanni

Re: STM32 USART v.2 Serial Driver Reinit error

Posted: Mon Jan 31, 2022 12:08 pm
by Giovanni
Fixed as bug #1217.

Giovanni