SlideShare a Scribd company logo
1 of 38
Download to read offline
External Hardware Interrupts
and Analogue to digital
Converter
Eng:Mohamed Loay Ali
1
Contents
 External Hardware Interrupt.
1. Introduction
2. Registers.
3. Programming in C.
4. External Interrupt priority (Vector table).
 Analogue to Digital Converter ADC.
1. Introduction
2. ADC Features in AVR
3. Registers
4. Programming in C
5. LDR.
6. Temperature Sensor LM35.
Eng:Mohamed Loay Ali
2
External Hardware Interrupt
Enabling the Interrupts:
To enable the interrupt is should be unmasked as shown in the following
figure.
 SREG is the Status register ,to enable the interrupt (unmask the
interrupt) the bit D7(I) should be activated using sei() set interrupt then
use TMISK register to enable interrupts of Timer (0 or 1 or 2)this will
covered later.
 To disable the interrupt the bit D7(I) should be cleared by cli()clear the
interrupt.
Eng:Mohamed Loay Ali
3
External Hardware Interrupt
 The External Interrupts are triggered by the INT0 and INT1 pins or
any of the PCINT23...0 pins.
 Observe that, if enabled, the interrupts will trigger even if the INT0
and INT1or PCINT23...0 pins are configured as outputs.
 The INT0 and INT1 interrupts can be triggered by a falling or
rising edge or a low level.
 The other pins interrupts can be triggered by toggling the pins.
1.Introduction
Eng:Mohamed Loay Ali
4
External Hardware Interrupt
1.Introduction
Eng:Mohamed Loay Ali
5
External Hardware Interrupt
1.Introduction
Eng:Mohamed Loay Ali
6
External Hardware Interrupt
2.Registers
Eng:Mohamed Loay Ali
7
External Hardware Interrupt
2.Registers
When an edge or logic change on the INT1or 2 pin triggers an interrupt
request, INTF1 or 2 becomes set (one). If the I-bit in SREG and the INT1 or 2
bit in EIMSK are set (one), the MCU will jump to the corresponding Interrupt
Vector.
Eng:Mohamed Loay Ali
8
External Hardware Interrupt
2.Registers
Bit 2 – PCIE2: Pin Change Interrupt Enable 2
Any change on any enabled PCINT[23:16] pin will cause an interrupt.
Bit 1 – PCIE1: Pin Change Interrupt Enable 1
Any change on any enabled PCINT[14:8] pin will cause an interrupt.
Bit 0 – PCIE0: Pin Change Interrupt Enable 0
Any change on any enabled PCINT[7:0] pin will cause an interrupt
These interrupts can be triggered only if the bits is enabled and the I-bit in the
Status Register (SREG) is set (one).
Eng:Mohamed Loay Ali
9
External Hardware Interrupt
2.Registers
Eng:Mohamed Loay Ali
10
External Hardware Interrupt
4)External Interrupt priority (Vector table)
See external interrupt priority example.
Eng:Mohamed Loay Ali
11
External Hardware Interrupt
3.Progarmming in C
See the following Examples
1)External interrupt example 1
2)External interrupt example 2
Eng:Mohamed Loay Ali
12
ADC
1)Introduction to ADC
ADC devices:
 ADC are widely used in data acquisition systems.
 Digital systems use binary (discrete) values , but in the physical
world every is thing is analogue (Continuous).
 Therefore the ADC is required to convert the analogue signal
(continuous) to digital signal (discrete) so the microcontroller can
read and process the data.
 The physical quantity such as (Pressure , Temperature and velocity )
are converted to electrical signal (Volt or Current) through sensor or
tranducer then fed into the ADC.
Eng:Mohamed Loay Ali
13
ADC
1)Introduction to ADC
Difference Between Analogue Signal and Digital Signal
Eng:Mohamed Loay Ali
14
ADC
1)Introduction to ADC
The Discretization of the signals:
Eng:Mohamed Loay Ali
15
ADC
1)Introduction to ADC
The Procedure of taking a signal from real world to Digital System
Controller
Eng:Mohamed Loay Ali
16
ADC
1)Introduction to ADC
Some Major Characteristics of ADC:
RESOLUTION:
 Is the smallest change that can be discerned by an ADC.
 The ADC has n-bit, where n can be 8, 10,12,16,24.
 The higher resolution ADC provides higher step size
Eng:Mohamed Loay Ali
17
ADC
1)Introduction to ADC
Some Major Characteristics of ADC:
Relation between Vin and Vref
Eng:Mohamed Loay Ali
18
ADC
1)Introduction to ADC
Some Major Characteristics of ADC:
Relation between Vin and Vref
Eng:Mohamed Loay Ali
19
CONVERSION TIME:
 Is defined as the time it takes the ADC to convert the analogue signal to the
digital signal.
 The conversion time is dictated by the clock source connected to the ADC in
addition the method used for data conversion and technology in fabrication
(TTL or MOS).
DIGITAL DATA OUTPUT:
 In 8 bit-ADC there is 8-bit digital data output of (D0-D7) while in 10 bit the
data output (D0-D9).
 To calculate the output voltage the following formula is used .
ADC
1)Introduction to ADC
Where Dout=digital data input in decimal and Vin=analogue input voltage.
Eng:Mohamed Loay Ali
20
ADC
1)Introduction to ADC
Eng:Mohamed Loay Ali
21
ADC
2)ADC Features in AVR
Eng:Mohamed Loay Ali
22
ADC
2)ADC Features in AVR
Eng:Mohamed Loay Ali
23
 The ATmega4328P features a 10-bit successive approximation ADC.
 The ADC is connected to an 8-channel Analog multiplexer which allows
eight single-ended voltage inputs constructed from the pins of Port A.
 The ADC contains a Sample and Hold circuit which ensures that the input
voltage to the ADC is held at a constant level during conversion.
ADC
2)ADC Features in AVR
Eng:Mohamed Loay Ali
24
ADC
2)ADC Features in AVR
Typical Connection to get the maximum accuracy
Eng:Mohamed Loay Ali
25
 By default, the successive approximation circuitry requires an input clock
frequency between 50kHz and 200kHz to get maximum resolution.
 The ADC module contains a prescaler, which generates an acceptable ADC clock
frequency from any CPU frequency above 100kHz
 The actual sample-and-hold takes place 1.5 ADC clock cycles after the start of a
normal conversion and 13.5 ADC clock cycles after the start of an first conversion.
ADC
2)ADC Features in AVR
Eng:Mohamed Loay Ali
26
ADC
3)Registers
ADLAR: ADC Left Adjust Result
Eng:Mohamed Loay Ali
27
ADC
3)Registers
Eng:Mohamed Loay Ali
28
ADC
3)Registers
Eng:Mohamed Loay Ali
29
ADC
3)Registers
Eng:Mohamed Loay Ali
30
ADEN: ADC Enable Writing this bit to one enables the ADC. By writing it to
zero, the ADC is turned off.
ADSC: ADC Start Conversion In Single Conversion mode, write this bit to one
to start each conversion and will be cleared by hardware when the conversion is
completed.
ADATE: ADC Auto Trigger Enable .When this bit is written to one, Auto
Triggering of the ADC is enabled.
ADIF: ADC Interrupt Flag .This bit is set when an ADC conversion completes
and the Data Registers are updated.
ADIE: ADC Interrupt Enable .When this bit is written to one and the I-bit in
SREG is set, the ADC Conversion Complete Interrupt is activated.
ADPS[2:0]: ADC Prescaler Select Bits .These bits determine the division factor
between the system clock frequency and the input clock to the ADC
ADC
3)Registers
Eng:Mohamed Loay Ali
31
ADC
3)Registers
By default, the successive approximation circuitry requires an input clock
frequency between 50kHz and 200kHz to get maximum resolution. If a lower
resolution than 10 bits is needed, the input clock frequency to the ADC can be
higher than 200kHz to get a higher sample rate.
Eng:Mohamed Loay Ali
32
ADC
3)Registers
Eng:Mohamed Loay Ali
33
ADC
3)Registers
 The ADC is enabled by setting the ADC Enable bit, ADEN in ADCSRA.
Voltage reference and input channel selections will not go into effect until
ADEN is set.
 The ADC generates a 10-bit result which is presented in the ADC Data
Registers, ADCH and ADCL. By default, the result is presented right
adjusted, but can optionally be presented left adjusted by setting the
ADLAR bit in ADMUX.
 If the result is left adjusted and no more than 8-bit precision is required, it
is sufficient to read ADCH. Otherwise, ADCL must be read first, then
ADCH, to ensure that the content of the Data Registers belongs to the
same conversion.
Eng:Mohamed Loay Ali
34
ADC
3)Registers
Eng:Mohamed Loay Ali
35
ADC
3)Registers
Bit 2:0 – ADTS[2:0]: ADC Auto Trigger Source
If ADATE in ADCSRA is written to one, the value of these bits selects which source
will trigger an ADC conversion. If ADATE is cleared, the ADTS[2:0] settings will
have no effect. A conversion will be triggered by the rising edge of the selected
Interrupt Flag. Note that switching from a trigger source that is cleared to a trigger
source that is set, will generate a positive edge on the trigger signal.
Bit 5:0 – ADC5D...ADC0D: ADC5...0 Digital Input Disable
When this bit is written logic one, the digital input buffer on the corresponding ADC
pin is disabled. The corresponding PIN Register bit will always read as zero when
this bit is set. When an analog signal is applied to the ADC5...0 pin and the digital
input from this pin is not needed, this bit should be written logic one to reduce
power consumption in the digital input buffer.
Eng:Mohamed Loay Ali
36
ADC
4)Programming in C:
Polling method:
To program the AVR ADC using the concepts of polling the following steps
should be taken:
1) Make the ADC channel as an input.
2) Turn the ADC module on and set the prescalar from ADCSRA register.
3) Set the Vref from REFS0:1 bits and ADC input channel from MUX4:0 bits,
both in ADMUX register.
4) Activate the start conversion by (1<<ADSC) on ADCSRA register and wait.
5) Wait the conversion to complete by polling ADIF in ADCSRA register.
6) When ADIF goes high read (ADCL,ADCH).Remember to read ADCL first
otherwise the result will be wrong.
See the ADC polling example
Eng:Mohamed Loay Ali
37
ADC
4)Programming in C:
Interrupt method:
Same steps of polling but the ADIF won’t be used ,instead the ADIE for interrupt
flag register will be used.
See the ADC interrupt example.
Eng:Mohamed Loay Ali
38

More Related Content

What's hot

PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mappingOsaMa Hasan
 
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLERGSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLERMd. Moktarul Islam
 
Programming with PIC microcontroller
Programming with PIC microcontroller Programming with PIC microcontroller
Programming with PIC microcontroller Raghav Shetty
 
GPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cGPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cZakaria Gomaa
 
174085193 pic-prgm-manual
174085193 pic-prgm-manual174085193 pic-prgm-manual
174085193 pic-prgm-manualArun Shan
 
AVR Micro controller Interfacing
AVR Micro controller Interfacing AVR Micro controller Interfacing
AVR Micro controller Interfacing Raghav Shetty
 
Arm7 document
Arm7  documentArm7  document
Arm7 documentN Harisha
 
Arm cortex (lpc 2148) based motor speed
Arm cortex (lpc 2148) based motor speedArm cortex (lpc 2148) based motor speed
Arm cortex (lpc 2148) based motor speedUday Wankar
 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]gauravholani
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC MicrocontrollersPremier Farnell
 
Microcontroller Instruction Set atmel
Microcontroller Instruction Set atmelMicrocontroller Instruction Set atmel
Microcontroller Instruction Set atmelRuderocker Billy
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC MicrocontrollerDivya Bansal
 
Features of ATMEL microcontrollers
Features of ATMEL microcontrollersFeatures of ATMEL microcontrollers
Features of ATMEL microcontrollersSuraj Shandilya
 
Programming pic microcontrollers
Programming pic microcontrollersProgramming pic microcontrollers
Programming pic microcontrollersMAIYO JOSPHAT
 
PIC16F877A interfacing with LCD
PIC16F877A interfacing with LCDPIC16F877A interfacing with LCD
PIC16F877A interfacing with LCDsunil polo
 

What's hot (20)

PIC introduction + mapping
PIC introduction + mappingPIC introduction + mapping
PIC introduction + mapping
 
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLERGSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
GSM 1308 MODEM CONTROL USING PIC-16F877A MICROCONTROLLER
 
Programming with PIC microcontroller
Programming with PIC microcontroller Programming with PIC microcontroller
Programming with PIC microcontroller
 
GPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-cGPIO In Arm cortex-m4 tiva-c
GPIO In Arm cortex-m4 tiva-c
 
174085193 pic-prgm-manual
174085193 pic-prgm-manual174085193 pic-prgm-manual
174085193 pic-prgm-manual
 
ATmega 16
ATmega 16ATmega 16
ATmega 16
 
AVR Micro controller Interfacing
AVR Micro controller Interfacing AVR Micro controller Interfacing
AVR Micro controller Interfacing
 
Arm7 document
Arm7  documentArm7  document
Arm7 document
 
PIC Microcontrollers
PIC MicrocontrollersPIC Microcontrollers
PIC Microcontrollers
 
Arm cortex (lpc 2148) based motor speed
Arm cortex (lpc 2148) based motor speedArm cortex (lpc 2148) based motor speed
Arm cortex (lpc 2148) based motor speed
 
Dio
DioDio
Dio
 
Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]Pic microcontroller [autosaved] [autosaved]
Pic microcontroller [autosaved] [autosaved]
 
8-bit PIC Microcontrollers
8-bit PIC Microcontrollers8-bit PIC Microcontrollers
8-bit PIC Microcontrollers
 
Microcontroller Instruction Set atmel
Microcontroller Instruction Set atmelMicrocontroller Instruction Set atmel
Microcontroller Instruction Set atmel
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontroller
 
Features of ATMEL microcontrollers
Features of ATMEL microcontrollersFeatures of ATMEL microcontrollers
Features of ATMEL microcontrollers
 
Programming pic microcontrollers
Programming pic microcontrollersProgramming pic microcontrollers
Programming pic microcontrollers
 
Interfacing using ِAtmega16/32
Interfacing using ِAtmega16/32 Interfacing using ِAtmega16/32
Interfacing using ِAtmega16/32
 
89c5131datasheet
89c5131datasheet89c5131datasheet
89c5131datasheet
 
PIC16F877A interfacing with LCD
PIC16F877A interfacing with LCDPIC16F877A interfacing with LCD
PIC16F877A interfacing with LCD
 

Viewers also liked

AVR_Course_Day2 what is pcb
AVR_Course_Day2 what is pcbAVR_Course_Day2 what is pcb
AVR_Course_Day2 what is pcbMohamed Ali
 
AVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronicsAVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronicsMohamed Ali
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programmingMohamed Ali
 
AVR_Course_Day8 motor drive and pwm techniques
AVR_Course_Day8 motor drive and pwm techniquesAVR_Course_Day8 motor drive and pwm techniques
AVR_Course_Day8 motor drive and pwm techniquesMohamed Ali
 
DAC-digital to analog converter
DAC-digital to analog converterDAC-digital to analog converter
DAC-digital to analog converterShazid Reaj
 
Diagonalization Linear Algebra Notes
Diagonalization Linear Algebra NotesDiagonalization Linear Algebra Notes
Diagonalization Linear Algebra NotesArunkumar Gowdru
 
