Replies: 6 comments 4 replies
-
Figured I may post my code as well :D
|
Beta Was this translation helpful? Give feedback.
-
Well there's yo u r first problem. Power_all_disable does nothing here. It
only works on classic avrs, they haven't updated that library yet (and I
wouldn't hold my breath for updates to those)
…____________
Spence Konde
Azzy’S Electronics
New products! Check them out at tindie.com/stores/DrAzzy
GitHub: github.com/SpenceKonde
ATTinyCore: Arduino support for almost every ATTiny microcontroller
Contact: ***@***.***
On Sun, Feb 6, 2022, 07:18 XFer012 ***@***.***> wrote:
Figured I may post my code as well :D
`#include <avr/sleep.h>
#include <avr/power.h>
#define ACTIVITY_MS 20000U
#define LED 7 // PA7 (upper-left pin)
#define SWITCH 6 // PA6 (upper-right pin) use this for edge change
interrupt which wakes up the AVR, shorting it to GND
#define N_PINS 23
#define BLINK_DURATION_MS 500
// Globals
uint32_t gElapsed_ms = 0;
/////////
// ISR
/////////
void switchISR()
{
// Nothing to do
}
void setupPins()
{
uint8_t i;
for (i = 0; i < N_PINS; i++)
{
pinMode (i, INPUT_PULLUP);
}
pinMode (LED, OUTPUT);
}
void startSleep ()
{
set_sleep_mode(SLEEP_MODE_PWR_DOWN);
power_all_disable(); // power off ADC, Timer 0 and 1, serial interface
// WDT.CTRLA = 0; // Disable WDT (no improvements)
// bitClear(RTC.CTRLA, 0); // Disable RTC (worse, +20% power draw)
// bitClear(RTC.PITCTRLA, 0); // Disable Periodic Interrupt generator
sleep_enable();
sleep_cpu(); // Enter sleep mode
// Wakes up here
sleep_disable();
power_all_enable(); // power everything back on
}
void setupPinChangeInterrupt(const uint8_t switchPin)
{
pinMode (switchPin, INPUT_PULLUP); // Momentary pushbutton will push it to
GND
attachInterrupt(digitalPinToInterrupt(switchPin), switchISR, CHANGE);
}
///////////
// SETUP
///////////
void setup ()
{
setupPins();
}
//////////
// LOOP
//////////
void loop ()
{
// We just woke up: signal is 1 long blink
digitalWrite (LED, HIGH);
delay (2 * BLINK_DURATION_MS);
digitalWrite (LED, LOW);
// Some activity
gElapsed_ms = millis();
while (millis() - gElapsed_ms < ACTIVITY_MS)
{
delay(1);
}
// Signal we are going to sleep: 3 blinks
digitalWrite (LED, HIGH);
delay (BLINK_DURATION_MS);
digitalWrite (LED, LOW);
delay (BLINK_DURATION_MS);
digitalWrite (LED, HIGH);
delay (BLINK_DURATION_MS);
digitalWrite (LED, LOW);
delay (BLINK_DURATION_MS);
digitalWrite (LED, HIGH);
delay (BLINK_DURATION_MS);
digitalWrite (LED, LOW);
startSleep();
}
`
—
Reply to this email directly, view it on GitHub
<#250 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTXEW5A62DTQHLXF6SBYITUZZRHZANCNFSM5NT65BCA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Yes once I give the ATTinyCore users their 2.0.0 the stupid sleep library is next on the list. Oh, do you have MVIIO enabled in the fuses? That takes an additional 500nA so it woulod come out just about exactly what you see? |
Beta Was this translation helpful? Give feedback.
-
Did you read the errata for the AVR128? Maybe it's something like this: PD0_ Input Buffer is Floating There are also some other erratas that mentions increased power consumption. Edit: Update link to correct erratas revision |
Beta Was this translation helpful? Give feedback.
-
The issue with pd0 mentioned is specific to those parts that don't have the
the pin - they do have it internally it isn't connected to a pin that comes
out of the part, but can Stull result in increased power consumption just
like any other pin. Thats the bug. But I think DxCore sets it up as either
output or input pull up to prevent that...
…____________
Spence Konde
Azzy’S Electronics
New products! Check them out at tindie.com/stores/DrAzzy
GitHub: github.com/SpenceKonde
ATTinyCore: Arduino support for almost every ATTiny microcontroller
Contact: ***@***.***
On Thu, Feb 10, 2022, 03:59 XFer012 ***@***.***> wrote:
There is no PD0 on AVR128DB28.
The errata about increased power consumption does not apply here (Vdd is
3.3V), nor the one about OpAmp increased draw (fixed in A5 and newer
versions), but thanks for your contribution.
—
Reply to this email directly, view it on GitHub
<#250 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTXEW2TIBOHOUTBL5TA2M3U2N5AHANCNFSM5NT65BCA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Tried with pinMode (PIN_PD0, OUTPUT) , but still measuring 1100 nA. Any chance PERIOD in FUSE.WDTCFG is set to a value > 0 by the core? |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm using DxCore v1.4.7 (many thanks to @SpenceKonde, it's great!!) with Arduino 1.8.19; working with an AVR128DB28 and flashing via SerialUSB UPDI (CH340-based).
I'm looking into Power Down sleep mode.
With AtMega 328p, I was able to achieve 200 nA with Power Down mode, WDT disabled, wake up by pin interrupt.
With AVR128DB, the best I managed is 1100 nA with Power Down mode, all pins to INPUT_PULLUP, BOD disabled.
What's worse, the chip won't wake up from pin level change.
So I have two questions, if I may:
Why the higher power draw in Power Down mode? I also tried to disable WDT (WDT.CTRLA = 0) to no effect; maybe the register is locked by FUSE.WDTCFG so I can't change it at runtime? Don't know how to modify fuses
Is there a working code example for wake up (from Power Down) after a pin change interrupt? I am obviously doing something wrong (just copied over my code from 328p, where it works)
Thanks, regards
Fernando
Beta Was this translation helpful? Give feedback.
All reactions