Switching MSI to HSI on STM32L1
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;
}