AnsweredAssumed Answered

processor crashes after wake up from sleep STM32L151

Question asked by polyakov.mikhail on Jul 1, 2012
Latest reply on Jul 2, 2012 by fm
I use sleep mode WFI.
After wake by interrupt I switch on HSI , switch system clock to HSI,  and just after it processor performs 5-10 lines and stuck(stop)
The effect is very unstable, it stuck in different moments, sometimes not stuck at all.
So , I can not exactly determine the place where problem happens.
I only know that :
1) If I do not use sleep mode, there is no problem.
2) If I do not switch to HSI,   there is no problem.
3)Problem can occur  only just after wake up and switch on HSI.  If  processor have successfull run throw first moment after wake up, it will never stop.

I switch to HSI the same way :

RCC_CR_MASK=RCC->CR;
 RCC_CR_MASK |=RCC_CR_HSION;
 RCC->CR=RCC_CR_MASK;       
while(!(RCC->CR & RCC_CR_HSIRDY)){}   //now HSI is ON

RCC_CFGR_MASK=RCC->CFGR;
RCC_CFGR_MASK &=~RCC_CFGR_SW;
RCC_CFGR_MASK |= RCC_CFGR_SW_HSI;
RCC->CFGR=RCC_CFGR_MASK    //now system clock is HSI

 I think, that this problem , as it is so unstable, is connect with hardware.
But no other thoughts do not come in my head.

Can anyone suggest anything?

Outcomes