Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed powerDown-Dps2.ino #282

Merged
merged 2 commits into from
Jun 6, 2023
Merged

Fixed powerDown-Dps2.ino #282

merged 2 commits into from
Jun 6, 2023

Conversation

wollewald
Copy link
Contributor

Found a bug in powerDown-Dps2.ino:
IOCWK = PORTD2) | PORTD4);

should be

IOCWK = (1<<PORTD2) | (1<<PORTD4);

And some issues in the comments.

@LaZsolt
Copy link
Collaborator

LaZsolt commented May 28, 2023

Thank you for reviewing the examples.
This is an untested example I haven't tested. I tested DPS2 mode without setting wake up sources.

@LaZsolt
Copy link
Collaborator

LaZsolt commented May 28, 2023

However, a 1-second sleep lasts much longer than 1 second.

@wollewald
Copy link
Contributor Author

I also found that the parameters for LowPower.adcNoiseReduction() and LowPower.powerDown() in lgt_LowerPower/readme.md do not match the allowed parameters. In the examples it's all good.

I forgot to say: Thank you for your great work on this library! I took a LQFP32 "Pro Mini" MiniEVB, removed the LEDs and the voltage regulator, supplied it with 5 V and tested the sleep modes with regards to the supply current. This is what I found:

power_consumption_in_sleep_modes

Fantastic!

@LaZsolt
Copy link
Collaborator

LaZsolt commented May 30, 2023

I also found that the parameters for LowPower.adcNoiseReduction() and LowPower.powerDown() in lgt_LowerPower/readme.md do not match the allowed parameters. In the examples it's all good.

The error in readme.md comes from the fact that the datasheet does not seem completely clear, so at first I experimented with more variable parameters than what was included in the final version. For example, switching the main clock to 32kHz did not reduce the current draw in DPS0 or DPS1 mode. The another interesting thing for me was that I measured the same current consumption in both DPS0 and DSP1 modes.

According to my measurement I measured the same current consumption in DPS0/1/2 modes than you.

In a few days I will merge your changes.

@LaZsolt
Copy link
Collaborator

LaZsolt commented May 30, 2023

I took a LQFP32 "Pro Mini" MiniEVB, removed the LEDs ....

I wrote the examples so that if you don't remove the LED off from D13 output you still measure the same current values in DPS0/1 modes. But not in DPS2 mode.

@wollewald
Copy link
Contributor Author

You are right. In order to test your examples it makes no sense to remove the LEDs. But the purpose of my tests was different. I wanted to measure how far you get down in power consumption. And for this I didn't want that any LED would comsume power. I tested the different sleep modes with this sketch by uncommenting the relevant lines:

#include "lgt_LowPower.h"

void setup()
{
  // Pin settings for low consumption in sleep mode.
    DDRB  = 0x00;                 // Set all pins to input
    DDRC  = 0x00;
    DDRD  = 0x00;
    DDRE  = 0x00;
    PORTB = 0xFF;                 // Set all input with internal pull up resistors
    PORTC = 0xFF;
    PORTD = 0xFF;
    PORTE = 0xFF;
//    IOCWK = (1<<PORTD4);  // for deepSleep2 mode 
}

void loop() {
    delay(10000); // To get stable power consumption in active mode

//    LowPower.idle(SLEEP_32S,ADC_OFF,TIMER3_OFF,TIMER2_OFF,TIMER1_OFF,TIMER0_OFF,
//    SPI_OFF,USART0_OFF,TWI_OFF,PCIC_OFF,FLASHCTL_OFF);

//    LowPower.adcNoiseReduction(SLEEP_32S, ADC_ON, TIMER2_OFF);

//    LowPower.powerStandby(SLEEP_FOREVER, ADC_OFF, BOD_OFF, TIMER2_OFF);  

//    LowPower.powerExtStandby(SLEEP_FOREVER, ADC_OFF, BOD_OFF, TIMER2_OFF);

    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);

//    LowPower.deepSleep2(SLEEP_FOREVER);

}

@LaZsolt LaZsolt merged commit b5f19ca into dbuezas:master Jun 6, 2023
@dbuezas
Copy link
Owner

dbuezas commented Jun 8, 2023

The CI broke somehow, I'll fix it soon and release

@dbuezas
Copy link
Owner

dbuezas commented Jun 8, 2023

released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants