
Originally Posted by
Bruce
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 written 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.
<h1>RATS !</h1> Misread the chart CMCON0=0 comparators off ANALOG, CMCON0 = 7 comparators off DIGITAL !
THANK YOU BRUCE !
Last edited by Archangel; - 9th May 2009 at 18:55.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
Bookmarks