Discussion in "Project Help" started by    madhu_b63    Oct 12, 2007.
Fri Oct 12 2007, 10:57 am
#1
Hello Ajay,

I am using AD7812 a serial ADC with 89c52 controller.In data sheet it is given that the 13 pulsese to be given to latch the data to the control register but the control register size is 10 bit but i tried to give 13 clk puses but it is not working.It is totally confusing to me could u please help in this regard.I will send my code to u please check it.

Thank u



unsigned int a2d()
{
unsigned int data_out=0;
unsigned char control[10]={0,1,1,0,0,1,1,0,1,1};// A0=0 , Powerdown=No, vin=0, No differential,Channel1,conersion start=1,externel refference
unsigned char i;
// bit flag ;
RFS=0; //rfs-tfs in transmit mode
for(i=0;i<13;i++) //transmit a control word
{
SCLK=1;
DIN=control[i];
SCLK=0;
}



// CONVS=1;

//delay2();

while(CONVS!=0);

RFS=1;//rfs-tfs in receive mode

data_out=0;

delay1();
//flag=0;

for(i=0;i<10;i++) //reading a result
{
SCLK=0;
if (DOUT) data_out = data_out + power(2,9-i);
SCLK=1;
}





[ Edited Fri Oct 12 2007, 06:40 pm ]
Mon Oct 15 2007, 12:12 pm
#2
Sorry i kind of missed your post.. was busy..
well i just saw the datasheet and this IC is having a weired kind of protocol...
anyways.. here is what you need to do.. I see some of things are done correctly.. but some are not..

regarding the connections...
You have SCLK, DIN, DOUT, CONVST, RFS&TFS(single pin)

So... one by one.. protocol...
1. Make TFS high..
2. Send 10 bit control byte, bit shifted at the first falling edge of sclk (only 10 clocks are needed.. not 13).
3. wait for CONVST goes low.. (make sure CONVST is high during startup to prevent the IC goes into power down mode).
4. put a NOP here.. so that you must wait 2.3­µS before you send RFS signal otherwise last converted data will be sent out not the new data..
5. Send RFS signal by making it high...
6. read data.. one by one.. 10 clocks.. data shifted at falling edge of the SCLK.

Now.. regarding data storage..
instead of using unsigned char array.. use bit array..
i mean..
bit dat[10]={your data here};
so you can directly send the data to DIN pin.. similarly for read..
Hope this will help you..
 madhu_b63 like this.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am