Skip to main content
JFELI.13
Associate III
May 28, 2020
Question

Switching MSI to HSI on STM32L1

  • May 28, 2020
  • 13 replies
  • 2207 views

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;

   

}

This topic has been closed for replies.

13 replies

JFELI.13
JFELI.13Author
Associate III
May 28, 2020

If this is the problem I will have to do my own delay function (using timer)

JFELI.13
JFELI.13Author
Associate III
May 28, 2020

OK, thanks a lot.

I use a 100ms timer and will add a function in it (I don't need exact delay)

Regards

JFELI.13
JFELI.13Author
Associate III
May 28, 2020

But I also need to control if serial port speed is OK too................... perhaps I will have the same problem.......