Shop OBEX P1 Docs P2 Docs Learn Events
SXB IO PIN declaration question. — Parallax Forums

SXB IO PIN declaration question.

Clock LoopClock Loop Posts: 2,069
edited 2006-05-28 04:04 in General Discussion
How can I do this when declaring IO PINS.

' -------------------------------------------------------------------------
' IO Pins

Read.0        var    RA.2    
Chrg.0        var    RA.3

Read.1        var    RB.0    
Chrg.1        var    RB.1

Read.2        var    RB.2    
Chrg.2        var    RB.3




Basically I am trying to assign the IO pin RA.2 to bit .0 in the byte READ.. and so on.

I can't complile like this. Is there a way I CAN do this?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Meh. Nothing here, move along.

Comments

  • BeanBean Posts: 8,129
    edited 2006-05-28 00:45
    What you are trying to do cannot be done. Your trying to alias a bit variable to a different bit position. You need code to do that.
    Also "READ" is a reserved word.

    I would recommend you make your connection in the order you want the bits to be in. Then you can just alias the whole port.

    ReadBack VAR RA
    Chrg VAR RB

    Bean

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com


    COMING SOON "SD DATA LOGGER" www.sddatalogger.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
  • Clock LoopClock Loop Posts: 2,069
    edited 2006-05-28 01:06
    Bean (Hitt Consulting) said...
    What you are trying to do cannot be done. Your trying to alias a bit variable to a different bit position. You need code to do that.
    Also "READ" is a reserved word.

    I would recommend you make your connection in the order you want the bits to be in. Then you can just alias the whole port.

    ReadBack VAR RA
    Chrg VAR RB

    Bean

    Oops on the read reserved word. I just made that one up here as an example..

    So your saying if I do, something like

    ReadBack VAR RA
    Chrg VAR RB

    I can then referr to the bits I want later...

    I.E. ReadBack.0, ReadBack.1 = RA.0, RA.1

    And Chrg.0, and Chrg.1 = RB.0, RB.1

    My whole goal of doing this was to be able to set one bit of ReadBack,,, and then referr to all bits in ReadBack as a whole.
    I didn't want to use elaborate code to combine different ports into one byte..

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Meh. Nothing here, move along.
  • BeanBean Posts: 8,129
    edited 2006-05-28 04:04
    Right, ReadBack.0 would be an alias for RA.0 and so on...

    Keep in mind that you are NOT creating a copy of the RA port. When you use ReadBack you ARE accessing the RA port. It's an alias not a copy.

    You can also then alias the individual bits as in...

    ReadBack VAR RA

    VoltageHigh VAR ReadBack.0
    VoltageLow VAR ReadBack.1

    If VoltageHigh = 1 THEN

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Cheap 4-digit LED display with driver IC·www.hc4led.com


    COMING SOON "SD DATA LOGGER" www.sddatalogger.com

    "I reject your reality, and substitute my own." Mythbusters
    ·
Sign In or Register to comment.