Proper syntax for INA command in C
brantleyra
Posts: 4
I'm trying to access a single pin's state with the INA command using C. The Imagecraft compiler software has almost no examples of the correct format of this or any of the other supported propellor commands. I would appreciate any help I can get with the correct syntax as trial and error is time consuming.
Comments
Below is Catalina's "wrapper" file that hides the difference between Catalina and ICC - in it you will find examples of the ICC syntax for all the Parallax special functions (as well as the equivalent Catalina syntax).
However, please note that while these should compile, and I believe the syntax is therefore correct, I have not done ANY actual testing with ICC.
If you find any problems, I'd appreciate it if you'd let me know.
Ross.
Ooops, you're right. Try this:
long value = INA;
BTW, several drivers are ported for ICC. They can be found at:
http://obex.parallax.com/objects/search/?q=ICC&csrfmiddlewaretoken=d9ed9ece14ac88d521ef456555f4ddae
Hopefully those examples, the examples ICC includes, and the ImageCraft on-line help will get you answers you need. I ported several examples because ICC was the first "native Propeller" C tool-chain. I'm not affiliated with ImageCraft in anyway other than having produced code.
Temp := INA[16]
Reads I/O pin 16 and stores its state (0 or 1) in the lowest bit of Temp; all other bits of Temp are cleared.
As I plan to read serveral pins at different times I didn't want to have to set-up a bit mask for each pin or a whole subroutine that strips out the pin.
temp = INA & 0x80;
will read the 15th bit (pin 16) of the register.
This looks like it will solve my problem. Simple and short.
I guess you left out some 0's. It should be "temp = INA & 0x8000;"
Spin is good about using array notation for pins if you're used to it.
A simple C function to read one pin "by number" would be:
Good luck on your C journey.