I am developing a low power application with STM32L151, the power just comes from the land line.
The application has different states in which the System Clock needs to be differently configured. I was able successfully to:
- - stop the RTOS
- change frequency and source of System Clock
- restart the RTOS
The issue is just after when the System Clock has been changed. For instance when the USART driver is started again calling sdStart(), the value for the baud rate register is calculated using the symbol STM32_PCLK2 which is defined at compile time. The problem is precisely this one, STM32_PCLK2 should not be a predefined symbol but should be a function which gets the real actual value of PCLK2 frequency. I am sure this issue will affect also other peripherals.
Idea#1 might be to replace STM32_PCLK2, STM32_PCLK1, ecc... with a function but I fear about portability and any hidden consequences.
Idea#2 might be to initialize the USART using the HAL layer available CubeMX.
I am open to any suggestion and tip.
Thank you in advance