[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 

Taskmanager and slepping.. RSS feed
Forum Index » IoAbstraction & TaskManagerIO
Author Message
lafleur


Joined: Feb 20, 2021
Messages: 1
Offline
If I have a number of tasks, and I put the CPU to sleep if an interrupt occurs, and I process the interrupt..

what is the best method to resume my sleep??

go back and use taskManager.microsToNextTask() to recompute my next wake time ??
or what other options??
davetcc


Joined: Jan 19, 2019
Messages: 321
Offline
This is an advanced topic. There are so many possible combinations that it is probably beyond the scope of the forum to discuss them all.

However, task manager execution is driven by the runLoop() method, which you would normally call in the main() or loop() method, it checks if any tasks are ready to be executed and executes them if needed, it also evaluates any events if needed.

As you rightly pointed out below you can use microsToNextTask along with a low power library or call, to avoid busy waiting by repeatedly calling the runLoop method, in fact there is an example of this for SAMD here: https://www.thecoderscorner.com/products/arduino-libraries/taskmanager-io/task-manager-low-power-samd-example/. A major point to consider is that you must make sure that if you want to process interrupts, that the processor would be awakened from the sleep by that interrupt.

I would say the best way unless it doesn't work is to follow something similar to the example above.
davetcc


Joined: Jan 19, 2019
Messages: 321
Offline
Also, let's say that you handled the interrupt as an event, you could either marshall the interrupt by using the task manager interrupt support, or you could have a raw interrupt handler instead and just trigger an event in the raw IRQ. As long as your sleep method woke up on the interrupt, set the event as triggered, then all should be good.

As with all signals, you should probably wake up occasionally and make sure that all state is as expected. You could add a task to task manager that scheduled every N seconds (or whatever was tolerable) that ensured everything was in a good state.

I would take a look at the events and interrupt sections of https://www.thecoderscorner.com/products/arduino-libraries/taskmanager-io/
 
Forum Index » IoAbstraction & TaskManagerIO
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer