43.6.1.1 Channel Context Configuration

The following steps are used to configure channel context via the ADCTX register:

  1. Write the desired context number into the CTX bits; hardware automatically clears CTXSW.
  2. Configure all desired ADC registers (e.g., ADCON1, ADCON2, etc.).
  3. Repeat steps 1 and 2 until all channel contexts have been configured.
Remember: The context number is always one number greater than the value written into the CTX bits. For example, when the CTX bits are written with zero (CTX = 0), Context 1 is in view.

Once the context number has been written into the CTX bits, the selected channel context is available for software access. After each ADC register is configured, the register value is copied into the associated context register.

Data can also be read from the ADC’s data registers (ADFLTR, ADRES, etc.) using the same steps above. Rather than configuring the desired ADC registers in step 2, user software can instead read data from the desired data registers.

Warning: It is highly recommended to verify that the STAT bits of the ADSTAT register are clear (STAT = 0) before changing any context registers. Modifying context registers during an active conversion may lead to data corruption.