Ports to In and Out at same time


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2005
    Posts
    67

    Smile Ports to In and Out at same time

    Hi,
    I looked at the bitwise functions, and the examples given in

    http://www.picbasic.co.uk/forum/show...hlight=masking

    Say you want PortB.0 as Input and Rest as Outputs
    Assuming you set
    TRISB = &10000000 '

    then

    PortB = PortBnewdata & $FE ' Will this only change the values on bits 1 to 7
    ' and leave the value of the input on bit 0 the same
    ' ie as an input ?

    kind regards

    Peter
    Pete

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Peter1960 View Post
    Say you want PortB.0 as Input and Rest as Outputs
    Assuming you set
    TRISB = &10000000 ' . . . .
    Switch 'er around Peter
    TRISB = %00000001 sets PortB.0 as input
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    PortB = PortBnewdata & $FE ' Will this only change the values on bits 1 to 7
    This will leave all <7:1> as is BUT it will clear bit0

    Assuming PortBnedata=$FF - AND with $FE give... $FE

    If you want set set a bit, you'll need to use -OR-

    Portb = PortBnewdata | $1

    You can use windows calc in scientific mode if you want. From the link you have posted, looked at the one i've posted about boolean operations/theory.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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