Optical fiber communication (Unit 5) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 5) notes written by Spoorti Arun Kumar (AP,...Optical fiber communication (Unit 5) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 5) notes written by Spoorti Arun Kumar (AP,...Arunkumar Gowdru
 
Amvdd Data Converter Fundamentals
Amvdd Data Converter FundamentalsAmvdd Data Converter Fundamentals
Amvdd Data Converter FundamentalsNiket Chandrashekar
 
Optical fiber communication (Unit 1) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 1) notes written by Spoorti Arun Kumar (AP,...Optical fiber communication (Unit 1) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 1) notes written by Spoorti Arun Kumar (AP,...Arunkumar Gowdru
 
Linear IC's & Application Notes
Linear IC's & Application NotesLinear IC's & Application Notes
Linear IC's & Application NotesArunkumar Gowdru
 
APRS - the amateur radio tracking system
APRS - the amateur radio tracking system APRS - the amateur radio tracking system
APRS - the amateur radio tracking system FSCONS
 
Complete Overview of MESH for Amateur Radio (Updated Nov. 2014)
Complete Overview of MESH for Amateur Radio (Updated Nov. 2014)Complete Overview of MESH for Amateur Radio (Updated Nov. 2014)
Complete Overview of MESH for Amateur Radio (Updated Nov. 2014)va3bco
 
Optical fiber communication (Unit 6) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 6) notes written by Spoorti Arun Kumar (AP,...Optical fiber communication (Unit 6) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 6) notes written by Spoorti Arun Kumar (AP,...Arunkumar Gowdru
 
An innovative introductory course to systems engineering teaching.pptx
An innovative introductory course to systems engineering teaching.pptxAn innovative introductory course to systems engineering teaching.pptx
An innovative introductory course to systems engineering teaching.pptxJoseph KAsser
 
Power Electronics Notes written by Arun Kumar G, Associate Professor, Dept. o...
Power Electronics Notes written by Arun Kumar G, Associate Professor, Dept. o...Power Electronics Notes written by Arun Kumar G, Associate Professor, Dept. o...
Power Electronics Notes written by Arun Kumar G, Associate Professor, Dept. o...Arunkumar Gowdru
 
Kasser synergy amateur radio
Kasser synergy   amateur radioKasser synergy   amateur radio
Kasser synergy amateur radioJoseph KAsser
 
Analog electronics Circuits Notes written by Arun Kumar G, Associate Professo...
Analog electronics Circuits Notes written by Arun Kumar G, Associate Professo...Analog electronics Circuits Notes written by Arun Kumar G, Associate Professo...
Analog electronics Circuits Notes written by Arun Kumar G, Associate Professo...Arunkumar Gowdru
 
04 Interfacing LCD Displays.2016
04 Interfacing LCD Displays.201604 Interfacing LCD Displays.2016
04 Interfacing LCD Displays.2016Mohamed Fawzy
 

Viewers also liked (20)

AVR_Course_Day2 what is pcb
AVR_Course_Day2 what is pcbAVR_Course_Day2 what is pcb
AVR_Course_Day2 what is pcb
 
AVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronicsAVR_Course_Day1 basic electronics
AVR_Course_Day1 basic electronics
 
AVR_Course_Day7 timers counters and interrupt programming
AVR_Course_Day7 timers counters and  interrupt programmingAVR_Course_Day7 timers counters and  interrupt programming
AVR_Course_Day7 timers counters and interrupt programming
 
AVR_Course_Day8 motor drive and pwm techniques
AVR_Course_Day8 motor drive and pwm techniquesAVR_Course_Day8 motor drive and pwm techniques
AVR_Course_Day8 motor drive and pwm techniques
 
BASIC ELECTRONICS
BASIC ELECTRONICS BASIC ELECTRONICS
BASIC ELECTRONICS
 
DAC-digital to analog converter
DAC-digital to analog converterDAC-digital to analog converter
DAC-digital to analog converter
 
Electronics ppt
Electronics ppt Electronics ppt
Electronics ppt
 
Diagonalization Linear Algebra Notes
Diagonalization Linear Algebra NotesDiagonalization Linear Algebra Notes
Diagonalization Linear Algebra Notes
 
Optical fiber communication (Unit 5) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 5) notes written by Spoorti Arun Kumar (AP,...Optical fiber communication (Unit 5) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 5) notes written by Spoorti Arun Kumar (AP,...
 
Amvdd Data Converter Fundamentals
Amvdd Data Converter FundamentalsAmvdd Data Converter Fundamentals
Amvdd Data Converter Fundamentals
 
Optical fiber communication (Unit 1) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 1) notes written by Spoorti Arun Kumar (AP,...Optical fiber communication (Unit 1) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 1) notes written by Spoorti Arun Kumar (AP,...
 
Linear IC's & Application Notes
Linear IC's & Application NotesLinear IC's & Application Notes
Linear IC's & Application Notes
 
APRS - the amateur radio tracking system
APRS - the amateur radio tracking system APRS - the amateur radio tracking system
APRS - the amateur radio tracking system
 
Complete Overview of MESH for Amateur Radio (Updated Nov. 2014)
Complete Overview of MESH for Amateur Radio (Updated Nov. 2014)Complete Overview of MESH for Amateur Radio (Updated Nov. 2014)
Complete Overview of MESH for Amateur Radio (Updated Nov. 2014)
 
Optical fiber communication (Unit 6) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 6) notes written by Spoorti Arun Kumar (AP,...Optical fiber communication (Unit 6) notes written by Spoorti Arun Kumar (AP,...
Optical fiber communication (Unit 6) notes written by Spoorti Arun Kumar (AP,...
 
An innovative introductory course to systems engineering teaching.pptx
An innovative introductory course to systems engineering teaching.pptxAn innovative introductory course to systems engineering teaching.pptx
An innovative introductory course to systems engineering teaching.pptx
 
Power Electronics Notes written by Arun Kumar G, Associate Professor, Dept. o...
Power Electronics Notes written by Arun Kumar G, Associate Professor, Dept. o...Power Electronics Notes written by Arun Kumar G, Associate Professor, Dept. o...
Power Electronics Notes written by Arun Kumar G, Associate Professor, Dept. o...
 
Kasser synergy amateur radio
Kasser synergy   amateur radioKasser synergy   amateur radio
Kasser synergy amateur radio
 
Analog electronics Circuits Notes written by Arun Kumar G, Associate Professo...
Analog electronics Circuits Notes written by Arun Kumar G, Associate Professo...Analog electronics Circuits Notes written by Arun Kumar G, Associate Professo...
Analog electronics Circuits Notes written by Arun Kumar G, Associate Professo...
 
04 Interfacing LCD Displays.2016
04 Interfacing LCD Displays.201604 Interfacing LCD Displays.2016
04 Interfacing LCD Displays.2016
 

Similar to AVR_Course_Day6 external hardware interrupts and analogue to digital converter

Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Omkar Rane
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and RoboticsNIT Raipur
 
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERDIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERChirag Lakhani
 
digitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdfdigitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdfsatyamsinha37
 
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
UNIT 4 & 5 - I         nterfacing_Lecture7.pptxUNIT 4 & 5 - I         nterfacing_Lecture7.pptx
UNIT 4 & 5 - I nterfacing_Lecture7.pptxnaveen088888
 
Analog to Digital Converters
Analog to Digital ConvertersAnalog to Digital Converters
Analog to Digital ConvertersAmitabh Shukla
 
ADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfVikasMahor3
 
Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]Guhan k
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converterCorrado Santoro
 
Analog to Digital converter in ARM
Analog to Digital converter in ARMAnalog to Digital converter in ARM
Analog to Digital converter in ARMAarav Soni
 
Mc module5 lcd_interface_ppt_msj
Mc module5 lcd_interface_ppt_msjMc module5 lcd_interface_ppt_msj
Mc module5 lcd_interface_ppt_msjmangala jolad
 
Microcontroller
MicrocontrollerMicrocontroller
MicrocontrollerSpitiq
 
1 PageAlarm Clock Design Using PIC18F45E.docx
1  PageAlarm Clock Design Using PIC18F45E.docx1  PageAlarm Clock Design Using PIC18F45E.docx
1 PageAlarm Clock Design Using PIC18F45E.docxmercysuttle
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsPallavi Bharti
 

Similar to AVR_Course_Day6 external hardware interrupts and analogue to digital converter (20)

Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148
 
Training Report on embedded Systems and Robotics
Training Report on embedded  Systems and RoboticsTraining Report on embedded  Systems and Robotics
Training Report on embedded Systems and Robotics
 
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLERDIGITAL VOLTMETER USING 8051 MICROCONTROLLER
DIGITAL VOLTMETER USING 8051 MICROCONTROLLER
 
digitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdfdigitalvoltmeterusing805112b2-170214173216 (1).pdf
digitalvoltmeterusing805112b2-170214173216 (1).pdf
 
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
UNIT 4 & 5 - I         nterfacing_Lecture7.pptxUNIT 4 & 5 - I         nterfacing_Lecture7.pptx
UNIT 4 & 5 - I nterfacing_Lecture7.pptx
 
Analog to Digital Converters
Analog to Digital ConvertersAnalog to Digital Converters
Analog to Digital Converters
 
ADC and DAC interfacing.pdf
ADC and DAC interfacing.pdfADC and DAC interfacing.pdf
ADC and DAC interfacing.pdf
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]Interfacing technique with 8085- ADC[0808]
Interfacing technique with 8085- ADC[0808]
 
Analog to digital converter
Analog to digital converterAnalog to digital converter
Analog to digital converter
 
Analog to Digital converter in ARM
Analog to Digital converter in ARMAnalog to Digital converter in ARM
Analog to Digital converter in ARM
 
Módulo adc 18f4550
Módulo adc   18f4550Módulo adc   18f4550
Módulo adc 18f4550
 
A 1.2V 10-bit 165MSPS Video ADC
A 1.2V 10-bit 165MSPS Video ADCA 1.2V 10-bit 165MSPS Video ADC
A 1.2V 10-bit 165MSPS Video ADC
 
Microcontroller part 3
Microcontroller part 3Microcontroller part 3
Microcontroller part 3
 
Mc module5 lcd_interface_ppt_msj
Mc module5 lcd_interface_ppt_msjMc module5 lcd_interface_ppt_msj
Mc module5 lcd_interface_ppt_msj
 
Chapter5 dek3133
Chapter5 dek3133Chapter5 dek3133
Chapter5 dek3133
 
Microcontroller
MicrocontrollerMicrocontroller
Microcontroller
 
digital clock atmega16
digital clock atmega16digital clock atmega16
digital clock atmega16
 
1 PageAlarm Clock Design Using PIC18F45E.docx
1  PageAlarm Clock Design Using PIC18F45E.docx1  PageAlarm Clock Design Using PIC18F45E.docx
1 PageAlarm Clock Design Using PIC18F45E.docx
 
Industrial training report of embedded system and robotics
Industrial training report of embedded system and roboticsIndustrial training report of embedded system and robotics
Industrial training report of embedded system and robotics
 

Recently uploaded

Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Recently uploaded (20)

9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 

AVR_Course_Day6 external hardware interrupts and analogue to digital converter

  • 1. External Hardware Interrupts and Analogue to digital Converter Eng:Mohamed Loay Ali 1
  • 2. Contents  External Hardware Interrupt. 1. Introduction 2. Registers. 3. Programming in C. 4. External Interrupt priority (Vector table).  Analogue to Digital Converter ADC. 1. Introduction 2. ADC Features in AVR 3. Registers 4. Programming in C 5. LDR. 6. Temperature Sensor LM35. Eng:Mohamed Loay Ali 2
  • 3. External Hardware Interrupt Enabling the Interrupts: To enable the interrupt is should be unmasked as shown in the following figure.  SREG is the Status register ,to enable the interrupt (unmask the interrupt) the bit D7(I) should be activated using sei() set interrupt then use TMISK register to enable interrupts of Timer (0 or 1 or 2)this will covered later.  To disable the interrupt the bit D7(I) should be cleared by cli()clear the interrupt. Eng:Mohamed Loay Ali 3
  • 4. External Hardware Interrupt  The External Interrupts are triggered by the INT0 and INT1 pins or any of the PCINT23...0 pins.  Observe that, if enabled, the interrupts will trigger even if the INT0 and INT1or PCINT23...0 pins are configured as outputs.  The INT0 and INT1 interrupts can be triggered by a falling or rising edge or a low level.  The other pins interrupts can be triggered by toggling the pins. 1.Introduction Eng:Mohamed Loay Ali 4
  • 8. External Hardware Interrupt 2.Registers When an edge or logic change on the INT1or 2 pin triggers an interrupt request, INTF1 or 2 becomes set (one). If the I-bit in SREG and the INT1 or 2 bit in EIMSK are set (one), the MCU will jump to the corresponding Interrupt Vector. Eng:Mohamed Loay Ali 8
  • 9. External Hardware Interrupt 2.Registers Bit 2 – PCIE2: Pin Change Interrupt Enable 2 Any change on any enabled PCINT[23:16] pin will cause an interrupt. Bit 1 – PCIE1: Pin Change Interrupt Enable 1 Any change on any enabled PCINT[14:8] pin will cause an interrupt. Bit 0 – PCIE0: Pin Change Interrupt Enable 0 Any change on any enabled PCINT[7:0] pin will cause an interrupt These interrupts can be triggered only if the bits is enabled and the I-bit in the Status Register (SREG) is set (one). Eng:Mohamed Loay Ali 9
  • 11. External Hardware Interrupt 4)External Interrupt priority (Vector table) See external interrupt priority example. Eng:Mohamed Loay Ali 11
  • 12. External Hardware Interrupt 3.Progarmming in C See the following Examples 1)External interrupt example 1 2)External interrupt example 2 Eng:Mohamed Loay Ali 12
  • 13. ADC 1)Introduction to ADC ADC devices:  ADC are widely used in data acquisition systems.  Digital systems use binary (discrete) values , but in the physical world every is thing is analogue (Continuous).  Therefore the ADC is required to convert the analogue signal (continuous) to digital signal (discrete) so the microcontroller can read and process the data.  The physical quantity such as (Pressure , Temperature and velocity ) are converted to electrical signal (Volt or Current) through sensor or tranducer then fed into the ADC. Eng:Mohamed Loay Ali 13
  • 14. ADC 1)Introduction to ADC Difference Between Analogue Signal and Digital Signal Eng:Mohamed Loay Ali 14
  • 15. ADC 1)Introduction to ADC The Discretization of the signals: Eng:Mohamed Loay Ali 15
  • 16. ADC 1)Introduction to ADC The Procedure of taking a signal from real world to Digital System Controller Eng:Mohamed Loay Ali 16
  • 17. ADC 1)Introduction to ADC Some Major Characteristics of ADC: RESOLUTION:  Is the smallest change that can be discerned by an ADC.  The ADC has n-bit, where n can be 8, 10,12,16,24.  The higher resolution ADC provides higher step size Eng:Mohamed Loay Ali 17
  • 18. ADC 1)Introduction to ADC Some Major Characteristics of ADC: Relation between Vin and Vref Eng:Mohamed Loay Ali 18
  • 19. ADC 1)Introduction to ADC Some Major Characteristics of ADC: Relation between Vin and Vref Eng:Mohamed Loay Ali 19
  • 20. CONVERSION TIME:  Is defined as the time it takes the ADC to convert the analogue signal to the digital signal.  The conversion time is dictated by the clock source connected to the ADC in addition the method used for data conversion and technology in fabrication (TTL or MOS). DIGITAL DATA OUTPUT:  In 8 bit-ADC there is 8-bit digital data output of (D0-D7) while in 10 bit the data output (D0-D9).  To calculate the output voltage the following formula is used . ADC 1)Introduction to ADC Where Dout=digital data input in decimal and Vin=analogue input voltage. Eng:Mohamed Loay Ali 20
  • 22. ADC 2)ADC Features in AVR Eng:Mohamed Loay Ali 22
  • 23. ADC 2)ADC Features in AVR Eng:Mohamed Loay Ali 23
  • 24.  The ATmega4328P features a 10-bit successive approximation ADC.  The ADC is connected to an 8-channel Analog multiplexer which allows eight single-ended voltage inputs constructed from the pins of Port A.  The ADC contains a Sample and Hold circuit which ensures that the input voltage to the ADC is held at a constant level during conversion. ADC 2)ADC Features in AVR Eng:Mohamed Loay Ali 24
  • 25. ADC 2)ADC Features in AVR Typical Connection to get the maximum accuracy Eng:Mohamed Loay Ali 25
  • 26.  By default, the successive approximation circuitry requires an input clock frequency between 50kHz and 200kHz to get maximum resolution.  The ADC module contains a prescaler, which generates an acceptable ADC clock frequency from any CPU frequency above 100kHz  The actual sample-and-hold takes place 1.5 ADC clock cycles after the start of a normal conversion and 13.5 ADC clock cycles after the start of an first conversion. ADC 2)ADC Features in AVR Eng:Mohamed Loay Ali 26
  • 27. ADC 3)Registers ADLAR: ADC Left Adjust Result Eng:Mohamed Loay Ali 27
  • 31. ADEN: ADC Enable Writing this bit to one enables the ADC. By writing it to zero, the ADC is turned off. ADSC: ADC Start Conversion In Single Conversion mode, write this bit to one to start each conversion and will be cleared by hardware when the conversion is completed. ADATE: ADC Auto Trigger Enable .When this bit is written to one, Auto Triggering of the ADC is enabled. ADIF: ADC Interrupt Flag .This bit is set when an ADC conversion completes and the Data Registers are updated. ADIE: ADC Interrupt Enable .When this bit is written to one and the I-bit in SREG is set, the ADC Conversion Complete Interrupt is activated. ADPS[2:0]: ADC Prescaler Select Bits .These bits determine the division factor between the system clock frequency and the input clock to the ADC ADC 3)Registers Eng:Mohamed Loay Ali 31
  • 32. ADC 3)Registers By default, the successive approximation circuitry requires an input clock frequency between 50kHz and 200kHz to get maximum resolution. If a lower resolution than 10 bits is needed, the input clock frequency to the ADC can be higher than 200kHz to get a higher sample rate. Eng:Mohamed Loay Ali 32
  • 34. ADC 3)Registers  The ADC is enabled by setting the ADC Enable bit, ADEN in ADCSRA. Voltage reference and input channel selections will not go into effect until ADEN is set.  The ADC generates a 10-bit result which is presented in the ADC Data Registers, ADCH and ADCL. By default, the result is presented right adjusted, but can optionally be presented left adjusted by setting the ADLAR bit in ADMUX.  If the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read ADCH. Otherwise, ADCL must be read first, then ADCH, to ensure that the content of the Data Registers belongs to the same conversion. Eng:Mohamed Loay Ali 34
  • 36. ADC 3)Registers Bit 2:0 – ADTS[2:0]: ADC Auto Trigger Source If ADATE in ADCSRA is written to one, the value of these bits selects which source will trigger an ADC conversion. If ADATE is cleared, the ADTS[2:0] settings will have no effect. A conversion will be triggered by the rising edge of the selected Interrupt Flag. Note that switching from a trigger source that is cleared to a trigger source that is set, will generate a positive edge on the trigger signal. Bit 5:0 – ADC5D...ADC0D: ADC5...0 Digital Input Disable When this bit is written logic one, the digital input buffer on the corresponding ADC pin is disabled. The corresponding PIN Register bit will always read as zero when this bit is set. When an analog signal is applied to the ADC5...0 pin and the digital input from this pin is not needed, this bit should be written logic one to reduce power consumption in the digital input buffer. Eng:Mohamed Loay Ali 36
  • 37. ADC 4)Programming in C: Polling method: To program the AVR ADC using the concepts of polling the following steps should be taken: 1) Make the ADC channel as an input. 2) Turn the ADC module on and set the prescalar from ADCSRA register. 3) Set the Vref from REFS0:1 bits and ADC input channel from MUX4:0 bits, both in ADMUX register. 4) Activate the start conversion by (1<<ADSC) on ADCSRA register and wait. 5) Wait the conversion to complete by polling ADIF in ADCSRA register. 6) When ADIF goes high read (ADCL,ADCH).Remember to read ADCL first otherwise the result will be wrong. See the ADC polling example Eng:Mohamed Loay Ali 37
  • 38. ADC 4)Programming in C: Interrupt method: Same steps of polling but the ADIF won’t be used ,instead the ADIE for interrupt flag register will be used. See the ADC interrupt example. Eng:Mohamed Loay Ali 38