Programming AVR ADC module with avr-gcc
Most AVR microcontrollers have Analog to Digital Converter (ADC) integrated into to chip. Such a solution makes embedded designers’ life much easier when creating projects and programming them. With no need for external ADC, PCB takes less space, easier to create programs – it saves time and money. As an example, let’s take the Atmega8 microcontroller, which has up to 8 ADC inputs, most with a 10-bit resolution(excluding ADC4 and ADC5 inputs that are 8-bit). All features of AVR internal ADC can be found on official ATMEL AVR datasheets, but most important to mention are: ±2 LSB accuracy – so measurements aren’t very accurate. If AREF voltage is 5V, then the error may reach ±0.04V, but this is still good results for most of the tasks; Integral nonlinearity ±0.5 LSB; Conversion speeds up to 15kSPS at maximum resolution. This is far not enough for 20kHz audio signal sampling.