Hi Rich, There are a couple of ways you could do this. One would be to use arrays to decode the inputs. It would probably be efficient. The second would be to use a switch-case statement. It is more versatile. If you decide to add more features, it'll come in handy. So that's what I'll do here for your Port A question, you can duplicate this for Port B and change it as necessary. void decodePortA(void) { unsigned char portashadow =3D PORTA & 0xC3; // zero out the bits we write later // If you are driving port A during interrupts, disable interrupts here switch (PORTA & 0x03) // only working with bits 0 and 1 { case 0: portashadow |=3D 0x24; // output bits 2 and 5 break; case 1: portashadow |=3D 0x08; // output bit 3 break; case 2: portashadow |=3D 0x10; // output bit 4 break; case 3: portashadow |=3D 0x20; // output bit 5 break; } PORTA =3D portashadow; // write the decoded pattern to the port // If you disabled interrupts earlier, re-enable them here } Sorry if formatting isn't great, using email editor. Using switch-case takes more steps, but it's real clear what you are doing, and you can do completely different things or additional steps for any case. Hope this helps. I haven't used XC8 but this should be portable. If I made errors, sorry, I'm sleepy :( Best regards, Bob On Sat, Sep 12, 2015, at 09:49 AM, Richard R. Pope wrote: > Hello all, > I solved this problem. Some how I managed to delete everything in=20 > the XC8 include files. I reinstalled XC8 and that fixed it. Dumb!! Now I= =20 > have another problem. The code is running and most of it works=20 > correctly. This is about as simple as it gets. I am using a series of if= =20 > and elseif statements to check for the setting of two input bits and=20 > then set four output bits. It is PortA and B and the input bits are 0=20 > and 1. The two ports control two separate devices. If the setting is 0,=20 > 0 then output bits 2 and 5 are on and bits 3 and 4 are off. If the=20 > setting is 0, 1 then bit 2, 4, and 5 are off and bit 3 is on. If the=20 > setting is 1, 0 then bits 2, 3, and 5 are off and bit 4 is on. If the=20 > setting is 1, 1 then bits 2, 3, and 4 are off and bit 5 is on. That is=20 > the way it is supposed to work. So here are three tables showing what is= =20 > supposed to happen and what is happening; > Supposed to be! The way it=20 > is! Port A The way it is! Port B > --------------------------------- ---------------------------------- = =20 > ---------------------------------- > | Input | Output | =20 > | Input | Output | | Input | Output | > | Bits | Bits | =20 > | Bits | Bits | | Bits | =20 > Bits | > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|-----|------|=20 > |-----|-----|-----|-----|-----|------| > | 1 | 0 | 2 | 3 | 4 | 6 | 5 for=20 > B | 1 | 0 | 2 | 3 | 4 | 6 | | 1 | =20 > 0 | 2 | 3 | 4 | 5 | > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|-----|------| =20 > |-----|-----|-----|-----|------|-----| > | 0 | 0 | 1 | 0 | 0 | 1 | =20 > | 0 | 0 | 1 | 0 | 0 | 1 | OK = =20 > | 0 | 0 | 1 | 0 | 0 | 1 | OK > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|------|-----| =20 > |-----|-----|-----|-----|------|-----| > | 0 | 1 | 0 | 1 | 0 | 0 | =20 > | 0 | 1 | 0 | 1 | 0 | 0 | OK=20 > | 0 | 1 | 1* | 0 | 0 | 1*| Bad* > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|------|-----| =20 > |-----|-----|-----|-----|------|-----| > | 1 | 0 | 0 | 0 | 1 | 0 | =20 > | 1 | 0 | 0 | 0 | 1* | 0 | OK* =20 > | 1 | 0 | 0 | 0 | 1 | 0 | OK > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|------|-----| =20 > |-----|-----|-----|-----|------|-----| > | 1 | 1 | 0 | 0 | 0 | 1 | =20 > | 1 | 1 | 0 | 0 | 0 | 1 | OK = =20 > | 1 | 1 | 0 | 1 | 0 | 0 | Bad > |-----|-----|-----|-----|-----|-----| =20 > |-----|-----|-----|-----|------|-----| =20 > |-----|-----|-----|-----|------|-----| --=20 http://www.fastmail.com - Access all of your messages and folders wherever you are --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .