Go Down

Topic: How to return to void loop() from sleep mode directly  (Read 229 times) previous topic - next topic

knee266

I have a sketch that needs to return to void loop()  from Powersave mode directly.
May I know how to do?

here is the simple sketch for explain:


void setup()
{
attachInterrupt(0, wakeISR, LOW);  <<<<< I need return to loop() directly.
}




void loop()
{

//if ADC value a,b no any change over 30 sec. then going to PowerSave mode.
   
while  (a<0 && b<0)
   {
   energy.PowerSave();
   }



//If the value of a and b have changes within 30 sec., continue run sketch


other sketch



}

DrAzzy

ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

6v6gt

What MCU is it ?
and what is in  energy.PowerSave() ; ?
Anyway, if it is AVR based ( like Uno etc.), on waking the sketch starts at exactly after that point in the sketch at which it stopped. So, in your case, on waking, the sketch resumes at the statement after energy.PowerSave() .

Alfresco

You can do this using an empty Interrupt Service Routine(ISR).

knee266

Just have an empty ISR.
thanks for you help.

Here is a part of schematic.
The J1 is the function button and shared with interrupt pin.
When I press button ,the 328P will always be interrupted.
Can I ignore the external wakeup (INT0) when the CPU wakes up?

Go Up