It might be simpler to add an external power switch where a pulse from an output pin turns off the power completely until a button is pushed such as: https://www.pololu.com/product/2808
I need software solution, there are more features in my project and i want to shutdown after a timeout without use...
/********************* go to deep sleep *********************/
#define SMC_PMPROT_AVLLS_MASK 0x2u
#define SMC_PMCTRL_STOPM_MASK 0x7u
#define SCB_SCR_SLEEPDEEP_MASK 0x4u
// see SMC section (e.g. p 339 of K66)
#define VLLS3 0x3 // RAM retained I/O states held
#define VLLS2 0x2 // RAM partially retained
#define VLLS1 0x1 // I/O states help
#define VLLS0 0x0 // all stop
#define VLLS_MODE VLLS0
void gotoSleep(void)
{
// /* Make sure clock monitor is off so we don't get spurious reset */
// MCG_C6 &= ~MCG_C6_CME0;
//
/* Write to PMPROT to allow all possible power modes */
SMC_PMPROT = SMC_PMPROT_AVLLS_MASK;
/* Set the STOPM field to 0b100 for VLLSx mode */
SMC_PMCTRL &= ~SMC_PMCTRL_STOPM_MASK;
SMC_PMCTRL |= SMC_PMCTRL_STOPM(0x4); // VLLSx
SMC_VLLSCTRL = SMC_VLLSCTRL_VLLSM(VLLS_MODE);
/*wait for write to complete to SMC before stopping core */
(void) SMC_PMCTRL;
SYST_CSR &= ~SYST_CSR_TICKINT; // disable systick timer interrupt
SCB_SCR |= SCB_SCR_SLEEPDEEP_MASK; // Set the SLEEPDEEP bit to enable deep sleep mode (STOP)
asm volatile( "wfi" ); // WFI instruction will start entry into STOP mode
// will never return, but call ResetHandler() in mk20dx128.c
}
Its absolutely not to old, I'm working on it right now for better USB operation. Did you download the latest version? As far as turning the Teensy off, you need some external circuitry to truly turn it off, i.e., cut power but if you want to go to a low power mode you just set it up for pin wakeup and then do not connect anything to that pin. I'm wondering why you want a project that never wakes up?Snooze library is too old i think, there are the examples that they can not compile
There is a simple command of snooze for the hibernate without wakeup option?
This is part of my hibernate routines
If you want a wakeup, you have to program it first before calling gotoSleep()
I need software solution, there are more features in my project and i want to shutdown after a timeout without use...
.Your code works fine! Thanks! What's the power consumption?