AVR Libs


  • C++
  • Sits on top of AVR LibC
  • PROGMEM and pgm_read_byte to store read only data in Flash only
  • Sometimes have to break the API for the greater good
  • Prefer using 8 bit types
  • -function-sections
    • Every function has it’s own section, then the linker can discard those sections
  • Pass template parameters as the code will be computed and discarded to save space
  • Restructure code to be event driven
    • Saves power, stops using busy loop rather than waiting
    • Make the main loop just check events and sleep
  • More functions in a classes
  • Write documentation first to avoid scope creep
  • Avoid generic names in libraries since the linker just picks the fist one
  • Use namespaces for libs
  • Limit variables
  • Name variables INCLUDING counters
  • Use scope enums


  • Harvard Arch

    • RAM and Program are separate
    • Program is read only
  • AVR limited memory CPU