After several weeks of “almost” getting there trying to use the LUT to share information between two process, I've given up and gone back to sharing data through the Hub Ram only.
I'd get everything working and think I was finally starting to get a handle on how the LUT sharing worked. Then I'd change something that SHOULDN'T have affected anything and it would all fall to pieces again. Seriously, add a NOP, insert a WAITX etc. and the data shared between cogs would be corrupted. Nothing like this happens using the Hub Ram.
I'm still using a couple of flags in the LUT to trigger functions between two cogs, This seem to work fine with a waitx #6 after setting one or the other of the flags but once I start to pass substantial amounts of information it breaks.
Is anyone else having difficulty using LUT sharing? Is there some timing trick I'm missing? Odds are good that I'm having issues with overwriting memory while it's being read. I've tried to establish “Locks” to prevent this but still no luck.
I can use the lut as “Scratchpad memory” for one cog with no problem, but between cogs is another matter.
I'm running one function in cog 2 and the other in cog 3. Is there some other combination that might work better?
At startup I am using this sequence:
coginit cognum1, ##@onemove ' init cog 2 for movement
coginit cognum2, #@mset ' init cog 3 for the setup functions.
cogstop #0 ' terminate the startup cog. coginit cognum2, #@mset ' init cog1 for the setup
cognum1 long 2
cognum2 long 3
Is this incorrect for using LUT sharing between cogs? If so... the fact that it ALMOST works has been throwing me off.
I am NOT using:
COGINIT #%1_1_0001,addr ‘start a pair of free cogs (lookup RAM sharing)
because I know cogs 2 and 3 are free and I can't figure out how to get my “onemove” function running in one cog and “mset” running in the other without starting them individually.
I realize this COULD be my problem. If so... how do I start two cogs with the COGINIT #%1_1_0001, function then get two different programs running in those “Matched” cogs?