Skip to content

Sleep mode may need an extra reset #2

@henkmuller

Description

@henkmuller

I think sleep mode cannot work without an extra reset.

The process for sleep mode in this repo is:

  1. Setup sleep mode
  2. switch silicon oscillator on
  3. switch to silicon oscillator
  4. switch crystal oscillator off
  5. go to sleep

The problem is with step (3). If there is a sudden change to the oscillator, then the PLL will unlock, chase, and may run the processor at an out-of-spec frequency, hanging the processor before (4) and (5) complete.

As USB relies on 12 or 24 MHz, and the crystal oscillator runs at 20, this is a nono for devices that use a USB style crystal. The software in this repo checks for the crystal frequency and skips steps 2, 3 and 4 in this case; this is a bit unfortunate, as you will end up in a less deep sleep mode that uses 10x more power.

Even if you use a 20 MHz crystal, it still does not work because (a) the silicon oscillator may be way out, and (b) even if it was 20 MHz, it may be out of phase by 180 degrees, and I don’t think the PLL will take that well. At present, the software in this repo accepts this case.

I think an extra reset will work:

  1. Setup sleep mode
  2. switch silicon oscillator on
  3. switch to silicon oscillator & reset the xCORE
  4. on boot check if the silicon oscillator is on - if so
    • switch crystal oscillator off
    • go to sleep

When it comes out of sleep it should switch back to the crystal oscillator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions