The following may correct any R-W-M mismatch condition, but it is a little risky to write to the output latch (even if not an output) when it maybe directly connected to +5V (through the SW):Would an initial read to the port, before the actual loop, do the same?Code:PortA = 0 PortB = 0
The RBPU should be disabled by default (unless PBP assigns it behind the scenes).
For these reasons I would have the port connected to +5V through a 10k resistor; and the switch would connect the port to GND (may be through 1k for protection).
The following post may give some ideas (not identical, but helps illustrate): http://www.picbasic.co.uk/forum/show...t=weak+pull-up
Bookmarks