## Friday, June 28, 2013

### Using Analog to Digital Converter of AT89C51CC01 Microcontroller

Using AT89STK-06 starter kit, I have written a few C code to read an analog to digital converter (ADC) input of AT89C51CC01 which is an 8051 microcontroller. It has 8 multiplexed ADC inputs with 10 bit resolution. As an example, ADC input pin 7 which is connected to a variable resister is read.
void SysADCInit()//Initialize AD7
{
}
{
ui16 v;
return v;
}

In the procedure to read ADC input, the analog to digital conversion process is started by setting the start bit, bit 3. Then, a while loop is used to check the flag and it waits until the process is finished. The conversion takes 16 microseconds only and, consequently, the use of interrupt is not recommended. Becasue it cannot improve the performance in such a low end microcontroller while the conversion time is not so long. After that, the flag is cleared. The result of the ADC conversion is 10 bits. The least significant 8 bits are in ADDL and the most significant 2 bits are at position 7 and 6 of ADDH. These two values are combined into 16 integer, v.