Hi All,
I need to set 2 bits of a port while also leaving the remaining 6 bits of the same port as Tri-state (set as inputs?)
Is there a preferred way to do this? and in what order?
I was first going to write a byte to the port, then set the port to input but i'm sure that erases my outputs that i just set to 1's or 0's.
While i can set the port as input (let dirsB = %00000000) should i then use "let pinsB = 00000011" to set just 2 bits on? or will this now force all the bits as outputs now?
My next thought was to FIRST make the port set as an input (all 8 bits), THEN individually 'set' any 2 (or more) bits to 1 or 0 as needed.
The 2 (or more) bits i need to set could be ANY of the 8 bits available.
I assume using 'set' is the best way to achieve this?
I feel that trying to 'and' the port with a number to isolate certain bits to be affected may over complicate the whole process.....maybe this is harder? easier?
Sorry, i can't try this myself, i'm moving house and my workshop/parts are packed in boxes. I only have a few chips at work to tinker with, so i now need to build a test jig to put some code together and try it out.
Anyone?
Thank in advance,
Marty.
I need to set 2 bits of a port while also leaving the remaining 6 bits of the same port as Tri-state (set as inputs?)
Is there a preferred way to do this? and in what order?
I was first going to write a byte to the port, then set the port to input but i'm sure that erases my outputs that i just set to 1's or 0's.
While i can set the port as input (let dirsB = %00000000) should i then use "let pinsB = 00000011" to set just 2 bits on? or will this now force all the bits as outputs now?
My next thought was to FIRST make the port set as an input (all 8 bits), THEN individually 'set' any 2 (or more) bits to 1 or 0 as needed.
The 2 (or more) bits i need to set could be ANY of the 8 bits available.
I assume using 'set' is the best way to achieve this?
I feel that trying to 'and' the port with a number to isolate certain bits to be affected may over complicate the whole process.....maybe this is harder? easier?
Sorry, i can't try this myself, i'm moving house and my workshop/parts are packed in boxes. I only have a few chips at work to tinker with, so i now need to build a test jig to put some code together and try it out.
Anyone?
Thank in advance,
Marty.
Last edited: