Port Variables act like Constants


Closed Thread
Results 1 to 5 of 5

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Port Variables act like Constants

    Look in the .bas file for the chip you are using.
    If it's a 16F877A then open c:\pbp\16f877a.bas

    The PORTL and PORTH aliases are used for the PIN numbers (0-15)
    PORTL is 0-7 and PORTH is 8-15.
    Code:
    PORTL   VAR     PORTB
    PORTH   VAR     PORTC
    TRISL   VAR     TRISB
    TRISH   VAR     TRISC
    If PORTH is aliased to PORTC then you don't need to do anything.
    If it's not, change it to PORTC, and change TRISH to alias TRISC.

    Then you can use the PIN numbers to access the pins with a variable.
    Code:
        If DS1=1 then
    	ComVar=14   ; PORTC.6
    	Else
    	ComVar=13   ; PORTC.5
        EndIF
    
        Serout2 ComVar, 84, [“  Com is PIN - ”, DEC ComVar,13,10]
    DT

  2. #2
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    232


    Did you find this post helpful? Yes | No

    Default Re: Port Variables act like Constants

    Darrel,
    Thanks again, you make it look so easy! After two days of working with this I now know I was searching for the wrong topics. I haven’t found anything about the .bas file in the manual. I think this subject deserves a WiKi along side your other documents.

    By the way, to those who had a hand in creating the Wiki and those who maintain it, ITS GREAT!

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