Skip to content

Conversation

@johngarchie
Copy link

Thought these changes might interest you. See the individual commit comments for details.

John Archie added 2 commits September 7, 2014 11:23
All deprecated interrupt names have been replaced by their
current equivalents:

    SIG_OVERFLOW0   -> TIMER0_OVF_vect
    SIG_PIN_CHANGE2 -> PCINT2_vect
    SIG_PIN_CHANGE0 -> PCINT0_vect
    SIG_INTERRUPT0  -> INT0_vect
    SIG_COMPARATOR  -> ANALOG_COMP_vect

The code no longer generates compile errors on recent versions of GCC.
(Tested on avr-gcc 4.8.2.)
This commit includes four sleep-related bugfixes.  Together, these
changes should ensure more reliable sleep behavior.

The code now uses a 2 MHz clock speed during sleep--fast enough for
reliable asynchronous timer (timer2) operation, but slow enough for
oscillator stability at 1.7 volts, the lowest possible voltage ensured
by the BOD settings.

Timer2 is now initialized only if not already initialized.  This
prevents time loss due to the unnecessary reinitializations after
calls to app_start().

The sleep code now ensures that all asynchronous timer settings are
latched before sleeping to ensure reliable waking via the once-per-
second time keeping interrupt.

The once-per-second interrupt must not exit before a full crystal
oscillation, so OCR2B--an unused timer2 register--is written at the
beginning of the interrupt routine.  The value of OCR2B is latched
after two positive edges from the crystal oscillator, and since the
system will not sleep until all asynchronous timer (timer2) registers
are latched, the system will not sleep until the necessary time has
passed.
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.

1 participant