PIC18 PPS unlock sequence

Thread Starter

bug13

Joined Feb 13, 2012
1,708
Hi guys

I need to re-map UART3 to RE0 and RE1, the pic is 18f65k40. In simulator, I don't see the value of PPSLOCK change at all, what I have done wrong?

here is how I tried to do it:
Code:
    di();
    // unlock  peripheral pin select module (PPS)
    // interrupt need to be disable if interrupt is enable before this point
    PPSLOCK = 0x55;
    PPSLOCK = 0xAA;
    PPSLOCKbits.PPSLOCKED = 0;
  
    // mapping UART3 TX and RX
    RX3PPS = 0x21;          // UART3 RX map to RE1
    RE0PPS = 0x10;          // UART3 TX map to RE0
  
    // lock peripheral pin select module (PPS)
    PPSLOCK = 0x55;
    PPSLOCK = 0xAA;
    PPSLOCKbits.PPSLOCKED = 1;
Here is the datasheet example (page337, section 17.4):
Code:
; Disable interrupts:
BCF INTCON,GIE
; Bank to PPSLOCK register
BANKSEL PPSLOCK
MOVLW 55h
; Required sequence, next 4 instructions
MOVWF PPSLOCK
MOVLW AAh
MOVWF PPSLOCK
; Clear PPSLOCKED bit to enable writes
; Only a BCF instruction will work
BCF PPSLOCK,PPSLOCKED
; Enable Interrupts
BSF INTCON,GIE
 

Thread Starter

bug13

Joined Feb 13, 2012
1,708
update:

Changing PPS1WAY config fixed it, still don't know why. In my origional code, this is the only place that unlock or lock the PPS.


From
Code:
#pragma config PPS1WAY = OFF
to
Code:
#pragma config PPS1WAY = ON
 
Top