Shop OBEX P1 Docs P2 Docs Learn Events
Restart a cog after COGSTOP ? — Parallax Forums

Restart a cog after COGSTOP ?

RonnyRonny Posts: 1
edited 2006-12-07 17:37 in Propeller 1
Is it possible to start·a cog again after a COGSTOP ?
I would not like to do a COGINIT and restart it from zero, just to continue the program
where it has stopped.

I am thinking of a way to expand the video program to use·external ram.
One cog is doing the video signal. When it needs to fetch data from extern ram,
it has to stop the cog that's write data to the video ram and start it again when finish
(of course, I must save current state of ram-pin first before I start to read the ram).

/Ronny

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-07 17:37
    It is not possible to continue after a COGSTOP.

    If you look at existing programs that "restart", they don't actually stop. They use one or more variables in main (hub) memory to communicate with other cogs and typically hang in a loop waiting for a particular value to appear in that location.

    An alternative is to use WAITCNT to wait for some fixed period of time to elapse or use WAITPNE/WAITPEQ to wait for some I/O pin to reach a particular status.

    Again, look at existing programs in the library included with the Propeller Tool. The graphics library is one example. The assembly Floating Point library is another example of a kind of interpreter done in assembly that sits in a cog waiting to be asked to do something.

    For the problem you're thinking about (how to share an external ram between a video driver and the program modifying it), you could use a buffer of addresses and their values to write to ram, then, during the vertical and horizontal retrace times, you could read from the buffer and update the ram rather than having to interrupt the display process (which would cause flashes on the screen). The routine that adds to the buffer would simply wait for there to be room in the buffer. The video driver itself would never actually stop.
Sign In or Register to comment.