Single Conversion Mode

Task: Single Conversion on ADC channel 0

In this program the initialize() routine is used to initialize the ADC module. The convert() routine has to be called whenever the application needs an ADC conversion.

  1. 1.Set the MUX bit fields (MUX3:0) in ADC’s MUX register (ADMUX) equal to 0000 to select ADC Channel 0.
  2. 2.Set the ADC Enable bit (ADEN) in ADC Control and Status Register A (ADCSRA) to enable the ADC module.
  3. 3.Set the ADC Pre-scalar bit fields (ADPS2:0) in ADCSRA equal to 100 to prescale the system clock by 16.
  4. 4.Set the Voltage Reference bit fields (REFS1:0) in ADMUX equal to 11 to select Internal 1.1V reference.
  5. 5.Set the Start Conversion bit (ADSC) in ADCSRA to start a single conversion.
  6. 6.Poll (wait) for the Interrupt Flag (ADIF) bit in the ADCSRA register to be set, indicating that the conversion is completed.
  7. 7.After the ADIF bit becomes high, read the ADC data register pair (ADCL/ADCH) to get the 10-bit ADC result.