Discussion in "8051 Discussion Forum" started by    qwertyboy    Apr 3, 2008.
Thu Apr 03 2008, 01:39 am
Hello! i´m new here,in this forum, and i have a question;)
Does anyone have work with max192 and de 89S51? I need to take mesures of 8 analog channels and i´ve buyed the maxim adc, MAX192, but i ´m having trouble putting the micro and the adc working. Does anyone have a tutorial in C language or some "lights" to help me (a beginer) to make an serial adc conversion with 89S51? Tk´s;)
Thu Apr 03 2008, 12:47 pm
can u post data sheet??
Thu Apr 03 2008, 12:55 pm
Hello! Yes, the ADC datasheet is:
Thu Apr 03 2008, 08:19 pm
You need to look at pg13,fig.9 to get an idea of what steps your microcontroller has to perform to select an analog channel,configure the ADC and read in the digital data.
Connect CS pin of the ADC to,say,P2.0 of 89S51.
SCLK to say P2.1
DIN to P2.2
DOUT to P2.3

Now according to the fig. 1st thing you have to do is make CS low.
Thus P2.1=0;

Next you have to clock in a control byte to the DIN pin.Read about the control byte in pg9.
So suppose you have to select channel 0 for adc in unipolar,single-ended mode you must send in the fol. control byte.
For this you make SCLK(P2.1) low and then set P2.2(DIN) to the MSB of the control byte followed by a small delay,then a high pulse on SCLK.
Thus P2.1=0; //SCLK low
P2.2=1; //the MSB of the ctrl byte
This comprises clocking in one bit of the ctrl byte.Clock in the other 7 bits in a similar manner.
After all 8 bits have been clocked out you need to make SCLK low and CS high according to the fig.
Now wait for atleast 10us for the conversion to take place.
delay(); //wait 20us

After the delay you make CS low and start clocking in the 10 bits representing the converted data.
P2.0=0; //make CS low
P2.1=1; //make SCLk high
P2.1=0; //make SCLK low
mydata^0=P2.3; //read in msb of data into variable 'mydata'
mydata=mydata<<1; //shift in the bit by one place.

In tis way you can read in 8bits into 'mydata' and the remaining 2 bits into another variable.

Hope this is enough to get you started.
 qwertyboypdi33 like this.
Thu Apr 03 2008, 09:14 pm
89S51 doesn't have SPI interface.. so either you have to implement SPI on 89S51 or you can use a controller with onchip SPI.

For more information on programming see page 12 of datasheet.. well that not all.. read the datasheet completely. start with something.. will help you as you move on
 qwertyboy like this.
Fri Apr 04 2008, 01:02 am
wow shashi , u surely have given the whole code itself just disguised in simple english language for interfacing. . It would save a lot of time if such explaination were given in the datasheet application notes.
Wed Apr 09 2008, 10:05 pm

What this does? the ^ after mydata?

Wed Apr 09 2008, 10:18 pm
mydata^0 means 0th bit of 8-bit data variable. Please make sure you define the variable in bit addressable area, using bdata directive.
 qwertyboy like this.

Get Social


Powered by e107 Forum System



Sun Jun 16 2024, 04:23 am
Sat Jun 15 2024, 09:17 pm
Sat Jun 15 2024, 02:18 pm
Fri Jun 14 2024, 03:16 pm
Fri Jun 14 2024, 11:56 am
Thu Jun 13 2024, 06:00 pm
Thu Jun 13 2024, 03:10 pm
Thu Jun 13 2024, 02:23 pm