Hot!Old issue, New question, pullups

Author
mountain747
New Member
  • Total Posts : 24
  • Reward points : 0
  • Joined: 2004/11/26 19:35:22
  • Status: offline
2018/03/03 09:42:51 (permalink)
0

Old issue, New question, pullups

I need a BUSY Status line on my RS485 comm.  Using a 16f886 I have RB1 available for use.  Because of distance from Master to Slave I think I need a pullup resistor on my BUSY line.  I thought I knew how this should work but I am mistaken.  
ANSEL =0
ANSELH=0
PORTB=0
TRISB=0
10k pullup to 5v
My intent was to go from high to low on the BUSY line by  the Toggling TRISB.1 from 0 to 1.  However With TRISB.1=1, RB1 is high and with TRISB.1=0, RB1 is pulling the line low. 
My understanding was that with TRISB an Output, RB1=0 would NOT be able to sink.  But that is exactly what is happening.
 
Can someone explain this to me?
Thanks  
#1

6 Replies Related Threads

    JorgeF
    Super Member
    • Total Posts : 3287
    • Reward points : 0
    • Joined: 2011/07/09 11:56:58
    • Location: PT/EU @ Third rock from the Sun
    • Status: offline
    Re: Old issue, New question, pullups 2018/03/03 11:36:39 (permalink)
    0
    Hi
     
    Whenever you set TRISB.1 = 0, you make the pin an output.
    It will sink  (0) or source current (1) depending on the state of PORTB.1
     
    OTOH if you make it an input with TRISB.1 = 1, the pin will have an high impedance state not sinking or sourcing any current.
     
     
    HIH
     
    Best reagrds
    Jorge
     
    #2
    mountain747
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2004/11/26 19:35:22
    • Status: offline
    Re: Old issue, New question, pullups 2018/03/03 13:09:57 (permalink)
    0
    Jorge, Now I understand, "TRISB.1 = 1......NOT sinking or sourcing any current", that was the key.
    The datasheets would be more understandable if they made the case in such simple terms.
    Thank you, Thank you
     
    #3
    qɥb
    Monolothic Member
    • Total Posts : 3329
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: Old issue, New question, pullups 2018/03/03 14:02:01 (permalink)
    0
    If you read the datasheet without preconceptions, they are very clear on how TRISB and PORTB work.
    A "0" in TRISB makes the pin an output, a "1" makes it an input,
    so if you are trying to toggle a pin high and low, make it an output, and just twiddle the PORTB bit (or LATB if your PIC had one, which a PIC16F886 does not. One more reason to NOT use those ancient PICs)
     
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #4
    jack@kksound
    code tags!
    • Total Posts : 2762
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Old issue, New question, pullups 2018/03/05 09:50:35 (permalink)
    0
    I am wondering if the OP is confusing this with the idea of using the TRISbit to simulate an open drain output:
    PORTBbits.RB1 = 0;
    TRISBbits.RB1 = 0; output is LOW
    TRISBbits.RB1 = 1; output is open drain - pulled up by extenral resistor
    ???
    #5
    musictom
    New Member
    • Total Posts : 8
    • Reward points : 0
    • Joined: 2013/01/25 10:29:03
    • Location: 0
    • Status: offline
    Re: Old issue, New question, pullups 2018/03/05 14:15:35 (permalink)
    0
    Hello!
    You can imagine the PIC I/O states, with attached (very simplified) illustration.
    So practically these three states are.
    (The 10Mega ohm resistor is only symbolic, but something of a similar magnitude is to be imagined).

    Attached Image(s)

    #6
    mountain747
    New Member
    • Total Posts : 24
    • Reward points : 0
    • Joined: 2004/11/26 19:35:22
    • Status: offline
    Re: Old issue, New question, pullups 2018/03/08 08:52:20 (permalink)
    0
    Thank you all for your excellent comments.  My difficulty was understanding how to read Board A PortB.1 and Board B PortB.1 if one board is in TRISB=0 and the other board in TRISB=1.  Until i tried it i did not understand you can't read a port in output TRISB state.  (pretty dumb now that I look on it hindsight)  I got it all figured out now.  all boards in TRISB.1=1, any board can read status of BUSY line.
    After Read and line is high (no comm) one board goes TRISB.1=0 pulls BUSY line low.  All other boards can still read status of BUSY line.  No collisions. 
    Thanks for all your input.
    #7
    Jump to:
    © 2018 APG vNext Commercial Version 4.5