You are here

Alternate printf Function for PSoC® 4 - KBA87093 | Cypress Semiconductor

Support & Community

Alternate printf Function for PSoC® 4 - KBA87093

Last Updated: May 27, 2016

The printf function consumes significant flash memory in PSoC® 4. Is there any alternate function for printf


The printf function is provided in the tool chain (ARM® GCC). As an alternative, use the iprintf() function provided in this KB. This function has the optimized code to implement some of the most commonly-used features of the printf function. 

The iprintf() function supports only the following format specifiers:

Table 1. iprintf() Format Specifiers

%s Array of char
%d Integer in decimal format
%c Char single character
%x Integer in hexadecimal format

To test the code, follow the steps given below:

  1. Create a project named “Design01”.
  2. Download and extract Copy the files iprintf.c and iprint.h to the “Design01.cydsn” folder.
  3. Add iprintf.c and iprint.h to the project.
  4. Add #include “iprintf.h” in the main.c file as shown in step 6.
  5. Place the SCB-based UART Component  in the design and configure its parameters depending on the requirements. Name the UART Component as “SCB_1”. If you want a different name, then modify the call SCB_1_UartPutChar(ch) in the iputc() function present in the iprintf.c file. 

    If you are using the Software UART Component (SW_Tx_UART) with the instance name SW_Tx_UART_1, then use the function SW_Tx_UART_1_PutChar() in iputc() function.

  6. Use the iprintf() function call in the main() function as shown in the following code. This code continuously prints the string “abcd” and the incrementing numbers in decimal, ASCII, and hexadecimal formats. 
File TitleLanguageFile SizeLast Updated
Download iprintf.zipEnglish1.03 KB05/21/14
Knowledge Base Tags: 

Provide feedback on this article

Browse KB By Product

Browse KB by Type