<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>AT89C51CC03 : 10-Bit ADC Problems</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/26958/at89c51cc03-10-bit-adc-problems</link><description> 
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</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: AT89C51CC03 : 10-Bit ADC Problems</title><link>https://community.arm.com/thread/84715?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2010 22:16:25 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:6dc2633c-6436-45f4-8d7e-b8716408068b</guid><dc:creator>Stefan Przybylski</dc:creator><description>&lt;p&gt;&lt;p&gt;
But i doesn&amp;#39;t see any difference in the result for 8Bit and 10Bit
conversion !&lt;/p&gt;

&lt;p&gt;
And the adc conversion for 10Bit runs also without the so called
required Interrupt ADC-EndOfConversion ! In the device manuals it
seems to be necesssary.&lt;/p&gt;

&lt;p&gt;
So i ask me what is wrong ?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AT89C51CC03 : 10-Bit ADC Problems</title><link>https://community.arm.com/thread/78681?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2010 12:56:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d6ca29fc-3013-4004-9459-ad2394ac3f0a</guid><dc:creator>ntino gr</dc:creator><description>&lt;p&gt;&lt;p&gt;
The accuracy of the ADC value either 8bit or 10bit is affected by
the hardware conditions on this specific board you use.&lt;/p&gt;

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

&lt;p&gt;
1 bit at VAREF 2.5V 10 bit resolution means 2,44mV&lt;br /&gt;
3 bit means 19.5mV span&lt;/p&gt;

&lt;p&gt;
Precision is different from Resolution.&lt;/p&gt;

&lt;p&gt;
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).&lt;br /&gt;
Another typical use is to construct a low pass digital filter using 5
integers to store the intermediate results.&lt;br /&gt;
and so on ...&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AT89C51CC03 : 10-Bit ADC Problems</title><link>https://community.arm.com/thread/90646?ContentTypeID=1</link><pubDate>Thu, 30 Sep 2010 04:00:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:90f5e063-7693-4678-8c77-fe4936e3e2e0</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;i tried your code, but i always got only an 8-Bit
result.&lt;/i&gt;&lt;br /&gt;
No. You appear to have somewhat strange ideas of what makes a result
a 10-bit one. You appear to be talking about the values of 10
different bits, so what exactly is 8-Bit about that?&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;(ADDH toggles +- 1LSB, and ADDL toggles from 0..3)&lt;br /&gt;
I think with 10 Bit precision, ADDH should be stable.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
That thought is incorrect. You&amp;#39;re talking about a digital value
here. &lt;b&gt;All&lt;/b&gt; bits can change for a 1-bit change in the value:
0x1ff -&amp;gt; 0x200&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AT89C51CC03 : 10-Bit ADC Problems</title><link>https://community.arm.com/thread/58709?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2010 23:56:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:881baee0-a294-436b-a413-486807157dfb</guid><dc:creator>Stefan Przybylski</dc:creator><description>&lt;p&gt;&lt;p&gt;
thank you for your answer.&lt;/p&gt;

&lt;p&gt;
i tried your code, but i always got only an 8-Bit result.&lt;br /&gt;
(ADDH toggles +- 1LSB, and ADDL toggles from 0..3)&lt;br /&gt;
I think with 10 Bit precision, ADDH should be stable.&lt;/p&gt;

&lt;p&gt;
Also the MCU does not stop, if PSIDLE Bit is set.&lt;br /&gt;
So the ADC seems to be not in the 10Bit mode, or this mode does not
work ?&lt;/p&gt;

&lt;p&gt;
I have changed one line in adcreadpre() :&lt;br /&gt;
ADCON |= channel; // Select channel ADCON.[SCH2..0]&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: AT89C51CC03 : 10-Bit ADC Problems</title><link>https://community.arm.com/thread/58706?ContentTypeID=1</link><pubDate>Wed, 29 Sep 2010 12:02:48 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ff015ded-4cf0-4b28-9745-59926b12f13e</guid><dc:creator>ntino gr</dc:creator><description>&lt;p&gt;&lt;p&gt;
have considered to use a &amp;quot;driver&amp;quot; for the ADC hardware ?&lt;br /&gt;
this works on AT89C51AC3 @29.4912MHz X1 mode.&lt;br /&gt;
also it takes care of the watchdog.&lt;br /&gt;
minor adjustments for the Keil compiler may be needed.&lt;/p&gt;

&lt;pre&gt;
// ADC 0-3V 8bit Standard or 10bit Best Precision at port P1[7..0]
__bit adc_eoc = 0;                      // ADC end of conversion
volatile unsigned char adc_val=0x00;    // ADC value 8bit Standard Precision
volatile unsigned int  adc_value=0x00;  // ADC value 10bit conversion Best Precision


void ADC_ISR(void) __interrupt(ADC_VECTOR) __using (3)
{
    ADCON &amp;amp;= ~ADEOC;                    // Set by Hardware at end of conversion. Clear by software
    adc_val = ADDH;                     // ADDH contains 8bit standard value of ADC
    adc_value = ADDH &amp;lt;&amp;lt; 2;              // ADDH:ADDL contains 10 bit value of ADC
    adc_value |= (ADDL &amp;amp; 0x03);         // mask ADDL[1..0] lower bits best precision
    adc_eoc = 1;                        // Set adc_eoc semaphore to inform end of conversion
}


void initadc(unsigned char ADCFchannels)   // setup P1 pins for ADC. call: initadc(CH6|CH7)  8BITS=8CHANNELS
{
    ADCON = 0x00;                      // clear
    ADCF  = 0x00;                      // clear all channels
    ADCF |= (ADCFchannels);            // set CH6, CH7 as Analog Inputs
    ADCLK = 0x00;                      // ADCLK[4..0] PRS4..0 = 0 =&amp;gt; X1 =Fxtal/128
                                       // F_XTAL = 29.491200 MHz / 128 = 230.400 KHz
    ADCON |= ADEN;                     // ADCON.ADEN = Enable (Disable for low power consumption)
                                       // Tsetup =4usec before the first convertion
    EADC = 1;                          // IEN1.EADC Enable ADC Interrupt
                                       // EA=1 global interrupt enable should handled in main
}

unsigned char adcreadstd (unsigned char ADCONchannel)   // Standard Precision call by channel to be converted 0..7
{
    ADCON &amp;amp;= ~(SCH2|SCH1|SCH0);        // clear all SCH clannels   3BITS=8CHANNELS
    ADCON |=  ADCONchannel;            // Select channel ADCON.[SCH2..0]
    ADCON &amp;amp;= ~PSIDLE;                  // Standard converion 8bit clear ADCON.PSIDLE=0
    ADCON |= ADSST;                    // Start conversion. Cleared by hardware after completion.

    while (!adc_eoc)
        resetWDT();

    return (adc_val);
}

unsigned int adcreadpre (unsigned char channel)   // Best Precision call by channel to be converted 0..7
{
    ADCON &amp;amp;= ~(SCH2|SCH1|SCH0);         // clear all SCH clannels
    ADCON  =  channel;                  // Select channel ADCON.[SCH2..0]
    ADCON |= (PSIDLE|ADSST);            // Best Precision convertion 10bit ADCON.PSIDLE=1, ADCON.ADSST=1
                                        // PSIDLE stop MCU but not peripherals. The ADC_ISR wakes system
    while (!adc_eoc)
        resetWDT();

    return (adc_value);
}

&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>