PDA

View Full Version : Ports to In and Out at same time



Peter1960
- 25th November 2007, 03:17
Hi,
I looked at the bitwise functions, and the examples given in

http://www.picbasic.co.uk/forum/showthread.php?t=2783&highlight=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

Archangel
- 25th November 2007, 06:44
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

mister_e
- 25th November 2007, 08:34
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.