sharing variables between cogs
it has been a long time that I did not code for the propeller-chip.
Now I'm back. I have quite some experience with coding in Delphi so I'm familiar with the basic concepts.
But I do not remember much how things are coded in spin.
I have a somehow advanced project that I want to do: driving mutliple stepper-motors controlled through a serial interface.
My basic idea is: one cog receives commands and sets up a second cog to do the step-creation.
For the step-creation I want to use this principle:
A loop is running very fast. As fast as possible. This loop is incrementing a variable with each iteration.
If for one of multiple stepper-motors step-pulses shall be created depends on a variable "StepsToDo"
as long as StepsToDo is bigger than zero => create a step-pulse decrement variable StepsToDo by 1
The frequency of the step-pulses shall be depend on a divisor
everytime counter // divisor == 0 create a step-pulse. I'm aware of, that this method does not allow any frequency only certain frequencies. But this is OK.
This means the "master-cog" must set variables for the code running in the step-pulses-creation-cog
How is this done? Do I have to do this by using the cog-stack? Or simply assigning a value to a "normal declared" variable?
Is there any example where I can study the principle?
best regards Stefan