How to restart cog zero?
william chan
Posts: 1,326
It seems that COGINIT needs a method and a stack address.
But COG zero (1st COG) does not need a starting method or a stack address.
So how to coginit the first cog?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
But COG zero (1st COG) does not need a starting method or a stack address.
So how to coginit the first cog?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
Comments
My watchdog cog is cog number 2.
So how does the watchdog cog restart cog zero if it detects a problem?
Should it be
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
If you've created a watchdog and need to restart your main program, the best way to do that is to reset the chip. Ohterwise, your main program will create additional running copies of your watchdog and other cogs that it starts via COGNEW. (You do use COGNEW, don't you, and not COGINIT?)
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
Post Edited (Phil Pilgrim (PhiPi)) : 9/15/2008 8:19:32 PM GMT
CogInit( 0, $F004, $0004 )
You'd have to design for this likelihood as stack space used could be different the second time round depending on what program paths are taken, variables won't be reset to zero, and cogs which are continuing to run will be using whatever space they had.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
So if i reboot the whole chip, the date/time is lost.
Hippy,
Are you sure the stack location for Cog zero is $0004 ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my
www.mercedes.com.my
I think you'd have to get the starting location of the program in the same way from the 1st 16 bytes of memory.
I don't have the info handy, but there's a description of this header information in one of the threads off Graham
Stabler's Good Thread Index in the "sticky" threads.
Why not use your main cog as a combination realtime clock, watchdog, and supervisor? That way if you need to restart a cog, you can do it with COGSTOP, and then use COGNEW the same way you launched it to begin with. That would be less awkward than trying to reload a parent cog via one of its offspring. Plus you don't run into the problem of the restarted main cog trying to reload your watchdog/realtime clock.
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
It's not, but then you are not starting a Spin method which needs a stack, you're starting a PASM routine which is in ROM ( the Spin Interpreter ) which uses the 'program header' parameter block to initialise and run your top-level program.
The $F004 is the starting address of the Spin Interpreter, $0004-$00F is the parameter block.