1. Key. Otherwise, the putchar function will be undefined.
Right-click the project and choose option> general option> ibrary configuration to change library to full, and select full2 from general option> library option> printf formatter.
2. Add in Main. C, where Serial Port 1 is used
/* --------------------------- Privatefunction prototypes -----------------------------------------------*/
# Ifdef _ gnuc __
/* With GCC/raisonance, small printf (option LD linker-> libraries-> small printf
Set to 'Yes') CILS _ io_putchar ()*/
# Define putchar_prototype int _ io_putchar (INT ch)
# Else
# Define putchar_prototype int fputc (int ch, file * F)
# Endif/* _ gnuc __*/
And
/**
* @ Brief retargets the C library printffunction to the usart.
* @ Param none
* @ Retval none
*/
Putchar_prototype
{
/* Place your Implementation of fputc here */
/* E.g. Write a character to the usart */
Usart_senddata (eval_com1, (uint8_t) CH );
/* Loop until the end of transmission */
While (usart_getflagstatus (eval_com1, usart_flag_tc) = reset );
Return ch;
}
The printf function prints the string and ends only when \ 0 is encountered.