View Full Version : Accessing a spin variable from PASM

07-03-2009, 12:12 PM
HELP!!!! I am trying to access a variable in a spin program (BoomBoxController) from a PASM program (ElapsedTimer) running in another cog. I thought it would be as simple as passing the address pointer, but that does not seem to work. I have gone through the manual and several objects and tried everything suggested with no luck. You can ignore the I/O on the pins in ElapsedTimer. That was added to make sure a cog was actually started and that it ran (it did).

Probably some minor thing I missed, so I am looking forward to one of those duh!! moments.

Any help is appreciated.

Mike Green
07-03-2009, 12:23 PM
You've got the RDLONG and WRLONG wrong. The following is correct:

RDLONG <cog destination>,<hub source address>

WRLONG <cog source>,<hub destination address>

07-03-2009, 12:50 PM
loop waitcnt target, delta
rdlong _time_loc, e_t ' read time value from hub to _time_loc
add _time_loc, #1 ' increment the time
wrlong e_t, _time_loc ' write back new time value
'************************************************* ************************************************** ********************
_time_loc long 0 ' pointer to elapsed time long in hub memory
delta long 0 ' time delay in clocks to increment target time by
'delta2 long 0 ' time delay2 in clocks to increment target time by
e_t long 0 ' temporary storage for time count in hub ram
pins long %11000000 ' select pins 7 and 8
target long 1 ' value for waitcnt instruction to wait for

Are you sure? I have the above code and longs in the cog and I think it is correct.

Never mind, I see what you mean.

07-03-2009, 01:11 PM
Thank you very much Mike. I wasted a lot of time hunting for what was basically a naming mistake. I must have looked at that code at least a hundred times and never noticed. I really need to find a better naming method for those types of variables. Any suggestions?