cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L151 - leaving Standby mode with time-stamp

kecskesgery
Associate II
Posted on October 02, 2015 at 15:08

Hello!

Well, my question is that is it possible to leave Standy mode on STM32L151 after a given time (lets say 30 sec)? 

I have designed a custom board, and did not include a 32.768kHz oscillator for RTC, nor did I connect anything to the wakeup pin. I just want to put the controller into Stadby mode, and then leave it after a given time. I have read throug the datasheett, and I've found out there's an option to use time-stamp, but I did not find any other useful information about it.

Can someone please a little ''enlighten me'', or privide any examples? I'd much appreciate it!

Thanks in advanced! 

#timestamp #autowakeup #autowakeup #timestamp #standby #standby
3 REPLIES 3
Posted on October 02, 2015 at 17:55

The internal connectivity should be sufficient to set up an alarm, on the L1's the LSE is powered when the rest of the core shuts down. The STANDBY mode exits via a Reset, so you have to recognize that, and that all you other prior state is lost.

These examples, and others,

STM32L1xx_StdPeriph_Lib_V1.1.1\Project\STM32L1xx_StdPeriph_Examples\RTC\TimeStamp\main.c

STM32L1xx_StdPeriph_Lib_V1.1.1\Project\STM32L1xx_StdPeriph_Examples\PWR\STANDBY\main.c

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
kecskesgery
Associate II
Posted on October 03, 2015 at 20:11

Hey clive,

thanks for the infos! Well, right know, I'm able to enter STANDBY mode, and exit it via a RTC WakeUpTimer. What really causes meg a hard time, is how to configure the wakeuptimer right. As I've tested, the max time I can spend in STANDBY is around 28 sec. But what if I want to be there for over lets say 60 sec? I must configure something wrong, in theENTER_StandbyRTCMode() function. Here's my code:


RTCHandle.Instance = RTC;


/* HELP: AN3371 - RTC config/Table 3. */


RTCHandle.Init.HourFormat = RTC_HOURFORMAT_24;

RTCHandle.Init.AsynchPrediv = RTC_ASYNCH_PREDIV; //124

RTCHandle.Init.SynchPrediv = RTC_SYNCH_PREDIV; // (37 000/ (124+1))-1 = 295

RTCHandle.Init.OutPut = RTC_OUTPUT_DISABLE;

RTCHandle.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;

RTCHandle.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;


if(HAL_RTC_Init(&RTCHandle) != HAL_OK)

{

LED2_On();

return; //in case of RTC Init error, the MCU wont go to standby

}



if(HAL_RTCEx_DeactivateWakeUpTimer(&RTCHandle) != HAL_OK)

{

LED2_On();

}



/* #1 Clear all related wake-up flags ######################################*/


/* Clear PWR wake up Flag */

__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);


/* Clear RTC Wake Up timer Flag */

__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&RTCHandle, RTC_FLAG_WUTF);


/* #2 Setting the Wake up time ############################################*/


double wakeUpTimeBase = RTC_WAKEUPCLOCK_RTCCLK_DIV16 / LSI_VALUE;

uint32_t WakeUpCounter = (wakeUpTime / wakeUpTimeBase);


HAL_RTCEx_SetWakeUpTimer_IT(&RTCHandle, WakeUpCounter, RTC_WAKEUPCLOCK_RTCCLK_DIV16);


/* #3 Enter the Standby mode ##############################################*/


/* Request to enter STANDBY mode */

HAL_PWR_EnterSTANDBYMode();

I choose

RTC_ASYNCH_PREDIV and

RTC_SYNCH_PREDIV values to get a 1Hz (1s) time base, but I'm guessing that something is either wrong there, or choosing wrong

RTC_WAKEUPCLOCK_RTCCLK_DIVxx macro.

Hopefuly you know the answer... Thanks in advanced!
kecskesgery
Associate II
Posted on October 06, 2015 at 10:56

So, I went through a lot of examples and docs, but still could not find the solution. Has anybody ever programmed any ST controller to enter STANDBY mode, and then use autowakeup event after more than 60 sec, or so?