Reassigning I/O within the program ?


Results 1 to 18 of 18

Threaded View

  1. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    You could use PIN numbers instead of PORT.bit.


    Code:
    InputSelect  VAR PORTB.0
    myPIN        VAR BYTE
    
    Test:
        IF InputSelect = 1 THEN
            myPIN = 1            ; PORTB.1 selected
        ELSE
            myPIN = 2            ; PORTB.2 selected
        ENDIF
    
        HIGH myPIN
        PAUSE 500
        LOW myPIN
        PAUSE 500
    GOTO Test
    Or, a similar version.
    The Inputselect will always read 0 or 1. Add 1 to it to make 1 or 2, for PORTB.1 and PORTB.2.
    Code:
    InputSelect  VAR PORTB.0
    myPIN        VAR BYTE
    
    Test:
        myPIN = InputSelect + 1
    
        HIGH myPIN
        PAUSE 500
        LOW myPIN
        PAUSE 500
    GOTO Test
    The ports used depends on the chip you are using.
    Check the .bas file for the PIC you are using in the PBP folder. (ex. 16F877a.bas)

    PORTL and TRISL determine which PORT that pin numbers 0-7 go to.
    PORTH and TRISH determine which PORT that pin numbers 8-15 go to.
    <br><br>
    Last edited by Darrel Taylor; - 6th June 2010 at 01:23. Reason: Forgot PIN was a reserved word, changed to myPIN
    DT

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts