Lots of ways to do this, here’s one:
If the pins are two adjacent pins of a port (for example portA.2 and porta.3) then you could use a bit mask and then shift the bit to the right as needed. So, using A.2 and A.3 it would be:
This will give you a value of MODE from 0-3.Code:MODEval= PortA & %00001100 MODEval = MODEval >> 2
Also, you would even skip the shift and just use the CASE to check for values of 4, 8, and 12.
And, if the pins are not consecutive, you can still use a bit mask and then check the values:
HTH,Code:MODEval = PortA & %10001000 SELECT CASE MODEval CASE 8 Statement... CASE 128 Statement... CASE 136 Statement... {CASE ELSE Statement...} END SELECT
SteveB




Bookmarks