0% found this document useful (0 votes)
85 views47 pages

ADC Programming for ATmega Microcontrollers

Here are the course contents (slides) of CSE 315 ( Microprocessors and Microcontrollers ) course in BUET (Bangladesh University of Engineering & Technology) taken by Tanvir Ahmed Khan , in December 2015. Please check other files for full content.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views47 pages

ADC Programming for ATmega Microcontrollers

Here are the course contents (slides) of CSE 315 ( Microprocessors and Microcontrollers ) course in BUET (Bangladesh University of Engineering & Technology) taken by Tanvir Ahmed Khan , in December 2015. Please check other files for full content.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

CSE 315

Microprocessors & Microcontrollers


Tanvir Ahmed Khan
Department of Computer Science and Engineering
Bangladesh University of Engineering and Technology.

October 21, 2014

Recap

ADC Basics

Typical Digital System Characteristics


1-bit ADC
What about n-bit ADC?

ADC Jargons

Sampling

Quantization

Resolution/Step Size

Conversion Time

Vref

Digital Data Output

Resolution/Step Size

for n-bit ADC,


I

stepsize =

Vref
2n

Find the step size if,


I
I

n = 8, Vref = 2.56V
n = 10, Vref = 2.56V

Digital Data Output


Vin
Dout =
stepsize
For, n = 9 and Vref = 2.56V , find the Dout if,


I
I

I
I

Vin = 0.8V
Vin = 2.1V

Analog-to-Digital Conversion Technologies

Successive Approximation

Integration

Counter Based Conversion


Parallel Conversion

Flash ADC

Successive Approximation ADC

Flash ADC

Todays Topic

ADC Programming in C

ATmega16/32 ADC Relevant Pin Diagram

ATmega16/32 ADC Features

ATmega16/32 ADC Features


I

10-bit ADC

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I

ADCH:ADCL

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I

ADCH:ADCL
16-bits, 6-bits are unused

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right

8 Analog input channels,

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right

8 Analog input channels,


I

7 differential input

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right

8 Analog input channels,


I
I

7 differential input
with optional gain of 10x & 200x

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right

8 Analog input channels,


I
I
I

7 differential input
with optional gain of 10x & 200x
However, only one conversion at a time

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

8 Analog input channels,


I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right
7 differential input
with optional gain of 10x & 200x
However, only one conversion at a time

Vref options,

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

8 Analog input channels,


I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right
7 differential input
with optional gain of 10x & 200x
However, only one conversion at a time

Vref options,
I

Analog Vcc , 5V

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

8 Analog input channels,


I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right
7 differential input
with optional gain of 10x & 200x
However, only one conversion at a time

Vref options,
I
I

Analog Vcc , 5V
internal 2.56V

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

8 Analog input channels,


I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right
7 differential input
with optional gain of 10x & 200x
However, only one conversion at a time

Vref options,
I
I
I

Analog Vcc , 5V
internal 2.56V
external AREF pin

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

8 Analog input channels,


I
I
I

7 differential input
with optional gain of 10x & 200x
However, only one conversion at a time

Vref options,
I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right

Analog Vcc , 5V
internal 2.56V
external AREF pin

ADC clock rate != MCU CPU clock rate

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

8 Analog input channels,


I
I
I

7 differential input
with optional gain of 10x & 200x
However, only one conversion at a time

Vref options,
I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right

Analog Vcc , 5V
internal 2.56V
external AREF pin

ADC clock rate != MCU CPU clock rate


I

selection of pre-scaler

ATmega16/32 ADC Features


I
I

10-bit ADC
2 output registers,
I
I
I

8 Analog input channels,


I
I
I

7 differential input
with optional gain of 10x & 200x
However, only one conversion at a time

Vref options,
I
I
I

ADCH:ADCL
16-bits, 6-bits are unused
Option to adjust left or right

Analog Vcc , 5V
internal 2.56V
external AREF pin

ADC clock rate != MCU CPU clock rate


I
I

selection of pre-scaler
AD Conversion takes at-least 13 ADC clock cycles

ADC Programming
Major Relevant registers

ADC Programming
Major Relevant registers

ADCH:ADCL

ADC Programming
Major Relevant registers

ADCH:ADCL

ADCSRA

ADC Programming
Major Relevant registers

ADCH:ADCL

ADCSRA

ADMUX

ADC Programming
Major Relevant registers

ADCH:ADCL

ADCSRA

ADMUX

SFIOR

ADC Programming
Major Relevant registers

ADCH:ADCL

ADCSRA

ADMUX

SFIOR

ADC Programming
ADCSRA Register

ADC Programming
ADCSRA Register

ADC Programming
ADCSRA Register

Initialization,

ADC Programming
ADCSRA Register

Initialization,
I

Polling, ADCSRA = 0b10000001;

ADC Programming
ADCSRA Register

Initialization,
I
I

Polling, ADCSRA = 0b10000001;


Interrupt, ADCSRA = 0b10001001;

ADC Programming
ADCSRA Register

Initialization,
I
I

Polling, ADCSRA = 0b10000001;


Interrupt, ADCSRA = 0b10001001;

Conversion Start,

ADC Programming
ADCSRA Register

Initialization,
I
I

Polling, ADCSRA = 0b10000001;


Interrupt, ADCSRA = 0b10001001;

Conversion Start,
I

ADCSRA = ADCSRA | 0b01000000;

ADC Programming
ADMUX Register

ADC Programming
ADMUX Register

ADC Programming
ADMUX Register

Sample ADC Program


Polling

Sample ADC Program


Interrupt

Reference

The avr microcontroller & embedded system, Chapter 13


I
I
I

Muhammad Ali Mazidi


Sarmad Naimi
Sepehr Naimi

You might also like