Microchip® Advanced Software Framework

 All Files Functions Typedefs Enumerations Enumerator Macros Groups
ADC example 1 for the ATmega48A Documentation

Introduction

This example demonstrates how to use the megaAVR ADC Driver to do a simple ADC conversion.

Files:

Brief description

This application will read the analog value on the ADC0 pin and output the 8-bit result on PORTB. in an infinite loop. If using an STK600, connect PORTB to the STK600 LEDs.

Note
You must connect an analog voltage source to the ADC0 pin. If using the STK600, you can use AREF0 or AREF1. Do not apply a voltage above the ADC voltage reference.
As the values in this example is not used for any meaningful calculation we do not throw away the first reading after setting the reference. You should always discard the first conversion after changing the voltage reference as the reference may not yet be stable. You can find more information about this in the ADC chapter of your device datasheet.

Compilation Info

This software was written for the GNU GCC for AVR, and IAR Embedded Workbench.
Other compilers may or may not work.

Contact Information

For further information, visit Microchip.
Support and FAQ: https://www.microchip.com/support/