Other Parts Discussed in Thread: ADS1243, ADS1240, ADS124S06
Good day.
I am having some problems with regards to waiting for the DRDY pin to go low. I am exciting the strain gauges, setting the mux and differential channels. I then send the RDATAC command, delay 100ms, then initiate sclk to read the data in a loop 8 times then average off. I am noticing in some instances, units are left waiting indefinitely for the DRDY pin to drop, this obviously without any timeout waiting for the pin to drop. This is a new find as some units have been operating successfully for over a year. Question is, if i "miss" the DRDY pin dropping low, or if the pin does not drop low at all, can i merely resend the RDATAC command, or should i send the RESET command and start from the beginning. Code is below. Any input would be appreciated.
void set_A2D_channel(unsigned char chan)
{
AD_CS=0; // Select A/D
switch(chan)
{
case 0: WriteSPI1(0x51); // Write to Register Starting at 1 (MUX)
DelayUs(20);
WriteSPI1(0x00); // Ending at Register 1 (MUX)
DelayUs(20);
WriteSPI1(0x04); // Channel 0 inputs: differential Ch 4
DelayUs(20);
break;
case 1:
WriteSPI1(0x51); // Write to Register Starting at 1 (MUX)
DelayUs(20);
WriteSPI1(0x00); // Ending at Register 1 (MUX)
DelayUs(20);
WriteSPI1(0x15); // Channel 1: differential Ch 5 - test: swap rails
DelayUs(20);
break;
case 2:
WriteSPI1(0x51); // Write to Register Starting at 1 (MUX)
DelayUs(20);
WriteSPI1(0x00); // Ending at Register 1 (MUX)
DelayUs(20);
WriteSPI1(0x26); // Channel 2 inputs: differential Ch 6
DelayUs(20);
break;
case 3:
WriteSPI1(0x51); // Write to Register Starting at 1 (MUX)
DelayUs(20);
WriteSPI1(0x00); // Ending at Register 1 (MUX)
DelayUs(20);
WriteSPI1(0x37); // Channel 3 inputs: differential 7 - test : swap rails
DelayUs(20);
break;
}
}
void get_A2D_value(void)
{
unsigned char i,j,flush_read = 0;
ad_value[ad_channel] = 0;
WriteSPI1(RDATAC); // Start reading continuously
DelayMs(100);
for(j=0;j<9;j++) {
if(j==0) {flush_read = 1;}
else {flush_read = 0; }
while(AD_DRDY);
for(i=0;i<3;i++) {
ad_reading[i]=ReadSPI1(0);
}
ad_value_test=ad_reading[0];
ad_value_test<<=8;
ad_value_test|=ad_reading[1];
ad_value_test<<=8;
ad_value_test|=ad_reading[2];
if((ad_reading[0] & 0x40) != 0)
ad_value_test|=0xff000000;
if(!flush_read) {
ad_value[ad_channel]+=ad_value_test;
}
}
/* Do value comparison with previous on each read and for total value with previous total value. If greater than 1% do re-read */
WriteSPI1(STOPC); // Stop reading
DelayMs(20);
AD_CS=1; // Deselect A/D
DelayMs(20);
ad_value[ad_channel] = (ad_value[ad_channel]>>3);
Thanks in advance




