Use the sprintf() function, there is no implementation for a system
printer in the libraries.
but why the example project using the printf() can do ? or I missed something?
Can you check what is the size of the heap memory allocated to the system from the project's CYDWR -> Systems tab?
Assuming that you have proper libraries to use that function in your system, you may have to increase the memory set for heap size in your project.
roit, can you enlighten me about printf() in a psoc project, what is it printing to ?
I do not see any sdtio.h in the workspace after a build, so I cannot figure out what
the STD is ?
1 of 1 people found this helpful
Finally, I resolved this problem after growing the heap size to 0x400, the original is only 0x80.
Roit, thanks you very much!!
Does it means that the printf() function will consume more RAM space?
Yes, the more heap size allocated, the more RAM will the project consume. If RAM usage is a concern, you can write a loop in your own project to send the data byte by byte over UART and no need to store it in a "file".
The printf() functions internally use character transfer over UART. But before sending, the input is saved as a "file" in the heap and then used to send the character byte by byte. So bigger the "file" that you want to save, the more heap size should be allocated.
Hope this helps.
I dug out this code from a Cypress example:
/* For GCC compiler revise _write() function for printf functionality */
int _write(int file, char *ptr, int len)
file = file;
for (i = 0; i < len; i++)
This you should provide for using the printf() function directly.
Regarding the heap:
I frequently use malloc() and free() which gets and releases memory from/to the heap instead of using the stack or global data storage. Feels like being quite more flexible. Thus my heap size is usually quite a bit more than 0x0080