Reading An 8 Bit Port - Easier Solution..
Posted: Tue Mar 05, 2019 4:56 pm
Hi all,
With FC 5 I am reading an 8 bit port, D0-D7 as one unmasked input...
I am trying to read basically two four bit switches and depending upon their position perform a different action where the port is split in two, D0-D3 and D4-D7...
In each of the two halves the switch readouts I am looking for are the same but priority is given to D0-D3 so if the positions are the same it acts on the first first.
You will say mask the port and read it twice then act upon it but in simulation that takes an extra read and I need it in one go.
The switches are read as the following and in each four bit half there must be a minimum of two switches set (showing zero) which is causing the hassle because the whole port will give more than two set regardless if there is one set in each half.
So I'm looking for and acting upon reading in each half but polling the WHOLE port in one go.
0011
1100
0001
0100
Obviously the binary above could have four zero's before or after it depending if it's D0-D3 or D4-D7.
I am bogged down. Is there an easy way to do this does anyone know please without the need to compare every possible combination in a IF THEN scenario?
James :-}
With FC 5 I am reading an 8 bit port, D0-D7 as one unmasked input...
I am trying to read basically two four bit switches and depending upon their position perform a different action where the port is split in two, D0-D3 and D4-D7...
In each of the two halves the switch readouts I am looking for are the same but priority is given to D0-D3 so if the positions are the same it acts on the first first.
You will say mask the port and read it twice then act upon it but in simulation that takes an extra read and I need it in one go.
The switches are read as the following and in each four bit half there must be a minimum of two switches set (showing zero) which is causing the hassle because the whole port will give more than two set regardless if there is one set in each half.
So I'm looking for and acting upon reading in each half but polling the WHOLE port in one go.
0011
1100
0001
0100
Obviously the binary above could have four zero's before or after it depending if it's D0-D3 or D4-D7.
I am bogged down. Is there an easy way to do this does anyone know please without the need to compare every possible combination in a IF THEN scenario?
James :-}