You are here

Using printf function in PSoC3 to send data to UART | Cypress Semiconductor

Using printf function in PSoC3 to send data to UART

Last Updated:

June 19, 2011

To use Keil's IO functions such as printf, the program must override Keil's built-in putchar function (the default putchar uses a SFR-based UART, which PSoC3 doesn't have).  For example, if ‘UART’ is the instance name of UART component in your project , then you should write following function in the file main.c to override Keil’s build-in putchar function:

char putchar(char c)
{
     UART_WriteTxData((uint8)c);
     return c;
}

Now, the compiler will use the new putchar function to stream data to the UART. Note that this function should either be defined or declared before the first call to the printf() function for proper execution.