Hi,

> However, the info gets sent on the serial port instead of lcd.  The
> relevant portion of the code is appended. Please help. 
> 
> #define putchar PUTCHAR
> 
> void PUTCHAR(unsigned char dat)
> {   code to  print on lcd 
>  }

You need to call your putchar routine putchar (in small letters),
because printf references the symbol putchar. The linker than either
takes your putchar (for lcd) or the default putchar (uart) from the
library. Your code defines a symbol PUTCHAR, which is never used as the
macro expands too late for the compilation of printf.

I see no way of getting both the library's putchar and an own version
besides copying the library code into your project, rename the putchar
routines and implement a new dispatcher putchar, like:

<code>
void putchar_uart(unsigned char c) {
  // code from library
}

void putchar_lcd(unsigned char c) {
  // code to print on LCD
}

int putchar_on_usart = 1;
void putchar(unsigned char c) {
  if (putchar_on_usart) {
    putchar_uart(c);
  } else {
    putchar_lcd(c);
  }
}
</code>

The dispatcher can be generalized...

Good luck,
Raphael



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to