I think Joe nailed it, but check the datasheet for the value to disable comparators. I think
it should be CMCON0 = 7 on the 16F688.
Pins configured as analog inputs will be read as 0 when used for digital I/O.
The HIGH / LOW commands use BSF and BCF read-modify-write assembly language
instructions. This causes the whole port to be read, the port pin to be modified, then the
whole port is writen back to each time it lands on a HIGH LOW instruction.
Example:
high LineLockOut ' reads whole port, sets C.1, writes whole port back.
high ClutchOut ' reads whole port, (C.1 is read back as 0), sets C.0, writes it back.
high Aux1Out ' reads whole port, (C.0 is read back as 0), sets C.2, writes it back.
If pins are set to analog inputs, then it reads each pin value back as 0, then writes it back
as a 0 on the next BSF operation, so you end up with only Aux1Out being set once it runs
through all three lines of code above.
The same scenario can happen with read-modify-write. Even if the pins are not configured
as analog inputs.
If it blazes through these three lines of code at a high-speed, and there's a little bit of
external capacitance on these pins, the next read-modify-write operation after changing
the first output pin - may read the pin before it has had time to change, so it writes back
the wrong value to a previous pin when it changes the next pin.
When that happens, you can fix it by inserting a short pause between each instruction that
sets or clears pins, or you can just write to the whole port at once instead of setting or
clearing individual bits one at a time.
Bookmarks