I was going to say that you need to unlock the PPS before trying to configuring it but reading the datasheet it looks like it is unlocked at POR - I've always thought it was the other way around.
Anyway, here's the relevant parts from a project of mine which uses both UARTS, in this particular case I even use the PPS peripheral to switch UART2 pins around to two different devices. Using HSEROUT / HSEROUT2 in the code it worked out fine. This is for a 67K40 so it won't match your setup but perhaps it can provide some pointers.
Code:
'----------------------------------------------------
' PPS Unlock
PPSLOCK = $55
PPSLOCK = $AA
@ BCF PPSLOCK, PPSLOCKED
RC6PPS = $0C ' We want PORTC.6 as EUSART1 TX
RX1PPS = %00010111 ' We want PORTC.7 as EUSART1 RX
RG7PPS = $0E ' We want EUSART2 TX on PortG.7
RX2PPS = %00110010 ' We want EUSART2 RX on PortG.2
' Since we're switching UART pins around during runtime we need to leave the PPS lock open.
'PPSLOCK = $55
'PPSLOCK = $AA
'@ BSF PPSLOCK, PPSLOCKED
'----------------------------------------------------
ANSELA = %00110000 ' RA4, 5 analog, rest digital
ANSELB = 0
ANSELD = 0
ANSELE = 0
ANSELF = 0
ANSELG = 0
' Setup for EUSART1
RCSTA1 = $90 ' Enable serial port & continuous receive
TXSTA1 = $24 ' Enable transmit, BRGH = 1
SPBRG1 = 64 ' 19200 Baud @ 64MHz, 0,04%
SPBRGH1 = 3
BAUDCON1.3 = 1 ' Enable 16 bit baudrate generator
' Setup for EUSART2
RCSTA2 = $90 ' Enable serial port & continuous receive
TXSTA2 = $24 ' Enable transmit, BRGH = 1
SPBRG2 = 138 ' 115200 Baud @ 64MHz, -0,08%
SPBRGH2 = 0
BAUDCON2.3 = 1 ' Enable 16 bit baudrate generator
TRISC.6 = 0 ' UART1 TX
TRISC.7 = 1 ' UART1 RX
TRISG.7 = 0 ' UART2 TX
TRISG.2 = 1 ' UART2 RX
/Henrik.
Bookmarks