This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sprintf works, but not putchar or printf

I am using Infineon XC866 and Keil uvision. I selected the LX51 Linker in the project setup. The UART is init through

///  Initialization of module 'UART (Serial Interface)'

UART_vInit();

which was done by Dave.

Sprintf works fine. And the function

// USER CODE BEGIN (MAIN_General,10)
void message( char *pucMessage )
{
 // while the character is not 0
 while (*pucMessage)
 {
  SBUF = *pucMessage++;
  while (TI == 0) {;}
  TI = 0;
 }
 return;
}
// USER CODE END

works fine.

But I can not get putchar or printf to work.

Any advise ?

Parents
  • No, putchar is called from printf.
    In principle the printf works like your function. The TI is set to enable transmitting of character.
    Thats all. The printf() is implemented to
    take care about that.
    After each character that was transmitted the TI will reset to 0 and for the next character again to 1.
    For the first character you must set the TI to '1' yourself.

    Stefan

Reply
  • No, putchar is called from printf.
    In principle the printf works like your function. The TI is set to enable transmitting of character.
    Thats all. The printf() is implemented to
    take care about that.
    After each character that was transmitted the TI will reset to 0 and for the next character again to 1.
    For the first character you must set the TI to '1' yourself.

    Stefan

Children
No data