2022-04-27 06:41 AM
I have been using printf() to output to UART for many years on a STM32L052
All these projects still compile and printf() to UART, no problem.
I started a NEW project with CubeMX, but now printf() does NOT print to UART.
I use the same int fputc(int ch, FILE *f) as in ALL the other projects, but still no UART output. (Plese see attached code)
I looked at other solutions, but they seem to be doing similar int fputc(int ch, FILE *f)
Any help appreciated
2022-06-28 03:32 PM
That is a very severely limited printf(). In case the full implementation with a reasonable resource usage is needed, I would recommend nanoprintf of LwPRINTF.
2022-06-30 11:56 AM
That is kind-of the point. This will work on stm32L053 with OS added. The others ... not so much; Also, this is more of an 'inspire' example to roll your own.
2022-06-30 12:34 PM
Of, course everything is OK if it solves some problem and fits the target. I also just reminded that Newlib's 12+ KB FLASH and 2+ KB RAM monster with a malloc() and global variables is not the only option of full implementations. The nanoprintf takes 1-3 KB of FLASH and does not use any heap or global variables - therefore it is completely reentrant. :)