Testing PortB pin


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    34

    Question Testing PortB pin

    Hi there,

    I'm struggling a bit with testing the status of PortB pin of a Pic16F876A.
    I want to be able to read the state of one of the pins of PORTB based upon a variable.
    -----------------------------------
    DEFINE LOADER_USED 1
    DEFINE OSC 10

    Green var PORTA.0 ' Led 2
    Data_1 var byte

    ADCON1=$07
    TRISB=%00000000

    Init:
    high green
    pause 2000
    low green

    data_1 = 5

    test:
    if PortB.0(data_1) = 0 then
    --> LCD should show "Low"
    else
    --> LCD should show "high
    endif
    pause 2000
    goto test
    ------------------------------
    When I use 'Data_1' as a variable with PortB it doesn't seem to work.
    Is there a solution or workaround for this?
    Data_1 can be from 0 to 7.

    Thanks

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    TRISB = %00000000 sets portb as outputs. Try TRISB = $FF and see how it
    responds.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  3. #3
    Join Date
    Apr 2004
    Posts
    34


    Did you find this post helpful? Yes | No

    Default

    Bruce,

    Thanks got it sorted out.
    Appologies for the late reply

Similar Threads

  1. PICs can do more if use others than delays instructions
    By hardcore in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 24th February 2010, 19:52
  2. shifting problem
    By helmut in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 31st August 2007, 06:11
  3. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  4. Another RTC, DS1287
    By DavidK in forum Code Examples
    Replies: 0
    Last Post: - 12th December 2006, 17:07
  5. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10

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