43.6.2 Channel Sequencer

The channel sequencer automatically performs the operations defined by each channel context. The channel sequencer is enabled when the Context Scan Enable (CSEN) bit is set (CSEN = 1), and the scan sequence is executed when the GO bit is set by software or by the reception of an auto-conversion trigger.
The sequence includes all channel contexts that are enabled via the context’s Channel Scan Enable (CHEN) bit. A context channel is included in the scan sequence when the CHEN bit is set (CHEN = 1). If all context channels’ CHEN bits are clear (CHEN = 0), the GO bit is immediately cleared and no conversions or interrupts will occur.
A sequence always begins with Context 1, as long as its CHEN bit is enabled. If Context 1’s CONT bit is set (CONT = 1), the sequencer will scan Context 1 and continue scanning until the threshold test invokes the ADC Channel Threshold Interrupt flag (ADCHxIF). If the ADC Stop On Interrupt (SOI) bit is set (SOI = 1) and the channel threshold interrupt occurs, the scanner will proceed to check Context 1’s ADC Scan Stop On Interrupt (SSI) bit to determine whether to proceed to the next channel context. If SSI is set (SSI = 1), the scanner will clear the GO bit and the scanner will stop. If the SSI bit is clear (SSI = 0), the scanner proceeds to the next channel context that has the CHEN bit set.
If Context 1’s CONT bit is set, the SOI bit is clear (SOI = 0) and the scanner will repeatedly scan Context 1 until software clears the GO bit.
Important: If a context’s CONT bit is set and both the SOI and SSI bits are clear, the scanner will repeatedly scan that context indefinitely without scanning any further channels.
If Context 1’s CONT bit is clear (CONT = 0), the sequencer will scan Context 1, and when the conversion completes, the channel threshold test is performed. If ADCH1IF is set, the sequencer checks Context 1’s SSI bit to determine whether to proceed to the next channel context. If SSI is set, the sequencer clears GO and the scanner stops. If the SSI bit is clear, the sequencer will proceed to the next channel that has the CHEN bit set.
Important: When the CONT bit is clear, the SOI bit is ignored.
The scan sequence ends when any context’s channel threshold interrupt occurs and that context’s SSI bit is set. If the sequencer has scanned all enabled channels and no interrupt occurs or no context’s SSI bit is set, the sequencer will return to Context 1 (or the first enabled channel context) and repeat the scanning process until software clears the GO bit.
Important: The final channel in a sequence need to set the Threshold Interrupt Mode Select (TMD) bits to “Interrupt regardless of the threshold test results” (TMD = 111) and set the SSI bit. These settings allow the scanner to stop after the scan sequence has completed.

The figure below illustrates the operation of the channel sequencer.

Figure 43-11. Channel Sequencer Operation
Note:
  1. If all channels are disabled (ADCSEL[1..4].CHEN = 0), the scanner stops, but the GO bit remains set. No interrupts will occur. If software relies on a hardware clear of GO to continue code execution, the program will stall indefinitely.
  2. ADC computation modes (Average, Burst Average, etc.) are included in the ‘Perform ADC Operation’ block.