cancel
Showing results for 
Search instead for 
Did you mean: 

Reason for freeze after sleep

russ
Associate II
Posted on November 11, 2008 at 21:23

Reason for freeze after sleep

2 REPLIES 2
russ
Associate II
Posted on May 17, 2011 at 12:51

I have been having an issue where my processor will freeze after quite a few cycles of returning from STOP mode.

After looking through some of the files I think I found the problem and it relates to the STM32 library.

Every time the processor comes back from being asleep it goes through the ''SYSCLKConfig_STOP()'' function that is in the example code.

In this function the processor reconfigures the system clock after wake-up by enabling the HSE and PLL. The first thing that is done after the HSE is configured ON is:

/* Wait till HSE is ready */

HSEStartUpStatus = RCC_WaitForHSEStartUp();

In this function we have the following code from the fwlib:

/*******************************************************************************

* Function Name : RCC_WaitForHSEStartUp

* Description : Waits for HSE start-up.

* Input : None

* Output : None

* Return : An ErrorStatus enumuration value:

* - SUCCESS: HSE oscillator is stable and ready to use

* - ERROR: HSE oscillator not yet ready

*******************************************************************************/

ErrorStatus RCC_WaitForHSEStartUp(void)

{

ErrorStatus status = ERROR;

/* Wait till HSE is ready and if Time out is reached exit */

do

{

HSEStatus = RCC_GetFlagStatus(RCC_FLAG_HSERDY);

StartUpCounter++;

} while((HSEStatus == RESET) && (StartUpCounter != HSEStartUp_TimeOut));

if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET)

{

status = SUCCESS;

}

else

{

status = ERROR;

}

return (status);

}

The problem seems to be that ''StartUpCounter'' is not reset. It is initialized at the top of the stm32f10x_rcc.c file as:

static vu32 StartUpCounter = 0;

Because it is static the value remains and is incremented every time the processor comes back from sleep. After enough cycles, the StartUpCounter value is high (equal to the HSEStartUp_TimeOut value) and will result in a fail.

Please confirm if this is correct. To fix this I initialize StartUpCounter to zero within the RCC_WaitForHSEStartUp() function.

russ
Associate II
Posted on May 17, 2011 at 12:51

Does anybody else use the ''SYSCLKConfig_STOP()'' function when coming out of sleep? More importantly does anybody else have issues with it causing rare lockups?