I read through that post and implemented the initializations. but there still seems to be a problem. the 24 bit data read is still 00 00 00. Here's the modified code.
void begin()
{
unsigned int i;
RESET=0; //initial reset
SDelay(100);
RESET=1;
write_to_register(0x5E, 0x00, 0x00, 0x01); //status reg= 000001
write_to_register(0x40, 0x00, 0x00, 0x04); //config reg= 000004
write_to_register(0x4A, 0x00, 0x00, 0x32); //cycle count=000032
write_to_register(0x78, 0x00, 0x00, 0x08); //control reg=000008
write_to_register(0x74, 0x80, 0x00, 0x00); //mask reg= 800000
write_to_register(0xE8, 0xFF, 0xFF, 0xFF); //start conv, nop, nop, nop
write_to_register(0xFF, 0xFF, 0xFF, 0xFE); //nop, nop, nop, nop
read_register(0x0E); //read inst current reg
SDelay(200); //delay
for (i=0;i<50;i++)
{
P2=0xFF; led1=0; P0=Display((high_byte>>4)& 0x0F); //Display High
SDelay(300);
P2=0xFF; led2=0; P0=Display((high_byte)& 0x0F);
SDelay(300);
P2=0xFF; led3=0; P0=Display((mid_byte>>4)& 0x0F); //Display Mid
SDelay(300);
P2=0xFF; led4=0; P0=Display((mid_byte)& 0x0F);
SDelay(300);
P2=0xFF; led5=0; P0=Display((low_byte>>4)& 0x0F); //Display Low
SDelay(300);
P2=0xFF; led6=0; P0=Display((low_byte)& 0x0F);
SDelay(300);
}
return;
}
void write_to_register(char command,char low,char mid,char high)
{
transfer_byte(command); //Transfer command followed by 24 bit data
transfer_byte(high);
transfer_byte(mid);
transfer_byte(low);
return;
}
void read_register(char command)
{
transfer_byte(command);
high_byte = recieve_byte(); //Receive Bytes
mid_byte = recieve_byte();
low_byte = recieve_byte();
return;
}
void transfer_byte(char number)
{
unsigned int i;
for (i=0; i<8; i++)
{
if (number & 0x80) SDI=1; //bit to be transferred is put on SDI
else SDI=0;
SDelay(100); //delay
SCLK=1; SDelay(100); SCLK=0; SDelay(100); //pulse clock
number = number<<1; //next bit
}
return;
}
char recieve_byte(void)
{
unsigned int i;
unsigned char x, sync=0xFE;
SDI=1;
for (i=0; i<8; i++)
{
x=x|SDO; //bit recieced from SDO is stored
x=x <<1;
if(sync &0x80) SDI=1; //strobing nop on SDI while reading
else SDI=0; //as per 5460 datasheet
sync= sync<<1;
SDelay(100); //delay
SCLK=1; SDelay(100); SCLK=0; SDelay(100); //pulse clock
}
return x;
}
Added after 26 minutes:
I also tried writing to the register im reading.
write_to_register(0x4E, 0xFF, 0xFF, 0xFF); //write instead of start conv, nop, nop, nop
write_to_register(0xFF, 0xFF, 0xFF, 0xFE); //nop, nop, nop, nop
no change.