Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Alternate printf Function for PSoC® 4

lock attach
Attachments are accessible only for community members.

Alternate printf Function for PSoC® 4

Anonymous
Not applicable

The printf function consumes significant flash memory in PSoC® 4.

What is the 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 with printf function, follow the steps given below:

 

  1. Create a project named “Design01”.
  2. Download and extract iprintf.zip. 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.                                                                                                                                                                                     
  6. 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.

  7. 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.                                                                 
    1.png

 

 

Version: *B

Translation - Japanese: PSoC® 4 の printf の代替関数 - KBA87093- Community Translated (JA)

Attachments
0 Likes
1862 Views