cogstop question
mikea
Posts: 283
Is there a way to use cogstop and have it pick up where it left off rather than starting it with cognew and beggining at the top of the code? The main code gets gps data and sends it to an lcd. There are a lot of pauses so theres another cog to jump in and take over the lcd momentarily so i need to pause the first cog off without losing its place. Any suggestions would be great.thanks-mike
Comments
Is the LCD a serial LCD or a 4/8bit parallel LCD?
If it is a parallel, do you have a chip-select or is the CS connected to "ALWAY SELECTED"?
If it is a real CS you could use the CS to see if the other COG is finished with writing to the LCD. You could use waitpeq/waitpne instructions to set the COG into "sleep"-mode until CS changes.
If you don't have a real CS and/or you don't have a parallel LCD you could also use another pin to synchronize both COGs.
Another way would be to use a HUB-RAM location to send instructions from one COG to the other. For example there could be messages like SUSPEND and RESUME. In case of SUSPEND the COG could simply run a waitcnt-loop until it finds the RESUME instruction. (Instead of HUB-RAM you could also use the LOCKs available in the Propeller)
All waitxxx instructions will reduce power-consumption in the COGs. The difference in the 2 methods (use waitpne/waitpeq versus waitcnt) is, that waiting for a pin-change will immediately react but it needs a pin. The waitcnt will only react within the time you have chosen as waittime. So, depending on the requirements it might be good enough.
the lock first, and release it after drawing to avoid hogging it. Other global hub variables can signal when the LCD
has been overwritten so each cog knows how much to redraw after reclaiming the lock.
I was thinking more along the line of a call to a subroutine that checks a shared variable for a stop command. When the subroutine sees the stop command it goes into a continuous loop that checks the shared variable and returns to the next instruction or a specific location when a new command is written into the shared variable by another cog.