what about calls from a cog
ChuckT
Posts: 12
If inside a cog I call a method from another object where does it execute? Inside the cog that called it. but without the local variable support? is this correct?
I think if the cog is called from an object then it has access to the variables from the parent obj.
But if a cog calls outside its parent object then how can the called method know its local variables.
I cant get my driver to work when it is called from another cog. do I need to supply it with all its local variables.
I think if the cog is called from an object then it has access to the variables from the parent obj.
But if a cog calls outside its parent object then how can the called method know its local variables.
I cant get my driver to work when it is called from another cog. do I need to supply it with all its local variables.
Comments
One object does not have access to the variables of another object no matter what cog is executing.· You can pass the address of a variable or block of variables from one object to another and that second object can access the variables indirectly.· Again, it doesn't matter what cog is running.
You run into two issues when more than one cog is executing your code:
1) Each cog has its own special registers (OUTA, DIRA, PHSA, FRQA, CTRA, etc.)· This is particularly an issue when one cog sets up an I/O pin as an output, but another cog tries to set the output state (high or low) without initializing the DIRA bit.
2) If two cogs attempt to change a variable, they might do it at essentially the same time even though the actual write operation is managed by the hub logic so there's no conflict.· One cog might copy the value to the stack and modify it before writing it back and the 2nd cog could change the value between the copy and the write.
If you want specific suggestions for your driver, you'll have to post it as an attachment, otherwise all we can make are general suggestions.