Printing issue with standart printf function

Hayee

Member level 2
Joined
Mar 4, 2022
Messages
49
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Activity points
469
Hi
I am going to print some values using usart port. I am using pic18f46k22 microcontroller along with mplab XC8 compiler.
This micorcontroller have two usart ports.
normally the microcontroller which have only one usart port, we can print like
Code:
printf("%u",value);
and we don't have to define in print function which port is it because microcontroller have only one port
note: printf is the standard function

but how we can print in pic18f46k22 with the desired serial port?
when i use the above code without defining the port, nothing prints.
Can you tell me how to define the port on which I have to print?
 

Not quite clear in post #1, but using printf() in XC8 requires putch() overloading to direct output to UART, no matter if your chip has one or multiple UART ports. There's no default putch() implementation in the run time library.

If you want to use multiple UARTs, you can switch putch() output dynamically, e.g. by utilizing control characters. Streams and fprintf() aren't supported in standard xc8 library.
 

Similar threads

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