Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

problem wtih reading and wirting cs5460 with at89c52

Status
Not open for further replies.

selvam.e

Newbie level 1
Joined
Nov 26, 2011
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,300
hello experts,
i here with atached part of code which is used for getting register values , but the problem is i'm not getting any values . im looking a guidance for read/write cs5460 with at89c52, software which im using is keil version.

warm regards,
selvam, bangalore.


cmd_5460(0xff); //nop
delay(1000);
cmd_5460(0xff); //nop
delay(1000);
cmd_5460(0xff); //nop
delay(1000);
cmd_5460(0xfe); //nop
write_5460(0x4a000012); //writing cycle count reg; with value of 18d
delay(1000);
write_5460(0x5e000001); //writing status register; with value of 1;
delay(1000);
write_5460(0x40000004);//writing config reg wih value of 4 for clock divider;
delay(1000);
write_5460(0x78000008); //writing control register for synchronize with adc clock;
delay(1000);
write_5460(0x74800000); //writing mask registr o mask all bits except drdy bit;


cmd_5460(0xe8);// start conersiion for continuous computation cycle

delay(1000);
cmd_5460(0x16);// read irms register
read_5460();


void cmd_5460(unsigned char cmd)
{
unsigned char i=8;
while(i>0)
{

if(cmd & 0x80)
{
sdi_5460=1;
sclk_5460=0; //clk applying
delay(1000);
sclk_5460=1;
delay(1000);

}
else
{
sdi_5460=0;
sclk_5460=0; //clk applying
delay(1000);
sclk_5460=1;
delay(1000);
}
i--;
cmd=cmd << 1;

}
}


unsigned long read_5460(void)
{
unsigned char i,j=0;
unsigned long temp;// temp is used to store read value
temp=0;
while(j<3)
{
i=7;
sdi_5460=1;
while(i>0)
{
temp=temp<<1;
sclk_5460=0; //clk applying
delay(1000);
sclk_5460=1;
delay(1000);

if(sdo_5460==1)
{
temp=temp|0x00000001;
}

i=i-1;
}
sdi_5460=0; /writing zero at eighth bit to be read.
temp = temp << 1;
sclk_5460=0; //clk applying
delay(1000);
sclk_5460=1;
delay(1000);
if(sdo_5460==1)
{
temp = temp|0x00000001;
}
j=j+1;

}
if(temp==0)
{
P2=disp1;
P0=1;
}

else
{
P2=disp2;
P0=1;
}

return(temp);

}


void delay(unsigned int q)
{

while(q>=1)
{
q=q-1;
}

}


void write_5460(unsigned long reg_value)
{
unsigned char k=32;
while(k>=1)
{
if (reg_value & 0x80000000)
{
sdi_5460=1;
sclk_5460=0; //clk applying
delay(1000);
sclk_5460=1;
delay(1000);
}
else
{
sdi_5460=0;
sclk_5460=0; //clk applying
delay(1000);
sclk_5460=1;
delay(1000);
}
reg_value = reg_value << 1;
k=k-1;

}

}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top