cancel
Showing results for 
Search instead for 
Did you mean: 

Using Standby Mode with the RTC

emilio
Associate II
Posted on March 03, 2014 at 17:40

Hello everybody.

I am developing some test firmwares on a STM32F103 based board.

After some working programs using the sleep mode, now I need to do some experience with the much more powerful standby mode.

I need to set a fixed timer using the RTC in order to wake up the system periodically to perform some tasks. I want to use the RTC, no external interrupts.

Can anybody help me with a code example?

Thanks in advance
18 REPLIES 18
emilio
Associate II
Posted on March 06, 2014 at 10:42

I am starting from examples but my firmware is not working.

I am using the following code to configure the RTC Alarm with the LSI in order to have an interrupt 3 second after the WFI instruction, but the RTC_AlarmIRQHandler doesn't play

NVIC_InitStructure.NVIC_IRQChannel = RTCAlarm_IRQn;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;                     

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 13;               

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init( &NVIC_InitStructure );

 

RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR | RCC_APB1Periph_BKP, ENABLE);

PWR_BackupAccessCmd(ENABLE);

BKP_DeInit();

RCC_LSICmd(ENABLE); /* Enable LSI */

while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET); /* Wait till LSI is ready */

RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);

RCC_RTCCLKCmd(ENABLE);

RTC_WaitForSynchro();

RTC_SetPrescaler(32767);

RTC_WaitForLastTask();  

RTC_ITConfig(RTC_IT_ALR, ENABLE);

RTC_WaitForLastTask();       RTC_ClearFlag(RTC_FLAG_SEC);

while(RTC_GetFlagStatus(RTC_FLAG_SEC)==RESET);

      

RTC_SetAlarm(RTC_GetCounter()+3);

RTC_WaitForLastTask();

__WFI();

Posted on March 06, 2014 at 23:42

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6cg&d=%2Fa%2F0X0000000brx%2FPUShGOjcmyOBK9q1QAdd.MotxWtMt4in_SEUzDQPONE&asPdf=false
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
stm322399
Senior
Posted on March 07, 2014 at 12:03

There is a missing 'connection' between RTCAlarm and interrupt controller. You need to configure EXTI_Line17 to do so.

emilio
Associate II
Posted on March 10, 2014 at 10:07

Thanks a lot, now I am using the standby mode with no problems :)

On the other hand, I have another question: I am measuring the power consumption in standby mode but I am noticing a very variable Idd, from 0.2 to 1mA during the standby period.

What about it? What is the cause?
Amel NASRI
ST Employee
Posted on March 10, 2014 at 11:12

Hi Emilio,

0.2 mA is so much, in standby mode consumption shouldn't exceed 5µA.

If you try just to enter standby mode without RTC configuration for wakeup, what do you get?

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

emilio
Associate II
Posted on March 10, 2014 at 11:21

In fact I am logging a really high current consumption for standby mode.

I am using the RTC alarm (with the RTC clock set to use the LSI) to wake up from standby mode.

stm322399
Senior
Posted on March 10, 2014 at 11:33

Going down to a few µA requires several conditions to be met.

Now that you are running the low power mode, you must check every I/O and make sure every pin has a stable voltage.

The most simple is to drive I/O to either 0 (preferable) or 1. When it is not possible to drive as output, input can be selected, either as logical or analog.

Of course no resistor shall have ends at different voltage (then sink µA or mA).

Don't let any wire to be HI-Z, they act as antenna and make logic to switch and consume a lot of µA.

Posted on March 10, 2014 at 14:19

input can be selected, either as logical or analog.

Analogue would generally be preferable as in STM32 pin designs it turns off the schmitt trigger on the input.

Other vendors suggest driving the pins low, this eliminates a potential for the pin to oscillate. I would try this also, and observe if it improves the current profile.

I don't have my notes in front of me, but my recollection is STANDBY takes a couple of uA, I stripped code from the example here that suppresses all the pins. I would examine closely what you have attached to the device pins, and the state of those pins.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
emilio
Associate II
Posted on March 12, 2014 at 12:09

Thanks to both!