cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

New Contributor II

hey,

I wanted to use printf() in my project, so I looked up how to make it work. I included stdio.h, increased the heap size to 0x200, and added the following to the beginning of my code:

int _write(int file, char *ptr, int len)

{

     int i;

     file = file;

     for (i = 0; i < len; i++)

     {

         UART_PutChar(*ptr++);

     }

     return len;

}

this makes it so I can use printf, but when I printed printf("uart test") it output "uart tes", missing the last character. I tried printing twice; "test1" and "test2" and the first string came out correctly ("test1") but the second printf was missing the last character again, giving "test". I can sprintf after with no issues, just the last printf() loses the last character

what is going on there? what do I need to adjust?

I'm using the CY8CKIT-059 and a FTDI cable (which has been working fine)

0 Likes
Reply
1 Solution
New Contributor II

Bob,

I can't post the project to which I was adding it due to the code being proprietary. I made a new project to re-create the problem and it just worked. I'll have to look at what in the code might be interfering.

xzng, I'll try that

View solution in original post

0 Likes
Reply
3 Replies
Esteemed Contributor II

Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use

Creator->File->Create Workspace Bundle (minimal)

and attach the resulting file.

Bob

0 Likes
Reply
New Contributor II

Bob,

I can't post the project to which I was adding it due to the code being proprietary. I made a new project to re-create the problem and it just worked. I'll have to look at what in the code might be interfering.

xzng, I'll try that

View solution in original post

0 Likes
Reply
Moderator
Moderator

0x200 heap size maybe not enough, try to change the heap size to 0x300.

0 Likes
Reply