I used a Real Ice system to set one PIC18F14K22 to continuously transmit an 'A' at 1 second intervals. This worked as I can capture the character on my scope. The problem arises when trying to receive this on the second PIC. Both use the same baud rate code and are running at 5V with a common earth. My code is:
;Receive byte at 1200 baud
CLRF SPBRGH
MOVLW D'51'
MOVWF SPBRG ;Baud=1200, 4MHz crystal
BCF TXSTA,BRGH
BCF BAUDCON,BRG16
BCF TXSTA,SYNC
;now have SYNC=0, BRGH=0,BRG16=0
BSF RCSTA,SPEN ;enable serial port
BSF TRISB,RX ;make RX pin an input
BCF RCSTA,CREN
BSF RCSTA,CREN ;enable reception
Loop1
BTFSS PIR1,RCIF ;poll RCIF for high
BRA Loop1
MOVF RCREG,W
NOP
END
I took the PIC that was transmitting the 'A' character and connected it to a Maximite which uses a PIC32MX170 which has a Basic interpreter on board. This received the 'A' . This convinces me that the problem is at the receiving end.
What am I doing wrong when trying to receive a character?
;Receive byte at 1200 baud
CLRF SPBRGH
MOVLW D'51'
MOVWF SPBRG ;Baud=1200, 4MHz crystal
BCF TXSTA,BRGH
BCF BAUDCON,BRG16
BCF TXSTA,SYNC
;now have SYNC=0, BRGH=0,BRG16=0
BSF RCSTA,SPEN ;enable serial port
BSF TRISB,RX ;make RX pin an input
BCF RCSTA,CREN
BSF RCSTA,CREN ;enable reception
Loop1
BTFSS PIR1,RCIF ;poll RCIF for high
BRA Loop1
MOVF RCREG,W
NOP
END
I took the PIC that was transmitting the 'A' character and connected it to a Maximite which uses a PIC32MX170 which has a Basic interpreter on board. This received the 'A' . This convinces me that the problem is at the receiving end.
What am I doing wrong when trying to receive a character?