[PIC] PPS for ESUART2 on PIC18F45K40 not working

Status
Not open for further replies.

FrustratedEngineer

Newbie level 6
Joined
Nov 30, 2015
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
122
Guys,

I am trying to connect UART2 engine to RD6 (Tx) and RD7 (Rx). For this I used PPS feature over RD6 and RD7.

When I check in debug mode, I get the Tx Interrupt and I can see that TX2REG is filled with the correct data everytime.

However, I don't see the data coming out of the RD6 pin, when I tapped the pin on Oscilloscope.
My immediate doubt is on PPS initialisation. I tried whatever I could but could not get data on Pin.

Please let me know where I am getting wrong.

PPS enabling... I tried both combinations (OFF and ON )
Code:
#pragma config PPS1WAY = OFF

Initialisation of PPS on RD6 and RD7
Code:
    ANSELDbits.ANSELD6 = 0;
    ANSELDbits.ANSELD7 = 0;
    TRISDbits.TRISD6 = 0;
    TRISDbits.TRISD7 = 1;
    PPSLOCK = 0x55;
    PPSLOCK = 0xAA;
    PPSLOCKbits.PPSLOCKED = 0x00; // unlock PPS
    RD6PPS = 0x0B;   //RD6->EUSART2:TX2;
    RD7PPS = 0x0B;   //RD7->EUSART2:RX2
    RX2PPSbits.RXPPS = 0x1F;   //RD7->EUSART2:RX2;
    PPSLOCK = 0x55;
    PPSLOCK = 0xAA;
    PPSLOCKbits.PPSLOCKED = 0x01; // lock PPS
 

Not directly answering your question, the default state for the PPSLOCKED bit is 'off'(0) so I strongly suggest that you don't try to play with the unlock/lock settings until you have everything working.
When you do, the unlock sequence MUST be executed bu the MCU as consecutive instructions. Unfortunately this is not guaranteed by any C compiler and you really need to use the in-line assembler capability - or better yet any built-in capability that your compiler might provide for you (some provide macros that do these special sequences for you).
Are you using a 28-pin or a 40-pin device? Your setting for the RD6PPS implies that it must be a 40-pin device.
Also the 2nd line (RD7PPS = 0x0b) might be confusing things a bit.
Susan
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…