This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

AT89C51CC03 : 10-Bit ADC Problems

Hello,

i have problems to get a 10-Bit result from the internal adc of the AT89C51CC03.

I always got only a 8-Bit result, though setting the PSIDLE-Bit.
Also i did not need the adc-eoc-interrupt to continue after the conversion,
as it is explained in the device manual.

So it seems to me, i made something wrong in setting up the adc for 10-Bit resolution.

I include the following code, which should not run with disabled eoc-interrupt.
But it runs !!!

#include "AT89C51CC03.h"
unsigned int i;
void main(void)
{
        ADCF = 0x20;  /* configure channel P1.5(AN5) for ADC */
        ADCLK = 0x00;  /* init prescaler for adc clock */
        ADCON = 0x20;  /* Enable the ADC */

        EA = 0;  /* disable interrupts */
        EADC = 0;

        P31 = 1;   // signal running via txd pin
        for (i=0; i< 20000; i++);

        while(1)
        {
                ADCON &= ~0x07;  /* Clear the channel field ADCON[2:0] */
                ADCON |= 0x05;   /* Select channel 5 */
                ADCON |= 0x40;   /* 10 bit mode */
                ADCON |= 0x08;   /* Start conversion */

                P31 = ~P31;       // signal running via txd pin
                while (!(ADCON & 0x10));
                ADCON &= 0xef;
                for (i=0; i< 20000; i++);

        }
}

So please contact me, if you have any ideas, hints, solutions, etc.

Parents
  • The accuracy of the ADC value either 8bit or 10bit is affected by the hardware conditions on this specific board you use.

    VSS as GND should be solid.
    VCC as Supply Voltage properly distributed on the board.
    VAREF Reference Voltage for ADC should be obtained from a stabilized source neutral to drifts.
    VAGND Reference Ground properly connected on pcb from the analog section to digital section.
    Power Supply with very small ripple and maximum noise rejection.
    Board construction for better results have to be built with 4 layers.
    Noisy signal path should be avoided.
    Undesired capacitance on signal probes.

    1 bit at VAREF 2.5V 10 bit resolution means 2,44mV
    3 bit means 19.5mV span

    Precision is different from Resolution.

    To overome the lower bits change you can oversample the desired signal eg for 32 times and then shift right 5 times the added measurements (or divide by 32).
    Another typical use is to construct a low pass digital filter using 5 integers to store the intermediate results.
    and so on ...

Reply
  • The accuracy of the ADC value either 8bit or 10bit is affected by the hardware conditions on this specific board you use.

    VSS as GND should be solid.
    VCC as Supply Voltage properly distributed on the board.
    VAREF Reference Voltage for ADC should be obtained from a stabilized source neutral to drifts.
    VAGND Reference Ground properly connected on pcb from the analog section to digital section.
    Power Supply with very small ripple and maximum noise rejection.
    Board construction for better results have to be built with 4 layers.
    Noisy signal path should be avoided.
    Undesired capacitance on signal probes.

    1 bit at VAREF 2.5V 10 bit resolution means 2,44mV
    3 bit means 19.5mV span

    Precision is different from Resolution.

    To overome the lower bits change you can oversample the desired signal eg for 32 times and then shift right 5 times the added measurements (or divide by 32).
    Another typical use is to construct a low pass digital filter using 5 integers to store the intermediate results.
    and so on ...

Children