Read value of digital ports


Closed Thread
Results 1 to 5 of 5
  1. #1

    Default Read value of digital ports

    Does somebody know how to read the complete status of portb on a 6F870.

    So i give one command and get the status of portb.0....portb.7, like when port b.0 and b.3 are high i get the value 5

  2. #2
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    762


    Did you find this post helpful? Yes | No

    Default

    Code:
    Value VAR BYTE
    Value=PortB
    regards

    Ralph

    _______________________________________________
    There are only 10 types of people:
    Those who understand binary, and those who don't ...
    _______________________________________________



  3. #3
    mauro66's Avatar
    mauro66 Guest


    Did you find this post helpful? Yes | No

    Default I tried B0 = PORTA, but.......

    Dear Sir,
    I tried to read from PORTA of a 16F872; on a demo, simple board it works, but on a more complex project board every time I tried to read something, the micro always read 4 or 0 (decimal). On the 8 pins of PORTA the single bits are exact.

    Do you know what's the problem ?

    Thanks,

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    PortA comes up in ANALOG mode as default. See DATASHEET, Section 10-2, ADCON1 register. Select DIGITAL mode. See associated table.

  5. #5
    mauro66's Avatar
    mauro66 Guest


    Did you find this post helpful? Yes | No

    Default My mistake

    Sorry, I made a mistake in the previous message:
    I'm working on PORTB as input, not on PORTA.
    However I've already setted the port directions, for my project, in this manner:

    Poke $9F,%00000110 ' Set PORTA as digital I/O
    ' $9F is address of ADCON1 register

    TRISA = $00 ' Set PORTA as OUTPUT
    TRISB = $FF ' Set PORTB as INPUT
    TRISC = $00 ' Set PORTC as OUTPUT

Similar Threads

  1. Cleaning up code
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd December 2009, 07:14
  2. How can I read a port's status
    By lecoind in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd October 2009, 10:54
  3. SEROUT WORD variable problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 19th April 2009, 11:20
  4. Help needed - PIC12F635- MCU does not read Ports
    By financecatalyst in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2009, 12:03
  5. Changing declared variables names on the fly
    By jessey in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th December 2006, 06:34

Members who have read this thread : 1

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