2.1.2 Free Running mode
Task: Free running conversion on ADC channel 0. Use of conversion complete interrupt.
In this program, the ADC module is initialized and runs in free running mode
in the adc_free_run_mode()
routine. As the ADC conversion complete
interrupt is enabled, the Interrupt Service Routine for this interrupt will be triggered
as soon as a conversion is completed. In Free Running mode, a new conversion will be
started immediately after a conversion completes. The ADSC bit remains high during a
conversion. The time between two consecutive ADC samples depends on the ADC conversion
time.
- Select ADC channel 0 by writing the Analog Channel Selection bit group in the ADC Multiplexer Selection register (ADMUX.MUX) to '0b0000'.
- Select internal reference to 1.1V by writing the Reference Selection bit in ADMUX (ADMUX.REFS0) to '0'.
- Enable the ADC module by writing the ADC Enable bit in the ADC Control and Status A register (ADCSRA.ADEN) to '1'.
- Select system clock prescaling to 16 by writing the ADC Prescaler Select bit group in ADCSRA (ADCSRA.ADPS) to '0b100'.
- Enable auto triggering by writing the ADC Auto Trigger Enable bit in ADCSRA (ADCSRA.ADATE) to '1'.
- Enable free running mode by writing the ADC Auto Trigger Source bit group in the ADC Control and Status B register (ADCSRB.ADTS) to '0b000'.
- Start the first conversion by writing the ADC Start Conversion bit in ADCSRA (ADCSRA.ADSC) to '1'.
- Optionally, wait for the Interrupt Flag bit in the ADCSRA register to be set, indicating that a new conversion is finished.
- After the conversion is over (ADIF bit becomes high) the CPU executes the ADC interrupt service routine where the ADC data register pair (ADCL/ADCH) is read to get the 10-bit ADC result.
Test Steps
Refer to Test Steps.