I believe "full asynchronous detection" is referring to when the main clock is not running, which could also be in standby mode:
This is the test I used:
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
// button on PA6 (arduino D2) can wake from sleep on falling edge
// button on PA4 (arduino D0) must wake from sleep on level change
const uint8_t ledPin = 7 ; // PB0 (arduino D7)
ISR(PORTA_PORT_vect)
{
PORTA.INTFLAGS = PIN4_bm | PIN6_bm ; // clear interrupt **
}
ISR(RTC_CNT_vect)
{
RTC.INTFLAGS = RTC_OVF_bm | RTC_CMP_bm ;
}
void setup() {
Serial.begin( 115200 );
pinMode( ledPin, OUTPUT ) ;
digitalWrite( ledPin, HIGH ) ;
delay(1000) ;
digitalWrite( ledPin, LOW ) ;
// set up PA6 (D2) for falling interrupts
//PORTA.PIN6CTRL = (PORTA.PIN6CTRL & ~PORT_ISC_gm) | PORT_ISC_FALLING_gc | PORT_PULLUPEN_bm ;
// OR
// set up PA4 (D0) for LEVEL change interrupts
PORTA.PIN4CTRL = (PORTA.PIN4CTRL & ~PORT_ISC_gm) | PORT_ISC_LEVEL_gc | PORT_PULLUPEN_bm ;
// set up RTC
while (RTC.STATUS > 0) {} // Wait for all register to be synchronized
cli() ;
// see http://ww1.microchip.com/downloads/en/AppNotes/TB3213-Getting-Started-with-RTC-90003213A.pdf
RTC.CLKSEL = RTC_CLKSEL_INT1K_gc; // 32KHz divided by 32, i.e run at 1.024kHz
RTC.CTRLA = RTC_PRESCALER_DIV1_gc // NO Prescaler
| RTC_RTCEN_bm // Enable RTC
| RTC_RUNSTDBY_bm; // Run in standby
RTC.CNT = 0;
RTC.PER = 4096UL ; // 4 seconds
set_sleep_mode(SLEEP_MODE_STANDBY);
RTC.INTCTRL = RTC_OVF_bm ;
sei() ;
}
void loop() {
digitalWrite( ledPin, HIGH ) ;
delay( 500 ) ;
digitalWrite( ledPin, LOW ) ;
delay( 500 ) ;
cli() ;
RTC.CNT = 0;
sei() ;
sleep_enable();
sleep_cpu();
// wake here
}
