Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] C programming on AVR

2008-03-23 by Leon

----- Original Message ----- 
From: "dlc" <dlc@frii.com>
To: <AVR-Chat@yahoogroups.com>
Sent: Sunday, March 23, 2008 7:28 AM
Subject: Re: [AVR-Chat] C programming on AVR


>
>
> Sander Pool wrote:
>> Why are printf and malloc bad habits? In your opinion, of course.
>
> Oy!  You've opened a can o' worms right and proper!  Printf is a nasty
> bit of work that is a small OS in and of itself.  It has to dynamically
> restructure itself to handle different print options since there is no
> fixed order or function within its use.  As such it sucks up a bunch of
> memory for very little utility.  Malloc is simply bad because you give
> up control of how memory is being used.  You typically have little
> enough RAM lying about to get what you want done, you don't need
> something else assigning RAM to structures that you can't reuse or
> carefully control!  With embedded programming you must know where all
> your time is being spent and what RAM is being used and where it is
> being used.

I was using fprintf extensively in part of an ARM application to make things 
easy, when writing formatted data to a buffer for transmission. It worked OK 
but it just took too much time and I was over-running a 20ms interrupt, so I 
had to replace it with my own function.

Leon
--
Leon Heller
Amateur radio call-sign G1HSM
Yaesu FT-817ND and FT-857D transceivers
Suzuki SV1000S motorcycle
leon355@btinternet.com
http://www.geocities.com/leon_heller

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.