This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

求助ADS131E08驱动程序

Other Parts Discussed in Thread: ADS131E08

void ADS131E08_Init(void)
{
u8 i;
GPIO_InitTypeDef GPIO_InitStructure;

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA, ENABLE); //使能PA,PC端口时钟

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5; //PC4 - ADC_START PC5- ADC_RESET 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
// GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4; //PA4 - CS 端口配置, 推挽输出
GPIO_Init(GPIOA, &GPIO_InitStructure); //推挽输出 ,IO口速度为50MHz

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1; //PA1- ADC_DRDY 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; //输入
GPIO_Init(GPIOA, &GPIO_InitStructure);

SPI1_Init();

CS_H; //PA4=1
delay_ms(10);
CS_L; //PA4=0
START_L;//PC=4

RESET_H;//PC=5
delay_ms(10);
RESET_L;
delay_ms(10);
RESET_H;
delay_ms(10);

SPI1_ReadWriteByte(SDATAC);// SDATAC Stop Read Data Continuously mode
delay_ms(10);
CS_H;

SPI1_ReadWriteByte(0x41);
SPI1_ReadWriteByte(11);
delay_ms(10);


SPI1_ReadWriteByte(0xD6);//conf1 1KSPS 24bits
// SPI1_ReadWriteByte(0xE3);//conf2
SPI1_ReadWriteByte(0xE0);//conf2
SPI1_ReadWriteByte(0x60);//conf3 Bit 5 = 1 参考电压为4v,接入5v电压时
SPI1_ReadWriteByte(0x00);
// delay_ms(1);

SPI1_ReadWriteByte(0x10);
SPI1_ReadWriteByte(0x10);
SPI1_ReadWriteByte(0x10);
SPI1_ReadWriteByte(0x10);
SPI1_ReadWriteByte(0x10);
SPI1_ReadWriteByte(0x10);
SPI1_ReadWriteByte(0x10);
SPI1_ReadWriteByte(0x10);
delay_ms(1);
SPI1_ReadWriteByte(0x20);
SPI1_ReadWriteByte(12);

START_H;


CS_L;
delay_ms(1);
SPI1_ReadWriteByte(RDATAC);
delay_ms(10);
CS_H;


}

void ADS131E08_Read(s32 *adc1buf)
{
u8 ReadBuf[27] = {0};
u8 i=0;

if(!DRDY_IN)
{
CS_L;
delay_ms(1);
// SPI1_ReadWriteByte(RDATAC);
for(i=0;i<27;i++)
{
ReadBuf[i] = SPI1_ReadWriteByte(0x00); //连续读取ADC的27 个字节数据
}
CS_H;
for(i=0;i<9;i++)
{
adc1buf[i]=ReadBuf[3*i]<<16 | ReadBuf[1+3*i]<<8 | ReadBuf[2+3*i]; //将27字节数据转化成9个24位的数据
}

printf("1c1=%8d,1c2=%8d,1c3=%8d,1c4=%8d,1c5=%8d,1c6=%8d,1c7=%8d,1c8=%8d\n",adc1buf[1],adc1buf[2],adc1buf[3],adc1buf[4],adc1buf[5],adc1buf[6],adc1buf[7],adc1buf[8]);




// printf("1c1=%8d,1c2=%8d,1c3=%8d,1c4=%8d,1c5=%8d,1c6=%8d", ReadBuf[0],ReadBuf[1],ReadBuf[2],ReadBuf[24],ReadBuf[25],ReadBuf[26]);
}
}

按照手册上配置好寄存器,但是读数为:

1c0=12813187,1c2= 1040895,1c3=16499137,1c4=12632256,1c5=12632256,1c6=12607584,1c7= 520447,1c8=16638176
1c0= 6293488,1c2=14737456,1c3= 3146744,1c4= 8388336,1c5= 7368728,1c6= 1573372,1c7= 4194168,1c8= 3684364
1c0=13639676,1c2= 393343,1c3= 1048558,1c4= 921091,1c5= 196671,1c6= 8912879,1c7= 460545,1c8= 8486943
1c0=12632079,1c2=12698048,1c3=12632256,1c4=12632160,1c5= 6293488,1c6=14737456,1c7= 3146744,1c8= 8368131
1c0=12611632,1c2= 4194232,1c3= 3673100,1c4= 65055,1c5=16768028,1c6= 1836544,1c7= 8326670,1c8= 921091
1c0=12586980,1c2= 459137,1c3= 8396739,1c4=16775043,1c5= 8618176,1c6=12586977,1c7=16776129,1c8=12697792
1c0=12607584,1c2=14737632,1c3= 6303747,1c4=16285695,1c5= 7368816,1c6= 1579009,1c7=16531455,1c8=12073016
1c0=14425094,1c2= 1048558,1c3= 921091,1c4= 196671,1c5= 8912647,1c6= 459521,1c7= 8396739,1c8=16776067

输入接地读数该为0,但是读出来的数一点不对,请各位大神帮忙查看一下哪有错误?!