By default, MPLAB® XC32's libraries use UART2 for STDOUT. This means that formatted output functions such as printf() use UART2.
The MPLAB XC32 compiler provides a __XC_UART variable that you may use to switch the default to UART 1. After including the xc.h header file, just add the following statement to your code in one of your functions: __XC_UART = 1. Currently, only UART1 and UART2 can be used by setting the __XC_UART to 1 or 2 respectively.
In some cases, you may want to use some other peripheral or mechanism for your output, other than the UART1 and UART2. To do this, you can provide a custom _mon_putc() function. The _mon_putc() function will be called by printf to pass each character and _mon_putc() will output to the module as defined in the function.
This example writes to UART3. “Hello World” will be displayed in the output window via the simulator's SIM UART3 IO tab. Make sure the UART IO is configured under the Debugger Settings in MPLAB X.
Microchip Technology acquires Atmel