Shop OBEX P1 Docs P2 Docs Learn Events
Data from regs? (in spin) — Parallax Forums

Data from regs? (in spin)

teddypteddyp Posts: 14
edited 2010-04-16 00:42 in Propeller 1
Hey all,
I am still a noob at this prop chip, but I love the way it runs. Right now, I'm trying to get some data from a register to do something to it. So, what I'm doing is making a counter with CTRA and PHSA. I can display the value in the serial terminal by outputting it.
so, if the serial terminal is debug as used many places,
debug.str(PHSA)
Out comes the value. Say 1542 for example.
How can I get that value... 1542, put it into another variable for something like summing the PHSA's or something as simple as dividing by two? The register thing has been killing me because I keep getting confused between a few things. I have programmed in TI ASM with the 23335 and in variants of C. So, how does the code work here? I can't just grab the value and move it, such as
tempVar := PHSA I just get the address or pointer or something. If I try tempVar := long[noparse][[/noparse]PHSA] I get something else. A big 32 number. Any ideas on this? Should I be using an object like Numbers to convert to a number first or something? Thanks in advance.

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2010-04-15 23:46
    teddyp said...
    I can't just grab the value and move it, such as tempVar := PHSA I just get the address or pointer or something.
    Of course that will work. At SPIN level phsa works (nearly) like any other variable, i.e. simple assignments like the one above just work.

    Have a look in the datasheet, SPIN language summary table. You'll find a tick next to phsx meaning that it returns its value when used in an assignment. And there is always trial and error [noparse]:)[/noparse]
  • teddypteddyp Posts: 14
    edited 2010-04-16 00:42
    Holy cow! thanks. It was actually my fault. I was assigning it's value to a variable, printing out the variable and then a few lines later printing out PHSA. When I looked, the two values were significantly different from each other. Simply because PHSA kept counting while I was doing other things! I feel kinda stupid now, but thats how you learn... I think.
    Thanks for your help again.
Sign In or Register to comment.