Need help understanding wordmove between 2 objects / cogs
Don M
Posts: 1,652
In my main cog I have 2 258 word buffers called buf1 and buf2. My main loop toggles back and forth between each buffer as each one reaches 254 words. After each toggle I want to transfer the whole buffer contents to another objects / cogs buffer called block (also a 258 word buffer) so that another method running independent of the Main method can use that data.
Can this be done and if so do I need to index through each of the 258 words from buf1 (or buf2) or is there a "wholesale" way to send the whole buffer?
I don't have all my code put together yet so I don't really have anything substantial to show... yet.
Does anyone have any or can think of any examples I can look at?
Thanks.
Can this be done and if so do I need to index through each of the 258 words from buf1 (or buf2) or is there a "wholesale" way to send the whole buffer?
I don't have all my code put together yet so I don't really have anything substantial to show... yet.
Does anyone have any or can think of any examples I can look at?
Thanks.
Comments
If Spin then the buffers are all in hub RAM so all you need to do is pass the address - no need for another array to store it. You'd then use the word[var][index] syntax rather than buffer[index]
Mark_T's suggested method of doing this is both simpler and faster. It is essentially transferring the ownership of the 3 buffers between the main loop and the object/cog by exchanging address pointers. When the main loop has filled buf1 it passes the address of buf1 to the object "block" and receives the address of the buffer the object has finished processing (probably buf3). Much faster than moving all the data in the buffers from one to the other.
PS, Doing it this way may also let you get away with using only 2 buffers.