Yes, it's the first trap I was caught, too ;-)
As far as I know of, there are at least two approaches we could take
(1) use printf with changing the configuration (USBUART)
(2) use UART_PutString() (any UART)
For (1) There is an AN "KBA89724", it uses USBUART.
I also posted a topic regarding to this.
I'd recommend you to use USB-Serial function of KitProg
As I don't want to connect 2 cables to CY8CKIT-059.
For (2), I'd do something like below
Then change some build settings, if you need to support "float"
From the menu Project > Build Settings...
Select ARM GCC xxx > Linkder > Command Line, then add Custom Flags
Add "-u _printf_float" for print, sprintf, and "-u _scanf_float" for scanf, sscanf.
Similarly in the Linker > General
Set "Use newlib-nano Float Formatting" to True
As floating point requires more memory, we also need to change the heap size
Select and double click to open Workspace Explorer > <the project> > Design Wide Resources
Then change the Heap Size bigger, the default is 0x80, I changed it to 0x400 here
Now, the program
char str ; /* print buf */
void print(char *str)
int icount = 0 ;
float fcount = 0.0 ;
CyGlobalIntEnable; /* Enable global interrupts. */
sprintf(str, "UART Test (%s %s)\r\n", __DATE__, __TIME__) ;
sprintf(str, "counts: %5d, %5.2f\r\n", icount, fcount) ;
fcount += 0.01 ;
CyDelay(1000) ; /* wait 1000ms = 1 sec */
I used "Tera Term" for the serial terminal, and the output was