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){;}
}