ADS1256有很多问题,希望大家能够解答一下,谢谢。

1、ADS1256上电初始化,先设置status,mux,adcon,drate几个寄存器值,分别设置成0x04,0x08,0x00,0x03(drate为2.5sps),但是读寄存器的值全部为0

2、读取ADS1256转换值,操作时序如下:

void ReadASingleData(u8 AINP,u8 AINN)
{
double ReadVoltage;
u32 Data;
u16 i;

ADS1255_write_reg(0x01,(AINP<<4) | AINN );//设置通道
ADS1255_write_reg(0x03,0x00);//数据采集速度2.5
ADS1255_SELFCAL(); 
ads1255_delayus(5);
ADS1255_SYNC(); 
ads1255_delayms(20);
ADS1255_WAKEUP();
ads1255_delayus(5);

for(i=0;i<8;i++) //采集8次数据
{
ADS1255_RDATA(); //读单次数据命令
ads1255_delayus(20); //至少50个延时周期
Data = ADS1255_Read_a_Data();//读取AD采集的二进制值
ReadVoltage = ADS1255_DataFormatting( Data , 2.5 , 1);//参考电压2.5V,内置增益为1
DataUart(ReadVoltage); //将电压发送到上位机
}

}

3.以下是我的ads1256初始化函数,DRDY的电平一直为低电平,不转化,不知道初始化对不对

u8 ADS1256_Init(void)
{

GPIO_InitTypeDef GPIO_Initure;
/****************************************
ADS1256_Read_MISO PBin(4)
ADS1256_Read_DRDY PEin(0)
ADS1256_CS PAout(15)
ADS1256_RESET PEout(1)
ADS1256_DRDY PAout(15)
ADS1256_MISO PBout(4)
ADS1256_MOSI PBout(5)
ADS1256_SCK PAout(5)
*****************************************/


__HAL_RCC_GPIOA_CLK_ENABLE(); //
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE(); //

//PA15 CS,PA5 SCK
GPIO_Initure.Pin=GPIO_PIN_15|GPIO_PIN_5;
GPIO_Initure.Mode=GPIO_MODE_OUTPUT_PP; /
GPIO_Initure.Pull=GPIO_NOPULL; //­
GPIO_Initure.Speed=GPIO_SPEED_MEDIUM; //
HAL_GPIO_Init(GPIOA,&GPIO_Initure); //³õʼ»¯
//PB5 MOSI
GPIO_Initure.Pin=GPIO_PIN_5;
HAL_GPIO_Init(GPIOB,&GPIO_Initure); //³õʼ»¯

//PE1 RESET
GPIO_Initure.Pin=GPIO_PIN_1;
HAL_GPIO_Init(GPIOE,&GPIO_Initure); //³õʼ»¯

//PB4 MISO
GPIO_Initure.Pin=GPIO_PIN_4;
GPIO_Initure.Mode=GPIO_MODE_INPUT; //ÍÆÍìÊä³ö
GPIO_Initure.Pull=GPIO_NOPULL; //ÉÏÀ­
GPIO_Initure.Speed=GPIO_SPEED_FAST; //¿ìËÙ
HAL_GPIO_Init(GPIOB,&GPIO_Initure); //³õʼ»¯

//PE0 DRDY
GPIO_Initure.Pin=GPIO_PIN_0;
HAL_GPIO_Init(GPIOE,&GPIO_Initure); //³õʼ»¯


u8 ReturnData = 0;
u8 ADS1256_reg_Init[4]={
0x04, 
0x08, 
0x00,
0x03,
// 0x00,
};
/*
ADS1256_RESET=1;
ADS1256_CS=1;
ADS1256_SCK=0; 
ADS1256_MOSI=1;
*/

ADS1256_CS=0;
ADS1256_SCK=0;
ADS1256_RESET=0;
delay_us(100);
ADS1255_RESET();
delay_ms(10);

while(ADS1256_Read_DRDY) ; 

ADS1256_SYNC(); 
ADS1256_WAKEUP(); 



ADS1256_write_bit((0x00& 0x0F) | 0x50);
ADS1256_write_bit(0x03);
ADS1256_write_bit(0x04); 
ADS1256_write_bit(0x08);
ADS1256_write_bit(0x00); 
ADS1256_write_bit(0x03); 
delay_us(100);



ADS1256_write_reg(0x00,ADS1256_reg_Init[0]);
delay_us(1);

ADS1256_write_reg(0x01,ADS1256_reg_Init[1]);
delay_us(1);

ADS1256_write_reg(0x02,ADS1256_reg_Init[2]);
delay_us(1);

ADS1256_write_reg(0x03,ADS1256_reg_Init[3]);
delay_us(1);


if(ADS1256_reg_Init[0] != ADS1256_read_reg(0x00))
ReturnData = 1;

if(ADS1256_reg_Init[1] != ADS1256_read_reg(0x01))
ReturnData = 1;

delay_us(1);

if(ADS1256_reg_Init[2] != ADS1256_read_reg(0x02))
ReturnData = 1;

delay_us(1);

if(ADS1256_reg_Init[3] != ADS1256_read_reg(0x03))
ReturnData = 1;

delay_us(1);

while(ADS1256_Read_DRDY)
ADS1256_SELFCAL(); 
delay_us(5);
ADS1256_SYNC(); 
delay_ms(20);
ADS1256_WAKEUP(); 
delay_us(5);

return(ReturnData);

}

真不知道到底是芯片有问题还是我操作上哪里不对了;

1 个回复