Shop OBEX P1 Docs P2 Docs Learn Events
How can I pass a PIN # to a Subroutine? - Possible? — Parallax Forums

How can I pass a PIN # to a Subroutine? - Possible?

T&E EngineerT&E Engineer Posts: 1,396
edited 2008-07-16 02:01 in General Discussion
I have a Subroutine like this:

SUB send_data1
  chunk = ~chunk
  SHIFTOUT RB.2,RB.0,1,chunk,100
  ENDSUB

However, I want to be able to pass a different PIN to the SHIFTOUT statement like this:
 
 
send_data1   SUB   1
 
ClrPos  VAR   Bit
tmpB1   VAR   Bit
 
ClrPos =  RB.2
 
SUB send_data1 ClrPos
  tmpB1 = __PARAM1
  chunk = ~chunk
  SHIFTOUT tmpB1,RB.0,1,chunk,100
  ENDSUB

But·this only works for Bits(??), Bytes, Words, etc.. not PINs.

I get an error: BIT IS NOT A HARDWARE PIN "tmpB1"



Currently I have 4 different PINs that I might send to the subroutine and have to use IF THEN ELSE statements to 4 different Subroutines. I want to reduce this to 1 subroutine if I can find a way to Pass a PIN.

Is this possible (or possibly in a Beta SX/B version)?

Comments

  • JonnyMacJonnyMac Posts: 9,216
    edited 2008-07-06 16:05
    No, this is not possible. You'll have to create a specialty routine that accepts that pin number, converts it to a mask for the desired pin, then does the process you desire. If you search the forums I've demo'd code for things like HIGH, LOW and PULSOUT using this strategy. It will be more complicated with SHIFTOUT, but it can be done.
  • John CoutureJohn Couture Posts: 370
    edited 2008-07-16 02:01
    The post Jon was referring to is here:

    http://forums.parallax.com/forums/default.aspx?f=7&m=263425

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John J. Couture

    San Diego Miramar College
Sign In or Register to comment.