Thank you for replying. I have looked at it, and to be honest, I'm just a bit lost on where to go with it. I was looking for a working example of how to implement it, and haven't exactly found anything that actually works. I have played around with it, as follows (leaving out other items specific to the board I made):
#include <Arduino.h>
#define led 13
#define button 48 //define for power button
void setup() {
// put your setup code here, to run once:
SerialUSB.begin(115200);
SerialUSB.println();
SerialUSB.println("Begin setup.");
//Set LED "L" to also give a heartbeat
pinMode(led, OUTPUT);
pinMode(button, INPUT);
attachInterrupt(button, wake_ISR, FALLING);
SerialUSB.println("Initial Setup Complete.");
}
void wake_ISR() // interrupt to handle a wake up button press
{
SerialUSB.println("waking up");
PMC->PMC_FSMR |= PMC_FSMR_FSTT7;
}
void loop() {
// put your main code here, to run repeatedly:
SerialUSB.println("LED Loop begins.");
for(int i=0;i<10;i++)
{
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
//After blinking for 10 seconds, put it all to sleep
SerialUSB.println("Going to sleep.");
pmc_set_writeprotect(0); //disable write protect of pmc registers
pmc_set_fast_startup_input(PMC_FSMR_FSTT7); //enable fast startup, wakeup pin 7
pmc_enable_waitmode(); //lower power mode versus sleep mode
}
This does not work at all, incidentally. Commenting PMC->PMC_FSMR |= PMC_FSMR_FSTT7; out of the ISR makes it somewhat functional, in that the processor seems to sleep until the ISR runs. However, current draw is still around 70mA, which is what it draws when it is awake, anyway.
My actual goal is to be able to push a Power button, on pin 48, have the routine shut down all attached peripherals (discretely, with other code), and then have the SAM3X8E go into backup power mode (that is the lowest power draw mode, correct?), and then wake up, and basically reset when the power button is pushed again. The idea is that this will be in a small battery powered device that we do not want running all of the time, and want to save the battery. I have done this on other projects, and have had good luck. This is my first go at that SAM3X, and I can really use all the help I can get. Thanks!