Shop OBEX P1 Docs P2 Docs Learn Events
PropBASIC - How to read pin array? — Parallax Forums

PropBASIC - How to read pin array?

simonlsimonl Posts: 866
edited 2012-09-26 04:43 in Propeller 1
Hi,

I'm trying to read an array of pins in PropBASIC, but the following results in me seeing 17 (the number of the final pin in the pin array)
DEVICE  P8X32A, XTAL1, PLL16X
XIN  5_000_000

src_addr PIN 19..14 INPUT

PROGRAM Start

Start:
  LOAD "C:\PropBASIC_Lib\vpterminal.lib" 
  
  vp_dec src_addr
  vp_char 13
  
  GOTO Start
END

I was expecting to see 2, as I have pin 19 high and the others low.

Anyone know how I should be doing this?

Comments

  • simonlsimonl Posts: 866
    edited 2012-09-25 15:27
    Got it!
    DEVICE  P8X32A, XTAL1, PLL16X
    XIN  5_000_000
    
    src_addr PIN 19..17 INPUT
    
    addr VAR LONG
    
    PROGRAM Start
    
    Start:
      LOAD "C:\PropBASIC_Lib\vpterminal.lib" 
      
      addr = src_addr                          ' Need this step to get value of src_addr pins (weird, but it works!)
      
      vp_dec addr
      vp_char 13
      
      GOTO Start
    END
    
  • BeanBean Posts: 8,129
    edited 2012-09-26 04:43
    Simon,
    PIN variables get passed to subroutines as their pin number. This allows you to write common subroutines that work with different pins.

    You have the correct solution shown in your second post.

    BTW: If you want to use a PIN number in your code (instead of the value ON the pins) you can use #pinname also @pinname will give the bitmask for the pin(s).

    Bean
Sign In or Register to comment.