Spin and COGS
inaki
Posts: 262
If I write all my stuff in Spin is it possible to use more than one COG at the same time ?
I understand that the Spin interpreter uses a COG for itself while the Spin code is read from the main RAM.
So, are·the other·seven COGs idle ?
Is there any way in Spin to use several COGs at the same time ? If so, how this·is done ? Are there more than a single SPIN interpreter running or there is some code generated on the fly for a COG ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I understand that the Spin interpreter uses a COG for itself while the Spin code is read from the main RAM.
So, are·the other·seven COGs idle ?
Is there any way in Spin to use several COGs at the same time ? If so, how this·is done ? Are there more than a single SPIN interpreter running or there is some code generated on the fly for a COG ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Comments
The cognew() inctruction is used to start a new cog and tell it which code to run.
Look over some of Dave's example/tutorial programs posted on this board.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Southern Illinois University Carbondale - Electronic Systems Technologies
Personal Links with plenty of BASIC Stamp info
StampPlot - Graphical Data Acquisition and Control
Yes, you can use more than one cog at a time with Spin.· If you look at the attached files you'll find an object called Timer.· The key element is a method called updateTimer that gets launched into its own cog where -- when enabled -- it updates the timer registers 100 times per second.· You see that the top level object, Timer_Test, simply calls the showTimer method to display the current HH:MM:SS.XX value.
Update: I found a sync error in the timer and I have made several other improvements.· I will take this object and create a new one called RTC that will include clock and calendar functions.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 4/7/2006 6:06:25 AM GMT
I was asking because I hear all the time that in order to execute code in a COG it must be written in assembler. I did not realize that when cognew is invoked a new Spin interpreter is launched.
So, if I understand well, the call to cognew(updatetimer) means that a new Spin interpreter is launched in a new COG to manage that routine. Is this right ?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax