UART and PPS_Mapping P32MX250

mikroC, mikroBasic and mikroPascal PRO for Microchip’s 32-bit PIC MCUs
Post Reply
Author
Message
lam
Posts: 1
Joined: 08 Dec 2019 04:45

UART and PPS_Mapping P32MX250

#1 Post by lam » 08 Dec 2019 12:19

Hi all,

I'm trying to use the UART on the P32MX250F128b with PPS_Mapping. It DOES work if I use Soft_UART so the hardware must be OK. If I switch to the hardware UART and use PPS_Mapping, the compiler is happy, but nothing is sent through the assigned TX pin.

Currently it's just a P32MX250F128b single chip that I wired up. I need to use the hardware UART to eventually operate at much high speed. Below is a very shot test code for both Soft_UART and hardware UART.

Thank you your help.

Lam
------------------------------------------------

Code: Select all

#define WORKING

void main() {
    TRISB = 0b1100100111001011;
    AD1CON1 = 0;
    JTAGEN_bit = 0;        
    ANSELA = 0;
    ANSELB = 0;
    SYSKEY = 0xAA996655, //Unlock System 
    SYSKEY = 0x556699AA; //Unlock System
	
#ifdef WORKING

    // This works
    Soft_UART_Init(&PORTB, 3, 2, 9600, 0);   // Soft UART with RB3 for Rx, and RB2 for Tx
    Soft_UART_Write('1');

#else

    // This doesn't work!
    //IOLOCK_bit = 0; // I also tried with this
    Unlock_IOLOCK();
    PPS_Mapping(_RPB2, _OUTPUT, _U1TX);   // Sets pin RB2 to be Output and maps UART1 Transmit to it
    PPS_Mapping(_RPB3, _INPUT, _U1RX);    // Sets pin RB3 to be Input and maps UART1 Receive to it
    Lock_IOLOCK();
    //IOLOCK_bit = 1;	

    UART1_Init(9600);
    UART1_Write('0');

#endif

    while(1){;}
}

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: UART and PPS_Mapping P32MX250

#2 Post by hexreader » 09 Dec 2019 12:35

Go to ...
.... project
.... .... edit project

.... and set first two configuration options to "allow multiple configurations"

Alternatively, try changing all instances of "PPS_Mapping" to "PPS_Mapping_NoLock"

If that does not resolve the problem, let me know and I will look harder.
Last edited by hexreader on 11 Dec 2019 08:00, edited 1 time in total.
Start every day with a smile...... (get it over with) :)

hexreader
Posts: 1785
Joined: 27 Jun 2010 12:07
Location: England

Re: UART and PPS_Mapping P32MX250

#3 Post by hexreader » 10 Dec 2019 19:37

Just spotted fundamental problems with PPS selections

Check FRM tables 11-1 and 11-2

You cannot choose just any pin for any function, there are limitations as described in the two tables mentioned
Start every day with a smile...... (get it over with) :)

Post Reply

Return to “PIC32 PRO Compilers”