Data from regs? (in spin)
teddyp
Posts: 14
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.
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
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]
Thanks for your help again.