Hi guys
I have multiple UART in my pic18f65k40, and I want to wrap the printf() in another function so I can print to different UART. How do you guy usually do that? I am using XC8 compiler.
Thanks for your help!
I have multiple UART in my pic18f65k40, and I want to wrap the printf() in another function so I can print to different UART. How do you guy usually do that? I am using XC8 compiler.
Thanks for your help!
Code:
// XC8 function to determine the destination of the standard output stream
void putch(char data){
switch(output_uart){
case DEBUG:
UART1Put(data);
break;
case COM:
UART2Put(data);
break;
case LCD:
UART3Put(data);
break;
}
}
// print to debug output
int debut_printf(const char *str, ...){
// set flag to direct output to debug uart
output_uart = DEBUG;
return printf(str, /* how do I pass ... to here */);
}
// print to LCD
int lcd_printf(const char *str, ...){
// set flag to direct output to LCD uart
output_uart = LCD;
...
}
// print to communication module.
int com_printf(const char *str, ...){
// set flag to direct output to com. uart
output_uart = COM;
...
}
Last edited: