Skip to content

LowPower.idle() doesn't work as expected, and the argument to LowPower.idle(millis) has absolutely no effect. #39

Open
@be-philippe

Description

@be-philippe

This simple sketch (on a SAMD21, for ex. MKR WiFi 1010):

#include <ArduinoLowPower.h>

void setup()
{
  pinMode(0, OUTPUT);
  digitalWrite(0, LOW);
}

void loop()
{
  LowPower.idle();
  digitalWrite(0, !digitalRead(0));
}

produces a nice ~500 Hz square wave on pin D0, because the IDLE state is ended by the SysTick interrupt every ms.
This is fine and useful, but should be properly documented.

Adding any value as argument to LowPower.idle(): (I use random() here to emphasize any)

  LowPower.idle((int)random(1000));

lowers the frequency to ~10.6 Hz.

Setting the RTC alarm takes ~46 ms, and then the IDLE state is ended on the next SysTick interrupt.

Most of the time needed to set the RTC alarm comes from synchronisation calls in RTCZero.cpp like

    while (RTCisSyncing())
      ;

I guess looping around the wfi instruction waiting for the right time to pass would be a better solution than using the RTC...

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: documentationRelated to documentation for the projecttype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions