Page 2 of 3

Re: Sleeping for a longer period of time

Posted: Sun Mar 11, 2012 4:32 pm
by kulve
I don't have any alarms, only wakeups.

I noticed that the RTC example uses barthess' board which has LSE. There's no LSE in my board nor in the F4 discovery.

My HSE is 25MHz and I tried to define STM32_RTCSEL to STM32_RTCSEL_HSEDIV and STM32_RTCPRE_VALUE to 25 and now it do sleep. But it never wakes up..

I guess it should be OK to use HSE as mentioned above and still use the 1Hz clock source as in the testhal RTC code?

My board seems to consume 6.9mA while in sleep with the power LED on. I need to solder that out to see how much it's without it :)

Thanks.

Re: Sleeping for a longer period of time

Posted: Sun Mar 11, 2012 5:05 pm
by barthess
kulve wrote:I guess it should be OK to use HSE as mentioned above and still use the 1Hz clock source as in the testhal RTC code?

No. Use LSI instead. And carefully read RTC part from reference manual.
kulve wrote: I need to solder that out to see how much it's without it

Not necessary. I think, your led connected through series resistor. Than you can measure voltage on resistor and calculate current using Ohm's law. Not very precise but works without soldering iron.

Re: Sleeping for a longer period of time

Posted: Thu Mar 15, 2012 6:53 pm
by kulve

Code: Select all

static void func_sleep(void){
  chSysLock();
  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
  PWR->CR |= (PWR_CR_PDDS | PWR_CR_LPDS | PWR_CR_CSBF | PWR_CR_CWUF);
  RTC->ISR &= ~(RTC_ISR_ALRBF | RTC_ISR_ALRAF | RTC_ISR_WUTF | RTC_ISR_TAMP1F |
                RTC_ISR_TSOVF | RTC_ISR_TSF);
  __WFI();
}


barthess wrote:It is hard to determine real reason of such behavior. Probably in EXTI cell. Try to look with memory browser what's exactly written to RTC registers. Are alarms and wakeups written in RTC correctly?


If I understand the TRM correctly, the f205 goes to StandBy mode with PDDS being set so setting the LPDS bit in the above code has no affect?

And in StandBy mode it shouldn't wake up by EXTI cell, that should happen only in Stop mode?

Thanks.

Re: Sleeping for a longer period of time

Posted: Fri Mar 16, 2012 3:17 pm
by barthess
kulve wrote:And in StandBy mode it shouldn't wake up by EXTI cell, that should happen only in Stop mode?

Yes, you are correct.
kulve wrote:If I understand the TRM correctly, the f205 goes to StandBy mode with PDDS being set so setting the LPDS bit in the above code has no affect?

Probably you are correct. I have create that demo just for testing of RTC, not power saving.

Re: Sleeping for a longer period of time

Posted: Sat Mar 17, 2012 6:21 pm
by kulve
I made couple of additional notes:

  1. It doesn't wake up without the call to rtcSetPeriodicWakeup_v2() so it doesn't wake to anything else.
  2. Increasing the WUTR from 9 ("+1 seconds") to 500, it "sleeps" around 8 seconds. Does that mean that my ck_spre isn't 1 second? The WUKSEL is set to 0b100.
  3. Sleeping works only once. After the wake-up, it doesn't seem to "sleep" at all.
  4. Judging from the power consumption, it is actually in the stop mode when "sleeping" and not in the standby mode. It takes 5.5mA with a led and according to our calculations the led is taking something between 1-2 mA.

All debugging hints are still welcome :)

Re: Sleeping for a longer period of time

Posted: Sat Mar 17, 2012 6:25 pm
by kulve
kulve wrote:Judging from the power consumption, it is actually in the stop mode when "sleeping" and not in the standby mode. It takes 5.5mA with a led and according to our calculations the led is taking something between 1-2 mA.


Actually I guess it should take much less even in the stop mode, so disregard that comment.

Re: Sleeping for a longer period of time

Posted: Sat Mar 17, 2012 6:28 pm
by kulve
And more more comment. It takes around 7mA if I keep the reset button pressed down. I don't know in which state it is then in.

Re: Sleeping for a longer period of time

Posted: Sat Mar 17, 2012 6:49 pm
by barthess
kulve wrote:Increasing the WUTR from 9 ("+1 seconds") to 500, it "sleeps" around 8 seconds. Does that mean that my ck_spre isn't 1 second? The WUKSEL is set to 0b100.

Enable calibration output (COE bit in RTC_CR register) and check frequency with oscilloscope.
kulve wrote:Sleeping works only once. After the wake-up, it doesn't seem to "sleep" at all.

Probably code from demo does not resets all flags in RTC_ISR register. Look in it with debugger.

Re: Sleeping for a longer period of time

Posted: Sat Mar 17, 2012 7:48 pm
by kulve
barthess wrote:
kulve wrote:Sleeping works only once. After the wake-up, it doesn't seem to "sleep" at all.

Probably code from demo does not resets all flags in RTC_ISR register. Look in it with debugger.


It wasn't the ISR but PWR->CR, thanks for the hint. I had those clear bits commented out because of some testing.. :oops:

Next thing is to see if all the peripherals are shutdown properly.

Re: Sleeping for a longer period of time

Posted: Mon Mar 19, 2012 5:40 pm
by kulve
barthess wrote:
kulve wrote:Increasing the WUTR from 9 ("+1 seconds") to 500, it "sleeps" around 8 seconds. Does that mean that my ck_spre isn't 1 second? The WUKSEL is set to 0b100.

Enable calibration output (COE bit in RTC_CR register) and check frequency with oscilloscope.


I checked and it was a bit over 500Hz which I guess is what is should with 32000Hz RTCLCK. I've double checked and double checked the PREDIV_A and PREDIV_S and I don't understand why my ck_spre isn't 1 Hz.

But I guess that doesn't have anything to do with the power consumption so I'm continuing to debug that next.

Thanks.