ADS1262的寄存器配置和读写都没有问题,但是发现采集到的32位数据一直为128 0 0 0,这是怎么回事呀?
adc_code = ADS1262ReadData(6,1); //AD读取数据
val = ((long double)adc_code/0x7fffffff);
val*=2.499;
printf("CODE: %10d CODE: %10d VOL: %.8Lf \r\n ",adc_code,adc_code,val);
下面是AD读取数据的程序
int32_t ADS1262ReadData(uint8_t NumBytes, uint8_t DataByteStartNum)
{
// assert((4 == NumBytes) || (5 == NumBytes) || (6 == NumBytes)); //Aborts program if FALSE
// assert((0 == DataByteStartNum) || (1 == DataByteStartNum)); //Aborts program if FALSE
uint8_t ADC_Bytes[6]; //Holds
int32_t ADC_Data_Only;
int i;
DACNCSS(0);
// while(ADS_DRDY);
for( i = 0; i < NumBytes; ++i)
ADC_Bytes[i] = SPI_DAC_SendByte(0);
ADC_Data_Only = ((int32_t)ADC_Bytes[DataByteStartNum + 0] << 24) | //Data MSB
((int32_t)ADC_Bytes[DataByteStartNum + 1] << 16) |
((int32_t)ADC_Bytes[DataByteStartNum + 2] << 8) |
((int32_t)ADC_Bytes[DataByteStartNum + 3] << 0); //Data LSB
DACNCSS(1);
return ADC_Data_Only;
} |