arduino-libraries / RTCZero

RTC Library for SAMD21 based boards
http://arduino.cc/en/Reference/RTC
GNU Lesser General Public License v2.1
78 stars 78 forks source link

standbyMode() needs clocks to be turned off? #9

Closed madvoid closed 8 years ago

madvoid commented 8 years ago

Hi,

I was reading the SAM D21 datasheet and I noticed that when placed into Standby mode, a significant amount of clocks and peripherals must be disabled, so that the voltage regulator is not overloaded (see section 16.6.2.8). However, the standbyMode() function in RTCZero doesn't appear to do that. It sets the deep sleep mask and goes directly to sleep. Am I missing something? Should code be added there to turn peripherals/clocks off? I apologize if this is the wrong place to post this, I can move elsewhere if necessary.

Thanks!

sandeepmistry commented 8 years ago

Hi @madvoid,

Am I missing something? Should code be added there to turn peripherals/clocks off?

I think the current approach is fine, because none of the peripherals a enabled in standby mode in the SAMD core. By default the peripherals and clocks are not enabled in standby mode.

AT11491: Peripheral Power Consumption in Standby Mode for SAM D Devices is also a good read. I found it while looking into https://github.com/arduino/ArduinoCore-samd/issues/142.

Let me know if this makes sense.

madvoid commented 8 years ago

Hello @sandeepmistry,

That makes perfect sense, thank you! I'm going to mark this as closed.

mennamorato commented 6 years ago

@sandeepmistry If none of the peripherals and clocks are enabled in standby mode, why is that my SAMD21 mini board with all LED's removed still consumes 8mA when using rtc.standbyMode()? something must be running... other people report less than 100uA with custom code. Suggestions? I really need to figure this out as I have to get to 200uA max, thanks!

kriti1717 commented 5 years ago

Hi @mennamorato I'm getting the same issue as you. Did you find a solution to it? I am using delay to wait for my digital pins to get into the write mode before taking a reading. Can I replace my delay function with standby. My guess is standby mode will not work as it shuts down the peripherals but then my standby mode power consumption is 9mA. Please advice

drewfish commented 5 years ago

The SAMD21 allows a lot of control over which peripherals still run in standby mode. You'll need to read the datasheet for details. It's a little tricky since you need to cross-reference the arduino pin numbers into the EIC signal numbers, then set the correct bits in the EIC configuration register.

I've used rtc.standbyMode() in projects to put the CPU to sleep but still have the EIC (external interrupt controller) peripheral running so that a button press wakes up the CPU. With that I was using 300uA, but some of that might have been other components (voltage regulator, etc) on the devboard I was using. I also configured the EIC to run off the same clock as the RTC, not sure if that was necessary.