Sleeping for a longer period of time

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm

Re: Sleeping for a longer period of time

Post 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.
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Sleeping for a longer period of time

Post 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.
User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm

Re: Sleeping for a longer period of time

Post 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.
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Sleeping for a longer period of time

Post 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.
User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm

Re: Sleeping for a longer period of time

Post 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 :)
User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm

Re: Sleeping for a longer period of time

Post 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.
User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm

Re: Sleeping for a longer period of time

Post 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.
User avatar
barthess
Posts: 861
Joined: Wed Dec 08, 2010 7:55 pm
Been thanked: 7 times

Re: Sleeping for a longer period of time

Post 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.
User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm

Re: Sleeping for a longer period of time

Post 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.
User avatar
kulve
Posts: 86
Joined: Mon Nov 28, 2011 8:36 pm

Re: Sleeping for a longer period of time

Post 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.
Post Reply