Page 1 of 1

fprintf() to serial port on AVR

Posted: Fri Feb 04, 2011 9:04 am
by JetForMe
I'm thinking it would be nice to be able to call fprintf() and print directly to a serial port on the AVR. I don't know if there's already support for this or not.

Otherwise, I have to either malloc() or permanently assign space for a buffer to build the string (either statically, or by statically allocating a bigger stack). I figure internally, fprintf() outputs a byte at a time into the FILE structure, I just have to associate one with a call to sdWrite() somehow.

Any suggestions?

TIA!

Re: fprintf() to serial port on AVR

Posted: Fri Feb 04, 2011 12:45 pm
by Giovanni
You should read the WinAVR C library documentation, I did something like that for ARM using newlib, a mechanism must exist for WinAVR too.

Be careful that the prinft-like functions can eat a lot of stack space.

Giovanni