Put data in array from another cog in asm
Rubberduck
Posts: 11
Hi I hope someone can help me with my little problem. Despite a lot of reading on the forum and checking other's code I can't figure out why this doesn't work.
This is just the very basic of the code. When I get it to work I want to read data from an ADC in one cog. Continusly fill a buffer with data from the "ADC-cog" in another·cog and finally put the data on a SD card with a 3:rd cog.·I want to make this application very fast.
Hope I make sense.
My main problem is that I cant fill an array with data.
Thx in advance
Andreas
This is just the very basic of the code. When I get it to work I want to read data from an ADC in one cog. Continusly fill a buffer with data from the "ADC-cog" in another·cog and finally put the data on a SD card with a 3:rd cog.·I want to make this application very fast.
Hope I make sense.
My main problem is that I cant fill an array with data.
Thx in advance
Andreas
Comments
The ADC-cog reads data and writes (wrlong) it to the HUB-Ram. Other cogs can fetch the data (rdlong) from there and process it like they want.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
Yes,I understand the theory of operation but cant get'it to work. I only get zero's when I check the result from the asm-cog. It's seems like the addresses isn't correctly maped, cuz when I write to the array I get very weired result - like in the files attached in the first message·- there I have a debug term on VGA but it doesn't work when I write to the array.
I running out of ideas to try out·- I·think·that·it's a very small thing but I can't see what the problem is.
/Andreas
I also would pass the 2 pointers for the ASM in an array. Like cognew(@cogcode, @paramArray) and paramArray[noparse][[/noparse]0]:= @something paramArray:= @ somethingElse
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
In Main.spin display buffer1[noparse][[/noparse] 0 ] and buffer1[noparse][[/noparse] 1 ] (not 1 and 2), the value 12 from Child.spin will be written in Index 0.
And the Child.spin have some bugs:
- In WriteMemory: fill the buf1 before the command, else the Assembly cog starts the command before the parameter is written from Spin.
- The writemem loop in the ASM code needs to read the value from buf1 and use this as address:
With this changes it should work...
Andy
This solved the problem.
Nick: Is "cognew(@cogcode, @paramArray)" just to make it more readable and easier to understand?·If it is then I understand, if not the please explane to a newbe.
Thanks again
/Andreas
D. Knuth, "Literate Programming"
Write what you intend and don't relay on things that you assume. In this case, you assumed that two vars that you have declared in a sequence are actually in memory in the same sequence. A bad assuption!
AFAIK, SPIN rearranges them (sorted by type)
Or you'll notice that as soon as you move one around in an absent moment.
So it is "only" good coding style.
Nick
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Never use force, just go for a bigger hammer!
The DIY Digital-Readout for mills, lathes etc.:
YADRO
/andreas