PortA as Inputs in PIC16F628A program
I'm working on the following simple piece of code that serouts the states (high or low) of its PortA and PortB pins. Right now it's successfully sending the PortB states but I'm not getting accurate PortA states. Please tell me what I'm doing wrong and feel free to comment if you think there's a better way to do this.
Thanks
SYMBOL PortA = 5
SYMBOL TrisA = $85
SYMBOL PortB = 6
SYMBOL TrisB = $86
SYMBOL CmCom = $1F
SYMBOL Ready = 2
SYMBOL Load = 1
SYMBOL Xmit = 3
POKE TrisA,%11111111 'only using PORTA.0-PORTA.3 in real application
POKE TrisB,%11110101
POKE CmCom,%00000111
Main:
IF Pin2 = 1 THEN Transmit
GOTO Main
Transmit:
HIGH Load
PEEK PortB,B0
PEEK PortA,B1
LOW Load
SEROUT Xmit, N9600, ("A","B",B0,B1) '"A" and "B" are qualifiers
GOTO Main
'End of Program
Turn off the comparators on PORTA
Hi,
Your chip has an onboard voltage comparator. You can turn this off by inserting:
CMCON = 7
This may solve your problem.
Regards
Sougata