Attachments are accessible only for community members.
Alternate printf Function for PSoC® 4
Anonymous
Not applicable
Jun 05, 2013
06:29 AM
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Jun 05, 2013
06:29 AM
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:
- Create a project named “Design01”.
- Download and extract iprintf.zip. Copy the files iprintf.c and iprint.h to the “Design01.cydsn” folder.
- Add iprintf.c and iprint.h to the project.
- Add #include “iprintf.h” in the main.c file as shown in step 6.
- 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.
- 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.
Version: *B
Translation - Japanese: PSoC® 4 の printf の代替関数 - KBA87093- Community Translated (JA)
Labels
Rate this article: