Another round of passing data
Can someone point me to some simple examples in SPIN where two or more COGS are accessing the same set of data ? I see some assembler, but I'd rather not add to my list. The application has a sensor package that is posting an array of longs. Two other COGS are running and use the data (one to make physical changes, one to log to storage). I'm pretty new to this so simple is best.
Thanks
Thanks

Comments
As long as you aren't using data sizes bigger than longs, it doesn't take much. Any longer and you'll have to start dealing with methods to synch using locks or what not.
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
SelmaWare Solutions - StampPlot GUI for controllers, XBee and Propeller Application Boards
Southern Illinois University Carbondale, Electronic Systems Technologies
American Technical Educator's Assoc. Conference·- April, Biloxi, MS. -- PROPELLER WORKSHOP!
Here the routine running on the first cog
{{MotionController2.spin}} VAR long StepTime long ActPos long RefPos byte MotStat byte SynchControl byte Pin0 OBJ Motion : "Stepper_A2919" PUB Main StepTime := 100_000 MotStat := 0 Pin0 := 0 Motion.Start(Pin0,@MotStat,@StepTime) repeat if ina[noparse][[/noparse]11..8] == 14 MotStat := 1 elseif ina[noparse][[/noparse]11..8] == 12 MotStat := 3 else MotStat := 0and here the routine(s) running on an other:
'stepper_A2919 {{MotStat Bit 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | State: 0 | 1 I I I I I I I I-------> Stop | Run I I I I I I I-----------> Forward | Backward I I I I I I---------------> Halfstep | Fullstep not implemented yet I I I I I-------------------> SPhase | TPhase not implemented yet I I I I-----------------------> Continous | Controled not implemented yet I I I---------------------------> NU I I-------------------------------> NU I-----------------------------------> NU Pin0 = P1 Pin0+1 = P2 Pin0+2 = P3 Pin0+3 = P4 P5 = VSS!!! (GND) }} VAR long Stack[noparse][[/noparse]14] 'Stack space for new cog byte Cog 'Hold ID of cog in use, if any byte StepNr 'the actual step number long MCounter 'counter to hold the waitcycles CON Run = 1 Backward = 2 FullStep = 4 TPhase = 8 Synch = 128 PUB Start(Pin0,AdrMotStat, AdrStepTime): Success Stop Success := (Cog := cognew(ManageMotor(Pin0,AdrMotStat, AdrStepTime), @Stack) + 1) PUB Stop {{Stop toggling process, if any.}} if Cog cogstop(Cog~ - 1) PUB ManageMotor(Pin0, AdrMotStat, AdrStepTime) StepNr~ 'clear the StepNr counter dira[noparse][[/noparse]Pin0+7 .. Pin0]~~ 'sets the needed pins as output repeat repeat until byte[noparse][[/noparse]AdrMotStat] & Run 'wait until motor has to run! if byte[noparse][[/noparse]AdrMotStat] & Backward --StepNr 'backward if StepNr == 255 StepNr := 7 else ++StepNr 'foreward if StepNr > 7 StepNr := 0 outa[noparse][[/noparse]Pin0+3 .. Pin0] := STEPTBL[noparse][[/noparse]StepNr] 'set the outputs depending on the StepNr waitcnt(clkfreq / 1_000_000 * long[noparse][[/noparse]AdrStepTime] + cnt) 'Wait for steptime cycles DAT STEPTBL byte 4, 0, 1, 2, 6, 10, 9, 8 'table for controling the motor (halfsteps)This is a stepper motor routine that (when finished!?) will run some stepper motors simultaneous controlled by the main program!
Saluti Joerg