Repeatedly starting and stopping a cog.....
th3jester
Posts: 81
Simple question:
Is it efficient/alright/okay if I continuously start and stop and restart a cog?
i.e.-
repeat
fMath.start
(do some math routines)
fMath.Stop
Is it efficient/alright/okay if I continuously start and stop and restart a cog?
i.e.-
repeat
fMath.start
(do some math routines)
fMath.Stop
Comments
efficient in terms of power consumption: depends on the average runtime of the COG. If you start it repeatingly you waste power for the startup process, where the COG has to load 512 LONGs from HUB RAM. The more often you start the COG inrelation to the runtime the more power you waste. If you can use a WAITCNT/WAITPEQ/WAITPNE you should prefere these for saving power.
efficient in terms of execution speed: again you have the startup. Response time for external events is much faster when not restarting but keeping the COG in a loop.
Alright: It won't harm the propeller. It's been build for that.
Okay: As you can see from the previous answers, it simply depends on what the propeller has to do. Restarting a COG each second which has to generate a video signal is a bad idea in general. Starting and stopping COGs which are related to user-input/actions/instructions .. why not.
If your design does not need high response times and you prefere an easy implementation for power saving or if you do not have enough COGs for having a "background" COG for all the tasks ...