3 Replies Latest reply on Jul 6, 2018 7:46 AM by dude.notmyname

    Printf working but missing the last character

    dude.notmyname

      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)