Post Go back to editing

ADC in continuous mode

Category: Datasheet/Specs
Product Number: ADuC832

How do I prevent reading wrong ADC results in continuous mode?

The result is updated in ADCDATAH and ADCDATAL independent of my coding reading the registers (in 2 mov instructions).

How can I be sure I'm not reading a high byte and a low byte that are from a different conversion?

  • Hi,

       May I know how you whether the input is desired one for measurement by ADC?

    Typically, after AFE switches and blocks are configured,

    ADC and its conversion are turned ON for a specific time period defined by waitclks. It expects input data to be valid during this period.

    At the end of waitclks, ADC is turned off. Input to ADC after waitclks are considered not required to be measured.

  • Hello,

    I know how to use the ADC in single conversion mode. This solves the issue when converting multiple channels.

    When only 1 channel needs to be converted continuous mode would result in lesser instructions needed (you don't need to restart the conversion and wait for it to finish every time a measurement is made).

    In continuous conversion mode, you have no idea what the converter is doing (when it is sampling/converting/updating the result).

    So you read the ADCDATAH and ADCDATAL registers asynchronous in relation to the ADC operation.

    There is no way of knowing in which fase of the conversion the ADC is.

    The issue is not that input voltage my vary (as it is sampled and arithmetic is used to obtain the desired result (e.g. averaging).

    The issue is that I want to avoid reading a wrong result as it is perfectly possible the ADCDATAH and ADCDATAL registers can be updated between readings by the ADC hardware.

    Somebody suggested to only use continuous mode with DMA.

  • Hello,

    I have no need for DMA.

    All I want to know is how I can reliably reed the ADCDATAH and ADCDATAL registers when the ADC is in continuous mode.

    Regards

  • Hi,

            That is what is mentioned in the documents shared above.

    To summarize here:

    For starting the conversion:

    - Either powering on ADC, or

    - Timer 2 conversion bit (T2C) in ADCCON1 or

    - external trigger

    is used as the ADC convert start trigger input. 

    ADC conversion time is set by ADCCON0[CK0, CK1]. A typical ADC conversion requires 17 ADC clocks.

    At the end of this period, ADC conversion gets completed. The ADC interrupt bit ADCI is set by hardware and ADCDATAH and ADCDATAL contain the new ADC conversion results.

    ADC automatically starts next conversion. 

  • Hello,

    If I understand you correctly:

    If I don't want to use DMA, there is no way continuous conversion can be used reliably, unless I

    would use interrupts, or poll the interrupt bit (and clear it) in software?

    But the above mentioned methods (using interrupt or software polling) don't offer any advantages to using single

    conversion.

    IF I can't read the ADC on the fly in continuous conversion mode, I have no use for it.

    So I'll just stick to single conversion.

    Regards

  • Hi,

      You can of course not read any register which is dynamically updated unless it is brought to stable state each time.

      The data written in ADCDATAH and ADCDATAL can be continuously read on DPRAM or a terminal, which is the purpose of DMA.