Shop OBEX P1 Docs P2 Docs Learn Events
can I name I/O pins ? — Parallax Forums

can I name I/O pins ?

Don PomplunDon Pomplun Posts: 116
edited 2007-01-25 04:51 in Propeller 1
I have ina[noparse][[/noparse]15] connected to the data-valid pin of an external chip. My code would be more readable if I could say
repeat until DV==1
rather than
repeat until ina[noparse][[/noparse]15] == 1

I tried defining a Constant DV = ina[noparse][[/noparse]15]
but it won't take. Is there a way to do this?

How about naming a range of I/O pins like
Touchtone = ina[noparse][[/noparse]14..11] ?

TIA
-- Don

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2007-01-25 04:51
    You can use an ordinary constant declaration for the number of the pin like "CON myPin = 15". You can then use the name within an INA/OUTA/DIRA like "ina[noparse][[/noparse]myPin]. You can't name a range, but you can name the ends of the range like "CON myOther = 4" and use both names like "ina[noparse][[/noparse]myOther..myPin]". You can also use the constant names to generate a bit mask like "|<myPin" for use with a WAITPNE/WAITPEQ statement. It's not quite the same thing as the PIN declaration in PBASIC, but it's quite powerful.
Sign In or Register to comment.