Shop OBEX P1 Docs P2 Docs Learn Events
communication via 2 cogs or more with PASM — Parallax Forums

communication via 2 cogs or more with PASM

robbydrobbyd Posts: 6
edited 2012-05-17 19:38 in Propeller 1
hello, im beginner and have read the
http://forums.parallax.com/showthread.php?139410-How-can-I-share-data-in-between-cogs-in-PASM/page3&highlight=pass+variable
but I don´t understand this crank things at all.

Its too much specific to me.

I want to share one variable or more defined in boot.spin to a.spin and b.spin in PASM.
a.spin should read something, calc and writeback
b.spin do the same ...

a short example:

boot.spin

var

' Shared between a and b
long sync
long data

pub start xy

sync:=101;
a.start(2,@sync)
b.start(3,@sync)
dat

the next is the a.spin and b.spin object


con
pub start(cogNumber,parameterBlock)
coginit(cogNumber,@entry,parameterBlock)

dat
org
entry
mov t1,par
rdlong sync,t1

add t1,#4
rdlong data,t1

' Stupid but only 4 a test
' counting up
loop: mov vari,data
add vari,#1
mov data,vari
jmp loop


sync long 0 '
data long 0 '
vari long 0


when I do similar , I get values passed by boot.spin one time ,
but the variable will allways the same, when reading from outside ! (maybe they change only locally but I have no debugger to see whats going )




How can I do this correct ?

Wbr

Comments

  • turbosupraturbosupra Posts: 1,088
    edited 2012-05-03 22:00
    Do you still need help with this?
  • robbydrobbyd Posts: 6
    edited 2012-05-16 03:34
    turbosupra wrote: »
    Do you still need help with this?
    Yes please, I cant see through :( I need an simple explanation how to share a memory block (in Hub Ram) between 2 or more Cogs ... Thank you in advance Robby
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-05-16 03:58
    What is passed in PAR is an addressin hub where data resides. A pasm cog can only access this data using read (rdbyte/rdword/rdlong) and writes (wrbyte/wrword/wrlong).

    So, in your example, you need to start the cog by..
    coginit(@entry,@sync)
    ... and in the cog ...
    entry rdlong csync,par
    ... add csync,#1
    ... wrlong csync,par

    csync long 0

    Note the way rdlong and wrlong dest is the data and srce is the hub pointer!!!

    Note we normally do not define which cogs are used.

    This should get you started. Then come back here with further questions. Btw, use the code tags to list code, or post the file/s in the advanced section.
  • robbydrobbyd Posts: 6
    edited 2012-05-16 04:16
    Thank You so much Cluso ! When I understand you right , my problem was , that I only change the Cog Ram Variable (long) and not the Hub Ram Variable ! I will try this and come back if my code isn´t working !
  • turbosupraturbosupra Posts: 1,088
    edited 2012-05-16 06:34
    Yes robby, that is correct.

    If you'll post a simple version of your code, I will make it so that the variables are shared so that you can see it working and then go back and figure out how it is working.
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-05-16 07:55
    If your hub needs are a bit more complex, you could use the location pointed to by PAR to address a different location than PAR itself. I plan to use the content of PAR to pass in a parameter consisting of start address and size of a circular buffer to live in the hub.
  • robbydrobbyd Posts: 6
    edited 2012-05-16 08:56
    If your hub needs are a bit more complex, you could use the location pointed to by PAR to address a different location than PAR itself. I plan to use the content of PAR to pass in a parameter consisting of start address and size of a circular buffer to live in the hub.
    like a heap in a C Program on a PC ? To put some values on the heap and call a method ?
  • frank freedmanfrank freedman Posts: 1,983
    edited 2012-05-16 09:33
    Or for pipeline processing of audio freq data through multiple effects implemented in individual cogs. zB. ADC @ 50khz dumping into a buffer low pass filter in next, high pass in next, other effects as desired, with one prop chip per channel. So, one cog for input, one for output, 6 for effects. Output either digital to cpu or analog. Gang group of these for multi-track audio capture system.
  • Cluso99Cluso99 Posts: 18,069
    edited 2012-05-17 19:38
    The video objects (tv vga) use par to pass a number of parameters to the object - one direction only. Fullduplexserial passes buffers this way too. It is the correct way to pass parameters and data back and forth.
Sign In or Register to comment.