PASM to spin
UltraLazer
Posts: 30
Is there a good way to send a long from a PASM cog back to a spin cog.
I am using a
to lunch my PASM cog so par is pointing at the beginning of a
in DAT...
I have a changing variable (long) in my PASM that I want to
to update the value in hub ram 1 x per loop of the pasm.
should I reserve space in DAT for the value to be shared? or declare it in spin?
can I "reuse" the par register later in the pasm, now that the cog has been initialized to the sequence?
I am using a
COGINIT (SEQ_cog,@Step000,@SEQ)
to lunch my PASM cog so par is pointing at the beginning of a
SEQ long 0,0,0,0,0,0....
in DAT...
I have a changing variable (long) in my PASM that I want to
wrlong
to update the value in hub ram 1 x per loop of the pasm.
should I reserve space in DAT for the value to be shared? or declare it in spin?
can I "reuse" the par register later in the pasm, now that the cog has been initialized to the sequence?
Comments
par will just stay as par I am not sure what you mean by resuse
Let's say you have three longs; you really should put them into contiguous locations and then pass the address of the first with coginit. In your PASM code you can start off like this:
This a simple way to handle it; there are some crafty programmer here that have come up with other solutions that are very clever -- I tend to stick with simple (keeps my brain from melting).
I am actually experimenting with Ray Tracy's, Mother of all LED sequencers (M.O.A.L.S.?)(http://obex.parallax.com/objects/240/)
I have a spin cog that reads a sequence from an eeprom, writes it to some predefined long array space called "SEQ" in DAT and launches the M.O.A.L.S. SEQ_Cog.
This works well, and looks Something like this:
I am hoping to get the M.O.A.L.S. to update a long in hub ram with its current element as it chunks through the SEQ data.
the par I was referring to is the one already used in the sequencer to set the data patterns adress. I was wondering if I have to reference the address of the shared SEQ data in order to write a long to the hub? my head hurts.
Your top-level code would write the address (@) of the data table to seqstart before calling coginit:
The MOAS code needs to capture the value par and add four to it to know the address of seqstep -- this is the address you will write back to that tells the top level code what step MOAS is presently running. Make sense? I would do something like this at the top of MOAS:
Remember... you can only pass one parameter when using coginit with an assembly cog. This is why the order of your variables is important; the cog needs to match the spin code that launches it. Now that know where the step address is held in the hub you can write the step back with wrlong (to steppntr).
Post Edited (JonnyMac) : 12/5/2009 9:52:52 PM GMT
The first 3 values (0,1,2) in the SEQ data are required for reps, timing and # of elements. Is this an issue with the suggested fix?
{ Step010 setup the first sequence }
:Step010
mov P0,par ' Get data patterns starting address
needs to be changed to
{ Step010 setup the first sequence }
:Step010
rdlong P0,startpntr ' Get data patterns starting address
Ehmmm ... and currently the sequencer does not wait. My expectation is that this will be changed, as you want to see the sequence?! But·at the moment·your SPIN code will miss a lot of data.
Post Edited (MagIO2) : 12/5/2009 11:48:20 PM GMT