Accessing hub variables from multiple cogs
I'm doing an application with the P2 Edge and Spin2. Everything is working fine but now I'm delving into using multiple cogs. I'm starting them like this:
cogspin(NEWCOG, @CogMethod, @CogStack)
And now I'm running into occasions where the P2 just locks up. I'm still trying to pinpoint the exact code, but the common thread seems to be situations where multiple cogs are trying to access the same hub variables. (I assume this is the location of spin variables defined in VAR.)
Are there any precautions that need to be taken when multiple cogs access the same global variables? The P2 datasheet indicates that there are safeguards in place to prevent problems, but it seems mostly geared toward PASM.
I understand that in these instances care would need to be taken to prevent corrupted data, with locks and such, but I'm puzzled as to why this would cause a processor crash.