2020-05-28 02:26 AM
Hi,
I have a problem: in my soft, initial setup is for MSI mode (this because, in "stop mode" it will return in this mode) but I want to choose STM32L1 mode, in MSI mode (2.097Mhz) or in HSI (16Mhz) mode
When I select HSI mode (after initial MSI setup) everything seem ok (timer 100ms is accurate) ... except when I'm using a delay function: delay become very short ( perhaps 1/3)
I did a register comparison (RCC_CR, RCC_CFGR, RCC_APB1RSTR,RCC_APB1ENR...) between initial HSI or MSI setup but I can't see the problem.
Any suggestion ?
Thanks for help
void STM32L151_HSI()
{
unsigned int TimeOut=0xFFFF;
RCC_CR.HSION=1;
while(!RCC_CR.HSIRDY && TimeOut--);
RCC_CFGR.SW0=1;
while(!RCC_CFGR.SWS0);
RCC_CR.MSION=0;
}
2020-05-28 05:10 AM
> It appear delay_ms function is not updated when clock change. Is it the problem ?
Sure seems like that would be a problem to me.
I would also use a delay function based on systick or other fixed timer interval rather than one that requires the CPU to be utilized 100% for the duration. With the latter, interrupts during the delay will cause the delay to be longer than intended.
2020-05-28 05:11 AM
If this is the problem I will have to do my own delay function (using timer)
2020-05-28 05:17 AM
OK, thanks a lot.
I use a 100ms timer and will add a function in it (I don't need exact delay)
Regards
2020-05-28 05:19 AM
But I also need to control if serial port speed is OK too................... perhaps I will have the same problem.......