• AVR Libc
    • Introduction
    • General information about this library
    • Supported Devices
    • avr-libc License
  • Toolchain Overview
    • Introduction
    • FSF and GNU
    • GCC
    • GNU Binutils
    • avr-libc
    • Building Software
    • AVRDUDE
    • GDB / Insight / DDD
    • AVaRICE
    • SimulAVR
    • Utilities
    • Toolchain Distributions (Distros)
    • Open Source
  • Memory Areas and Using malloc()
    • Introduction
    • Internal vs. external RAM
    • Tunables for malloc()
    • Implementation details
  • Memory Sections
    • The .text Section
    • The .data Section
    • The .bss Section
    • The .eeprom Section
    • The .noinit Section
    • The .initN Sections
    • The .finiN Sections
    • Using Sections in Assembler Code
    • Using Sections in C Code
  • Data in Program Space
    • Introduction
    • const Keyword
    • Data
    • Strings
    • Caveats
  • avr-libc and assembler programs
    • Introduction
    • Invoking the compiler
    • Example program
    • Pseudo-ops and operators
  • Inline Assembler Cookbook
    • GCC asm Statement
    • Assembler Code
    • Input and Output Operands
    • Clobbers
    • Assembler Macros
    • C Stub Functions
    • C Names Used in Assembler Code
    • Links
  • How to Build a Library
    • Introduction
    • How the Linker Works
    • How to Design a Library
    • Creating a Library
    • Using a Library
  • Benchmarks
    • Some libc functions
    • Math functions
  • Porting From IAR to AVR GCC
    • Introduction
    • Registers
    • Interrupt Service Routines (ISRs)
    • Intrinsic Routines
    • Flash Variables
    • Non-Returning main()
    • Locking Registers
  • Frequently Asked Questions
    • My program doesn't recognize a variable updated within an interrupt routine
    • I get "undefined reference to..." for functions like "sin()"
    • How to permanently bind a variable to a register?
    • How to modify MCUCR or WDTCR early?
    • What is all this _BV() stuff about?
    • Can I use C++ on the AVR?
    • Shouldn't I initialize all my variables?
    • Why do some 16-bit timer registers sometimes get trashed?
    • How do I use a #define'd constant in an asm statement?
    • Why does the PC randomly jump around when single-stepping through my program in avr-gdb?
    • How do I trace an assembler file in avr-gdb?
    • How do I pass an IO port as a parameter to a function?
    • What registers are used by the C compiler?
    • How do I put an array of strings completely in ROM?
    • How to use external RAM?
    • Which -O flag to use?
    • How do I relocate code to a fixed address?
    • My UART is generating nonsense! My ATmega128 keeps crashing! Port F is completely broken!
    • Why do all my "foo...bar" strings eat up the SRAM?
    • Why does the compiler compile an 8-bit operation that uses bitwise operators into a 16-bit operation in assembly?
    • How to detect RAM memory and variable overlap problems?
    • Is it really impossible to program the ATtinyXX in C?
    • What is this "clock skew detected" message?
    • Why are (many) interrupt flags cleared by writing a logical 1?
    • Why have "programmed" fuses the bit value 0?
    • Which AVR-specific assembler operators are available?
    • Why are interrupts re-enabled in the middle of writing the stack pointer?
    • Why are there five different linker scripts?
    • How to add a raw binary image to linker output?
    • How do I perform a software reset of the AVR?
    • I am using floating point math. Why is the compiled code so big? Why does my code not work?
    • What pitfalls exist when writing reentrant code?
    • Why are some addresses of the EEPROM corrupted (usually address zero)?
    • Why is my baud rate wrong?
  • Building and Installing the GNU Tool Chain
  • Using the GNU tools
  • Using the avrdude program
  • Release Numbering and Methodology
  • Acknowledgments
  • Todo List
  • Deprecated List
  • Library Reference
    • : Allocate stack space
      • alloca
    • : Diagnostics
      • assert
    • : Character Operations
      • Conversion
        • toascii
        • tolower
        • toupper
    • : System Errors
      • errno Variable
    • : Integer Type conversions
    • : Mathematics
      • Constants
      • Miscellaneous
        • fabs
        • fdim
        • fma
        • fmin
        • fmax
        • fmod
        • modf
      • Inspect
        • isfinite
        • isinf
        • isnan
        • copysign
        • signbit
        • frexp
      • Exponential
        • exp
        • ldexp
        • pow
        • log
        • log10
        • square
        • sqrt
        • cbrt
      • Trigonometric
        • sin
        • cos
        • tan
        • asin
        • acos
        • atan
        • atan2
        • hypot
      • Hyperbolic
        • sinh
        • cosh
        • tanh
      • Rounding
        • ceil
        • floor
        • round
        • lround
        • rint
        • lrint
        • trunc
    • : Non-local goto
      • setjmp
      • longjmp
    • : Standard Integer Types
    • : Standard IO facilities
      • Types, Constants, and Globals
        • FILE
        • stdin, stdout, stderr
        • EOF
      • Stream Setup
        • fdev_setup_stream, FDEV_SETUP_STREAM
        • _FDEV_SETUP_READ, _FDEV_SETUP_WRITE, _FDEV_SETUP_RW
        • _FDEV_EOF, _FDEV_ERR
        • fdev_get_udata, fdev_set_udata
      • Open, Close, Status
        • fdevopen
        • fdev_close
        • fclose
        • feof
        • ferror
        • clearerr
      • Stream Input
        • getchar
        • getc
        • fgetc
        • ungetc
        • fgets
        • gets
        • fread
      • Formatted Input
        • scanf, scanf_P
        • fscanf, fscanf_P
        • sscanf, sscanf_P
        • vscanf
        • vfscanf, vfscanf_P
      • Stream Output
        • putchar
        • putc
        • puts, puts_P
        • fputc
        • fputs, fputs_P
        • fwrite
        • fflush
      • Formatted Output
        • printf, printf_P
        • fprintf, fprintf_P
        • sprintf, sprintf_P
        • snprintf, snprintf_P
        • vprintf
        • vfprintf, vfprintf_P
        • vsprintf, vsprintf_P
        • vsnprintf, vsnprintf_P
    • : General utilities
      • Memory allocation
        • malloc
        • calloc
        • realloc
        • free
      • Number-String conversion
        • atoi, atol
        • strtol, strtoul
        • atof, strtof
        • itoa, ltoa, utoa, ultoa
        • dtostre, dtostrf
      • Integer math
        • abs, labs
        • div, ldiv
        • rand, rand_r, srand
        • random, random_r, srandom
      • Other functions
        • bsearch
        • qsort
        • exit
    • : Strings
      • Search Character(s)
        • strlen, strnlen
        • strchr, strrchr, strchrnul
        • strspn, strcspn
        • strpbrk
        • strtok, strtok_r, strsep
      • String Compare
        • strcmp, strcasecmp, strncmp, strncasecmp
        • strstr, strcasestr
      • String Copy
        • strcpy, strlcpy, strncpy
        • strcat, strlcat, strncat
        • strdup
      • Inplace Modification
        • strrev
        • strlwr
        • strupr
      • Memory Functions
        • memchr, memrchr
        • memcpy, memmove
        • memset
        • memccpy
        • memcmp
        • memmem
      • Others
        • __ATTR_PURE__
        • _FFS, ffs, ffsl, ffsll(x)
    • : Bootloader Support Utilities
    • : EEPROM handling
      • Read
        • eeprom_read_byte
        • eeprom_read_word
        • eeprom_read_dword
        • eeprom_read_float
        • eeprom_read_block
      • Write
        • eeprom_write_byte
        • eeprom_write_word
        • eeprom_write_dword
        • eeprom_write_float
        • eeprom_write_block
      • Update
        • eeprom_update_byte
        • eeprom_update_word
        • eeprom_update_dword
        • eeprom_update_float
        • eeprom_update_block
    • : Fuse Support
      • Macros
    • : Lockbit Support
      • Macros
    • : Interrupts
      • ISR: Declare Interrupt Service Routine
        • isr_vect: Controller specific vector name
        • BADISR_vect: Catch-all for undefined handlers
        • ISR_BLOCK: Default behaviour
        • ISR_NOBLOCK: Enable interrupts
        • ISR_NAKED: Don't generate prologue/epilogue
        • ISR_ALIASOF: Use ISR for multiple sources
      • EMPTY_INTERRUPT: Declare empty ISR
      • cli(), sei(): Switch Interrupt Flag
    • : AVR device-specific IO definitions
    • : Program Space Utilities
    • : Power Reduction Management
      • PRR: Power Reduction Register
      • CLKPR: Clock Prescaler
    • : Special function registers
      • Additional notes from
    • : Signature Support
    • : Power Management and Sleep Modes
      • sleep_enable
      • sleep_disable
      • sleep_cpu
    • : avr-libc version macros
    • : Watchdog timer handling
      • wdt_enable
      • wdt_disable
      • wdt_reset
    • Atomically and Non-Atomically Executed Code Blocks
    • : CRC Computations
  • Demo Projects
    • A simple project
      • The Project
      • The Source Code
      • Compiling and Linking
      • Examining the Object File
      • Linker Map Files
      • Generating Intel Hex Files
      • Letting Make Build the Project
      • Reference to the source code
    • A more sophisticated project
      • Hardware setup
      • Functional overview
      • A code walkthrough
        • Macro definitions
        • Variable definitions
        • Interrupt service routines
        • Auxiliary functions
        • main()
      • The source code
    • Using the standard IO facilities
      • Hardware setup
      • Functional overview
      • A code walkthrough
        • stdiodemo.c
        • defines.h
        • hd44780.h
        • hd44780.c
        • lcd.h
        • lcd.c
        • uart.h
        • uart.c
      • The source code
    • Example using the two-wire interface (TWI)
      • Introduction into TWI
      • The TWI example project
      • The Source Code
    • Combining C and assembly source files
      • Hardware setup
      • A code walkthrough
        • asmdemo.c
        • project.h
        • isrs.S
      • The source code