Shop OBEX P1 Docs P2 Docs Learn Events
Put data in array from another cog in asm — Parallax Forums

Put data in array from another cog in asm

RubberduckRubberduck Posts: 11
edited 2007-12-10 19:59 in Propeller 1
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

Comments

  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-08 17:04
    The principle is easy:
    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
  • RubberduckRubberduck Posts: 11
    edited 2007-12-08 18:51
    Thx Nick for your reply

    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
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-08 21:22
    Don't know wether an ORG not followed by 0 works?
    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

  • AribaAriba Posts: 2,685
    edited 2007-12-08 22:39
    Rubberduck:

    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:
    writemem
                  rdlong    addr, buf1ptr   '<-- get value from buf1  
                  mov       temp,#12
                  wrlong    temp,addr       '<-- write in Array
                  mov temp,#0
                  wrlong temp,comptr
                  jmp #writemem 
    
    



    With this changes it should work...

    Andy
  • RubberduckRubberduck Posts: 11
    edited 2007-12-09 18:27
    thx Nick and 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
  • Nick MuellerNick Mueller Posts: 815
    edited 2007-12-09 18:41
    > Nick: Is "cognew(@cogcode, @paramArray)" just to make it more readable and easier to understand? If it is then I understand, ...

    D. Knuth, "Literate Programming" smile.gif
    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. smile.gif

    Nick

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Never use force, just go for a bigger hammer!

    The DIY Digital-Readout for mills, lathes etc.:
    YADRO
  • RubberduckRubberduck Posts: 11
    edited 2007-12-10 19:59
    Okej, thx for clearing that out, nick

    /andreas
Sign In or Register to comment.