Your source for daily hacks

Published on: September 1, 2013 / Comments: None

Tips for reducing your code size on AVR platforms

Disclaimer: do not put your microcontroller in a vice.

The guys over at Bot Thoughts like using AVR micros, specifically ATTiny’s.  Whats wrong with the ATTiny ?  Well … It’s tiny!  Meaning not a lot of code space.  After reading this doc they put together some highlights.

While some of the tips may be pretty obvious (like compiling with -Os, let the compiler optimize for size) there are some other tips you may not have thought about.  On the test code, they got their code down from 4.2k to 1.4k.  The biggest chunk of savings came from not using floating point math, believe it or not you can accomplish a lot of float type math with just integers and you can save a bunch!

Nice tips, I recommend checking out the full article.

Leave a Reply

Some HTML is OK