Thanks for the encouragement.
So as to continue, I just now hooked up a factory fresh Moteino with the regular RFM69HW and wire antenna using Felix's FTDI connector. So, this is a little different, because Antenna is not shorted to ground, it has a wire antenna, and its voltage regulator is still intact. On the plus side, though, is that the hardware hasn't been monkeyed with, and so I don't expect anything will come loose anytime soon. Also, all of what follows should be easily reproducible by anyone reading this.
Here's the TL;DR summary: with this setup there
is a disparity between the results that come from just reading the D2 pin versus attaching an interrupt to the D2 pin.
Using:
while (!(digitalRead(D2))) {} // Wait for RSSI to go HIGH
the RSSI flag doesn't appear to go high until about 6968uSeconds after putting the RFM69HW into Rx Mode:
---------------------------------------------------------------------
RSSI=-116, rssiFlagRising=6968uSec
RSSI=-118, rssiFlagRising=6968uSec
RSSI=-117, rssiFlagRising=6968uSec
RSSI=-115, rssiFlagRising=6968uSec
---------------------------------------------------------------------
However, if I attach an interrupt instead to D2 and attempt to get the atmega328p to enter powerdown sleep, what I get instead is:
---------------------------------------------------------------------
RSSI=-118, rssiFlagRising=12uSec
RSSI=-118, rssiFlagRising=16uSec
RSSI=-118, rssiFlagRising=16uSec
RSSI=-118, rssiFlagRising=12uSec
---------------------------------------------------------------------
RSSI=-115, rssiFlagRising=12uSec
RSSI=-115, rssiFlagRising=16uSec
RSSI=-115, rssiFlagRising=16uSec
RSSI=-115, rssiFlagRising=16uSec
---------------------------------------------------------------------
RSSI=-116, rssiFlagRising=16uSec
RSSI=-116, rssiFlagRising=16uSec
RSSI=-116, rssiFlagRising=12uSec
RSSI=-116, rssiFlagRising=16uSec
---------------------------------------------------------------------
RSSI=-117, rssiFlagRising=16uSec
RSSI=-117, rssiFlagRising=16uSec
RSSI=-117, rssiFlagRising=12uSec
RSSI=-117, rssiFlagRising=16uSec
---------------------------------------------------------------------
Obviously, that is a dramatic difference.
The code I'm using to attach the interrupt, powerdown, and wake up, is Nick Gammon's "Sketch J" (
http://www.gammon.com.au/power), which I simply repackaged as "sleepNow()":
#include <avr/sleep.h>
void wake ()
{
// cancel sleep as a precaution
sleep_disable();
// precautionary while we do other stuff
detachInterrupt (0);
} // end of wake
void sleepNow ()
{
// disable ADC
ADCSRA = 0;
set_sleep_mode (SLEEP_MODE_PWR_DOWN);
sleep_enable();
// Do not interrupt before we go to sleep, or the
// ISR will detach interrupts and we won't wake.
noInterrupts ();
// will be called when pin D2 goes HIGH
attachInterrupt (0, wake, RISING);
EIFR = bit (INTF0); // clear flag for interrupt 0
// turn off brown-out enable in software
// BODS must be set to one and BODSE must be set to zero within four clock cycles
MCUCR = bit (BODS) | bit (BODSE);
// The BODS bit is automatically cleared after three clock cycles
MCUCR = bit (BODS);
// We are guaranteed that the sleep_cpu call will be done
// as the processor executes the next instruction after
// interrupts are turned on.
interrupts (); // one cycle
sleep_cpu (); // one cycle
} // end of sleepNow()
The only difference between the first and second sets of results is that I replaced:
while (!(digitalRead(D2))) {} // Wait for RSSI to go HIGH
with
If anyone has a better way to handle the interrupt scenario, please post a link and I'll try it instead. Normally Gammon's code works just fine for me, but just not now when DIO0 is mapped to RSSI. What's clear is that the atmega328p never even fully gets into deep powerdown sleep, because if it did, it would take about 2.1ms (at 8Mhz) just to wake up.