I'm trying to use both serial ports UART1 and 2 at the "same time" in the microcontroller PIC32MX150F128B, but only UART1 work OK, the UART2 didn't work.
When I configure UART1 or UART2 individualy, works fine, but if I configure both, as the code below, UART2 doesn't work.
Please, could you help me?
Code: Select all
void main() {
JTAGEN_bit = 0;
ANSELA = 0;
ANSELB = 0;
TRISA = 0;
TRISB = 0;
LATA = 0;
LATB = 0;
Unlock_IOLOCK();
PPS_Mapping(_RPB3, _OUTPUT, _U1TX);
PPS_Mapping(_RPB2, _INPUT, _U1RX);
PPS_Mapping(_RPB10, _OUTPUT, _U2TX);
PPS_Mapping(_RPB11, _INPUT, _U2RX);
Lock_IOLOCK();
I2C1_Init(100000);
UART1_Init(115200);
UART2_Init(115200);
delay_ms(100);
while(1){
UART1_Write(0xCD);
UART2_Write(0xAB);
delay_ms(250);
}
}