Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Printing issue with standart printf function

Hayee

Member level 2
Joined
Mar 4, 2022
Messages
44
Helped
0
Reputation
0
Reaction score
1
Trophy points
8
Activity points
434
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.
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top