Shop OBEX P1 Docs P2 Docs Learn Events
Accessing a spin variable from PASM — Parallax Forums

Accessing a spin variable from PASM

kwinnkwinn Posts: 8,697
edited 2009-07-03 06:11 in Propeller 1
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.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-03 05:23
    You've got the RDLONG and WRLONG wrong. The following is correct:

    RDLONG <cog destination>,<hub source address>

    WRLONG <cog source>,<hub destination address>
  • kwinnkwinn Posts: 8,697
    edited 2009-07-03 05:50
    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.
  • kwinnkwinn Posts: 8,697
    edited 2009-07-03 06:11
    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?
Sign In or Register to comment.