We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am using uVision3 with AT89S52 and 89S52 is connected with 12-bit Serial ADC MAX187 according to Datasheet. I have interfacing problem with this ADC using C51 compiler. I searched uVision help and net also, but didn't find any solution. So please Reply in Detail. and don't tell me to goto http://www.atmel.com or http://www.maxim-ic.com because i already searched there for any example.
Problems are: 1. How can i store A/D Converted value (12bit) to one 16bit register for 89S52 ,or using two registers? 2. I can use "ACC" for 8 bit rotation but how i will store 8-bit ACC data to any register or Variable so i can print to LCD. 3. Can i use DATA,BDATA,IDATA and PBYTE,CWORD,DWORD,PWORD from absacc.h ? 4. How can i convert 12bit binary to ASCII? so i can print to LCD.
But How will you initiallize uC for P1^0 as output port when CS is also 0 (i.e CS=0) for Selecting ADC. If sbit CS=P1^0 is connected then CS=0 will Select ADC, not P1^0 as output port??
and so as for sbit DOUT=P^1 as input port? when your program triggers loop for (i = 12; i != 0; i--) { Take SCLK high; shift_reg <<= 1; Take SCLK low; if (DOUT) /* if initiallize as input ports i.e. DOUT = 1*/ shift_reg |= 1; }
Is there other way to display converted 12bit binary data for simulation purpose. If so please let me know.
I am also using Proteus 7 VSM Pro latest version but library doesn't has MAX187 ADC instead it has MAX1240 i.e. also 12 bit Serial ADC but 2.7V instead 5V.
Any easiest way through Proteus VSM ?
In your program if i assigns sbit DOUT=P1^1; then how will i link to data of DOUT to shift_reg because DOUT is a single bit and shift_reg is an integer.
Please Explain !
I think this can be done easily in assembly by using of registers but i want easily with C
unsigned int shift_reg; shift_reg = 0; for (i = 12; i != 0; i--) { Take SCLK high; shift_reg <<= 1; Take SCLK low; if (DOUT) shift_reg |= 1; }
"How will you initiallize uC for P1^0 as output port ..."
The port is quasi-bidirectional. I can't say much more than that without referring you to 8051 reference material or data sheets, which you asked not be done.
"In your program if i assigns sbit DOUT=P1^1; then how will i link to data of DOUT to shift_reg because DOUT is a single bit and shift_reg is an integer."
In C51, a bit is a data type that can have the value 0 and 1. 0 and 1 are also evaluated in conditional expressions as false and true, respectively. The left shift operator (<<) has shifted in a 0 into the shift register and only if DOUT is true (1) to we changed that shifted-in 0 to a 1, hence the shift and conditional OR represent DOUT's value.
Thanks a lot Dan Henry!