Hi all.
A get a problem when try to use ADS1258 in autoscan mode. I use this code for data acquisition:
#define SCALE (4.096 / 0x780000) * 1.06666660308837 #define V 1 #define mV 0.001 #define uV 0.000001 // read values in auto-scan mode void adc_request_values(uint8_t n_channels) { uint8_t buf[16+5][4] = {0,0}; uint8_t ch, byte = 0; float vcc, adcgain, ref, temp, offset = 0; int32_t tmp = 0; ADS_SET_HIGH(ADS_PIN_START); // start conversion for(ch = 0; ch < n_channels+5; ch++) { while(GPIO_ReadInputDataBit(GPIOA, ADS_PIN_DRDY) != 0); // wait for data ready // read data direct ADS_SET_LOW(ADS_PIN_CS); for(byte = 0; byte < 4; byte++) { buf[ch][byte] = ads_spi_xmit(0); } ADS_SET_HIGH(ADS_PIN_CS); } ADS_SET_LOW(ADS_PIN_START); // stop conversion offset = ((uint32_t) ((buf[16][1] << 16) | (buf[16][2] << 8) | buf[16][3])) / 786432.0; vcc = ((uint32_t) ((buf[17][1] << 16) | (buf[17][2] << 8) | buf[17][3])) / 786432.0; temp = (((((uint32_t) ((buf[18][1] << 16) | (buf[18][2] << 8) | buf[18][3])) * SCALE * uV) - 168) / 394) + 25 ; adcgain = ((uint32_t) ((buf[19][1] << 16) | (buf[19][2] << 8) | buf[19][3])) / 7864320.0; ref = ((uint32_t) ((buf[20][1] << 16) | (buf[20][2] << 8) | buf[20][3])) / 786432.0; printf("VCC = %2.5fv\n", vcc); printf("GAIN = %2.5fv\n", adcgain); printf("REF = %2.5fv\n", ref); printf("TEMP = %2.5fC\n", temp); printf("OFFSET = %2.5fv\n", offset); printf("\n"); for(ch = 0; ch < n_channels; ch++) { printf("%06x", (uint32_t) ((buf[ch][1] << 16) | (buf[ch][2] << 8) | buf[ch][3])); printf(" AIN%2d:", (buf[ch][0] & 0x1F) - 8); printf(" %2.5fv", ((buf[ch][1] << 16) | (buf[ch][2] << 8) | buf[ch][3]) * SCALE / adcgain); if(((buf[ch][0] & 0x40) >> 6) == 1) printf(" Voltage overflow! (Vin > 1.06*Vref)"); if(((buf[ch][0] & 0x20) >> 5) == 1) printf(" Lost supply! (AVDD-AVSS below a preset limit)"); printf("\n"); } }
When read is done, i get the first channel data is always zero:
000000 AIN 0: 0.00000v 56c1d7 AIN 1: 3.17450v 56c118 AIN 2: 3.17439v 56c31a AIN 3: 3.17468v 56beee AIN 4: 3.17408v 56bee0 AIN 5: 3.17407v 004ef6 AIN 6: 0.01129v 5bd0b9 AIN 7: 3.35958v 5bca58 AIN 8: 3.35866v 5be632 AIN 9: 3.36264v 5bb8e8 AIN10: 3.35617v 5bad18 AIN11: 3.35448v 5b7166 AIN12: 3.34595v ff547b AIN13: 9.34267v 5b4752 AIN14: 3.33994v 5bc839 AIN15: 3.35836v
So, the first reading is correct (first data have some value) and all next acquisitions is zeroed first data.
Note that this behavior independs from number of selected channels.
Why?