AD7705采集通道一和通道二的电压,读取完通道一后再去读取通道二的数据,是否需要重新设置寄存器?
下面的程序一和程序二中哪段是对的?
程序一:
void Init7705()//功能:AD7705初始化
{
PORTD|=(1<
WriteByte7705(0x20); //设置时钟寄存器
WriteByte7705(0x01);//WriteByte7705(0x01); //ZERO,ZERO,ZERO,CLKDIS,CLKDIV,CLK,FS1,FS0 //0x08
WriteByte7705(0x10); //设置寄存器
WriteByte7705(0x44);//WriteByte7705(0x44); //MD1(0) MD0(0) G2(0) G1(0) G0(0) nB/U(1) BUF(0) FSYNC (0)
WriteByte7705(0x21); //设置时钟寄存器
WriteByte7705(0x01);//WriteByte7705(0x01); //ZERO,ZERO,ZERO,CLKDIS,CLKDIV,CLK,FS1,FS0 //0x08
WriteByte7705(0x11);
WriteByte7705(0x44);
}
void adc_read(void)
{
WriteByte7705(0x10);
WriteByte7705(0x44);
adc_clk();
WriteByte7705(0x38);
temp=ReadWord7705();
WriteByte7705(0x11);
WriteByte7705(0x44);
adc_clk();
WriteByte7705(0x39);
temp=ReadWord7705();
}
程序二:
{
PORTD|=(1<
WriteByte7705(0x20); //设置时钟寄存器
WriteByte7705(0x01);//WriteByte7705(0x01); //ZERO,ZERO,ZERO,CLKDIS,CLKDIV,CLK,FS1,FS0 //0x08
WriteByte7705(0x10); //设置寄存器
WriteByte7705(0x44);//WriteByte7705(0x44); //MD1(0) MD0(0) G2(0) G1(0) G0(0) nB/U(1) BUF(0) FSYNC (0)
WriteByte7705(0x21); //设置时钟寄存器
WriteByte7705(0x01);//WriteByte7705(0x01); //ZERO,ZERO,ZERO,CLKDIS,CLKDIV,CLK,FS1,FS0 //0x08
WriteByte7705(0x11);
WriteByte7705(0x44);
}
void adc_read(void)
{
WriteByte7705(0x38);
temp=ReadWord7705();
WriteByte7705(0x39);
temp=ReadWord7705();
}