I wrote a small buffered I/O system that sits between the avr-gcc stdio and
the UART. Attached is what I use.
The GCC library routines are pretty efficient and standard. So, now that I
have the buffer scheme I don't mess with my own pretty-printing routines any
more. Anyway the bit o magic to tie the buffered I/O stream into GCC stdio
is:
InitSerialIO(BaudTbl[BAUD38400]);// my routine
fdevopen(putlcdchar, 0, 0); // Assigns to stderr & stdout
stdout = 0; // Clobber stdout
fdevopen(put_char, get_c, 0); // Now overwrite stdout
Note, on this particular project I set "stderr" to a small LCD output
driver. put_char is blocking, get_c is non-blocking. See attached files.
The code is from a mega16 project - slight modifications to the init routine
might be needed for other chips.
-----Original Message-----
From: Graham Davies
--- In AVR-Chat@yahoogroups.com, "wbounce" <wbounce@s...> wrote:
> So you write all your own print
> to uart routines ...
Absolutely, but using buffered I/O. Personally, I use my own operating
system which includes stream I/O. My printf(), actually OsPrintfLite(),
puts the output characters in a buffer and an interrupt transfers them
to the actual UART, or wherever else the stream identifier sends them.
This makes printf() *much* less intrusive and *much* safer in embedded
applications.
> ... including things
> like handling double?
Floating point is often not necessary in embedded systems and should be
avoided due to long and unpredictable execution times. So, just don't
implement it in your printf(). That's why mine's called OsPrintfLite().
If you absolutely have to printf() floating point, use the library to
print it to a string and throw the string to your printf(). But, now
you've got to inspect the floating point library and sprintf() for
suitability to embedded systems.
Graham.
Yahoo! Groups LinksMessage
RE: [AVR-Chat] Re: Atmega16 Real time clock
2005-06-03 by Larry Barello
Attachments
- No local attachments were found for this message.