Variables & Cogs
Travis M. Best
Posts: 9
First I Want To Thank Everyone So Far For All Their Help I've Learned Alot On The Propeller Chip. Thanks To Everyone's Help. I do have another Issues and that is I am try to read and write to variables between cogs what is the best way to do this??
Thanks
Travis
Thanks
Travis
Comments
If you have two cogs running Spin code in different objects, the variable names are not available outside the object(s). One object can call a routine in the other object to set the variable to some value or to return (get) the value of the variable. You can also call a routine in another object that returns the address of a variable which can be used to set or get the variable value (using LONG, WORD, or BYTE). You do have to be careful about two separate cogs trying to change the same variable(s) at the same time.
If you want more specific suggestions or examples, you're going to have to explain in more detail what you're trying to do.
It could also be useful to know if he was talking about main ram, or cogs 512 long, but I suspect it's about the main ram, hehe.If it's main ram and same file, he don't have to worry about address things, just use the variable name, simple as that!
Anyway, I'm just reformulating what the forum master has said (Mike) but he did it better than me :P