u8 ADS1256_reg_Init[5]={ 0x02, //状态寄存器初始化值
0x01, //模拟多路选择器初始化值
0x00, //AD控制寄存器初始化值
0x03, //数据速度寄存器初始化值 0x00, //I/O控制寄存器初始化值
};
ADS1256_Write_CS_H;
ADS1256_Write_SYNC_H;
ADS1256_Write_SCLK_L;
ADS1256_Write_RST_L;
ads1256_delayms(1);
ADS1256_Write_RST_H;
ads1256_delayms(1);
ADS1256_Write_CS_L; ads1256_delayms(1);
ADS1256_write_reg(0x00,ADS1256_reg_Init[0]);//状态寄存器初始化
ads1256_delayus(1);
ADS1256_write_reg(0x01,ADS1256_reg_Init[1]);//模拟多路选择器初始化
ads1256_delayus(1);
ADS1256_write_reg(0x02,ADS1256_reg_Init[2]);//AD控制寄存器初始化
ads1256_delayus(1);
ADS1256_write_reg(0x03,ADS1256_reg_Init[3]);//数据速度寄存器初始化 ads1256_delayus(1);
ADS1256_write_reg(0x04,ADS1256_reg_Init[4]);//I/O控制寄存器初始化
ads1256_delayus(1);
if(ADS1256_reg_Init[1] != ADS1256_read_reg(0x01)) ReturnData = 1;
if(ADS1256_reg_Init[2] != ADS1256_read_reg(0x02)) ReturnData = 1;
ads1256_delayus(1);
if(ADS1256_reg_Init[3] != ADS1256_read_reg(0x03)) ReturnData = 1;
ads1256_delayus(1);
if(ADS1256_reg_Init[4] != ADS1256_read_reg(0x04)) ReturnData = 1;
ads1256_delayus(1);
while(ADS1256_Read_DRDY);
// for (ii=0;ii<6000;ii++)// {if(ADS1256_Read_DRDY == 0) break;}
ADS1256_SELFCAL(); //补偿和增益自校准
ads1256_delayus(5);
ADS1256_SYNC(); //AD转换同步
ads1256_delayms(20);
ADS1256_WAKEUP(); //退出待机模式
ads1256_delayus(5);
return(ReturnData);
user151383853:
先检查一下时序吧,检查是不是里面有时间不合适的地方
Yaju DU:
回复 user151383853:
你好, 另外一个问题:while(ADS1256_Read_DRDY); 一直等待。不能进行下去,之前问题暂不管