Restarting stopped COGS (Power save mode?)

With all the discussion on COG allocation etc. across on the LUT share thread I thought I would bring up another cog allocation scenario to add to the mix.
When the start address S[19:0] of COGINIT is <$200 and D[5]=1 the cog can be restarted with the code already resident in COGRAM.
This works great as long as your aware that a restart also resets DIRx bits.
This demo code starts a cog, waits 4 secs then stops it. 4 secs later restarts it in a different location.
When the start address S[19:0] of COGINIT is <$200 and D[5]=1 the cog can be restarted with the code already resident in COGRAM.
This works great as long as your aware that a restart also resets DIRx bits.
This demo code starts a cog, waits 4 secs then stops it. 4 secs later restarts it in a different location.
sys_clk = 80_000_000
selected_cog = 5
dat org
loc ptra,#@mycode
coginit #selected_cog,ptra 'start cog
waitx ##sys_clk * 4
cogstop #selected_cog 'pause cog
waitx ##sys_clk * 4
coginit #32+selected_cog,#restart 'restart cog at different cogram address
here jmp #here
'==== code to stop/start =========
orgh $400
org
mycode setb dirb,#0
setb dirb,#2 '<< lost on restart
.loop notb outb,#0
waitx ##sys_clk >> 4 'fast flash
jmp #.loop
restart setb dirb,#2 '*** restore port direction bit
.loop2 waitx ##sys_clk >> 1 'slow flash
notb outb,#2
jmp #.loop2
Comments
Thanks for the reminder.
Will COGSTOP be lower power, than WAITX ?
COGSTOP stops all toggling within a cog.
So what is the predicted difference in power, between a WAIT and a COGSTOP COG ?
There will be much less toggling during a WAIT than occurs during running. The streamer may still be running, but the cog ALU is pretty much suspended, waiting for the WAIT to end.
Very good points!
I've proposed a COGFRZ state to cover this, in the other thread.
Probably better covered here.