AD7147只出STAGE0的数值,其他stage的寄存器输出均为0

2019-07-17 10:33发布

利用附上的代码,实现与AD7147通信成功,但在AD7147的conversion sequence里面配置了12个stage运行,然后出来的结果只有stage0是有值的,从其他stage寄存器读出的值均为0。针对AD7147芯片手册重新配置了一遍AD7147,结果还是依旧,很迷惑。求高手解决!

配置描述:
寄存器2配置:
stage0   --CIN0(+)
stage1   --CIN1(+)
stage2   --CIN0(+)
stage3   --CIN3(+)
stage4   --CIN4(+)
stage5   --CIN5(+)
stage6   --CIN6(+)
stage7   --CIN7(+)
stage8   --CIN8(+)
stage9   --CIN9(+)
stage10   --CIN10(+)
stage11   --CIN11(+)
寄存器1配置
                          寄存器高位地址  低位地址   高位数据   低位数据  
  SETUP_7148_a(0x00                     ,0x00 ,     0x01,    0x12);

  SETUP_7148_a(0x00,                     0x02,          0x32,    0x33);
  SETUP_7148_a(0x00,                     0x03,          0x08,    0x19);

  SETUP_7148_a(0x00,                      0x04,         0x08,     0x32);
  SETUP_7148_a(0x00,                      0x05,          0x00,    0x00);
  SETUP_7148_a(0x00,                      0x06,          0x00,    0x00);
  SETUP_7148_a(0x00,                       0x07,          0x00,    0x01);

  SETUP_7148_a(0x00,                      0x01,          0x0f,       0xff);

  //AD7147寄存器设置,SETUP_7148_a(高位地址,低位地址,高位配置数据,低位配置数据)
  //第一步设置:配置寄存器二,7个阶段即实现cin0:7的配置
      //Stage0   - CIN0--CIN11(+)
  SETUP_7148_a(0x00,0x80,0x2A,0xAA);
  SETUP_7148_a(0x00,0x81,0x3A,0xAA);
  SETUP_7148_a(0x00,0x82,0x01,0x00);
  SETUP_7148_a(0x00,0x83,0x26,0x26);
  SETUP_7148_a(0x00,0x84,0x20,0x00);
  SETUP_7148_a(0x00,0x85,0x20,0x00);
  SETUP_7148_a(0x00,0x86,0x20,0x00);
  SETUP_7148_a(0x00,0x87,0x20,0x00);
  
    //Stage1   - CIN1(+)   
  SETUP_7148_a(0x00,0x88,0x3F,0xFB);
  SETUP_7148_a(0x00,0x89,0x3F,0xFF);
  SETUP_7148_a(0x00,0x8A,0x01,0x00);
  SETUP_7148_a(0x00,0x8B,0x26,0x26);
  SETUP_7148_a(0x00,0x8C,0x20,0x00);
  SETUP_7148_a(0x00,0x8D,0x20,0x00);
  SETUP_7148_a(0x00,0x8E,0x20,0x00);
  SETUP_7148_a(0x00,0x8F,0x20,0x00);
  
    //Stage2   - CIN2(+)
  SETUP_7148_a(0x00,0x90,0x3F,0xEF);
  SETUP_7148_a(0x00,0x91,0x1F,0xFF);
  SETUP_7148_a(0x00,0x92,0x01,0x00);
  SETUP_7148_a(0x00,0x93,0x26,0x26);
  SETUP_7148_a(0x00,0x94,0x20,0x00);
  SETUP_7148_a(0x00,0x95,0x20,0x00);
  SETUP_7148_a(0x00,0x96,0x20,0x00);
  SETUP_7148_a(0x00,0x97,0x20,0x00);
  
    //Stage3   - CIN3(+)
  SETUP_7148_a(0x00,0x98,0x3F,0xBF);
  SETUP_7148_a(0x00,0x99,0x1F,0xFF);
  SETUP_7148_a(0x00,0x9A,0x01,0x00);
  SETUP_7148_a(0x00,0x9B,0x26,0x26);
  SETUP_7148_a(0x00,0x9C,0x20,0x00);
  SETUP_7148_a(0x00,0x9D,0x20,0x00);
  SETUP_7148_a(0x00,0x9E,0x20,0x00);
  SETUP_7148_a(0x00,0x9F,0x20,0x00);
  
    //Stage4   - CIN4(+)
  SETUP_7148_a(0x00,0xA0,0x3E,0xFF);
  SETUP_7148_a(0x00,0xA1,0x1F,0xFF);
  SETUP_7148_a(0x00,0xA2,0x01,0x00);
  SETUP_7148_a(0x00,0xA3,0x26,0x26);
  SETUP_7148_a(0x00,0xA4,0x20,0x00);
  SETUP_7148_a(0x00,0xA5,0x20,0x00);
  SETUP_7148_a(0x00,0xA6,0x20,0x00);
  SETUP_7148_a(0x00,0xA7,0x20,0x00);
  
    //Stage5  - CIN5(+)
  SETUP_7148_a(0x00,0xA8,0x3B,0xFF);
  SETUP_7148_a(0x00,0xA9,0x1F,0xFF);
  SETUP_7148_a(0x00,0xAA,0x01,0x00);
  SETUP_7148_a(0x00,0xAB,0x26,0x26);
  SETUP_7148_a(0x00,0xAC,0x20,0x00);
  SETUP_7148_a(0x00,0xAD,0x20,0x00);
  SETUP_7148_a(0x00,0xAE,0x20,0x00);
  SETUP_7148_a(0x00,0xAF,0x20,0x00);


    //Stage6   - CIN6(+)
  SETUP_7148_a(0x00,0xb0,0x2F,0xFF);
  SETUP_7148_a(0x00,0xb1,0x1F,0xFF);
  SETUP_7148_a(0x00,0xb2,0x01,0x00);
  SETUP_7148_a(0x00,0xb3,0x26,0x26);
  SETUP_7148_a(0x00,0xb4,0x20,0x00);
  SETUP_7148_a(0x00,0xb5,0x20,0x00);
  SETUP_7148_a(0x00,0xb6,0x20,0x00);
  SETUP_7148_a(0x00,0xb7,0x20,0x00);
  
    //Stage7   - CIN7(+)
  SETUP_7148_a(0x00,0xb8,0x3F,0xFF);
  SETUP_7148_a(0x00,0xb9,0x1F,0xFE);
  SETUP_7148_a(0x00,0xbA,0x01,0x00);
  SETUP_7148_a(0x00,0xbB,0x26,0x26);
  SETUP_7148_a(0x00,0xbC,0x20,0x00);
  SETUP_7148_a(0x00,0xbD,0x20,0x00);
  SETUP_7148_a(0x00,0xbE,0x20,0x00);
  SETUP_7148_a(0x00,0xbF,0x20,0x00);
  
   //Stage8  - CIN8(+)
  SETUP_7148_a(0x00,0xC0,0x3F,0xFF);
  SETUP_7148_a(0x00,0xC1,0x1F,0xFB);
  SETUP_7148_a(0x00,0xC2,0x01,0x00);
  SETUP_7148_a(0x00,0xC3,0x26,0x26);
  SETUP_7148_a(0x00,0xC4,0x20,0x00);
  SETUP_7148_a(0x00,0xC5,0x20,0x00);
  SETUP_7148_a(0x00,0xC6,0x20,0x00);
  SETUP_7148_a(0x00,0xC7,0x20,0x00);

    //Stage9  -CIN9(+)
  SETUP_7148_a(0x00,0xC8,0x3F,0xFF);
  SETUP_7148_a(0x00,0xC9,0x1F,0xEF);
  SETUP_7148_a(0x00,0xCa,0x01,0x00);
  SETUP_7148_a(0x00,0xCb,0x26,0x26);
  SETUP_7148_a(0x00,0xCc,0x20,0x00);
  SETUP_7148_a(0x00,0xCd,0x20,0x00);
  SETUP_7148_a(0x00,0xCe,0x20,0x00);
  SETUP_7148_a(0x00,0xCf,0x20,0x00);
  
    //Stage10  -CIN10(+)
  SETUP_7148_a(0x00,0xD0,0x3F,0xFF);
  SETUP_7148_a(0x00,0xD1,0x1E,0xBF);
  SETUP_7148_a(0x00,0xD2,0x01,0x00);
  SETUP_7148_a(0x00,0xD3,0x26,0x26);
  SETUP_7148_a(0x00,0xD4,0x20,0x00);
  SETUP_7148_a(0x00,0xD5,0x20,0x00);
  SETUP_7148_a(0x00,0xD6,0x20,0x00);
  SETUP_7148_a(0x00,0xD7,0x20,0x00);
  
    //Stage11  -CIN11(+)
  SETUP_7148_a(0x00,0xD8,0x3F,0xFF);
  SETUP_7148_a(0x00,0xD9,0x1E,0xFF);
  SETUP_7148_a(0x00,0xDa,0x01,0x00);
  SETUP_7148_a(0x00,0xDb,0x26,0x26);
  SETUP_7148_a(0x00,0xDc,0x20,0x00);
  SETUP_7148_a(0x00,0xDd,0x20,0x00);
  SETUP_7148_a(0x00,0xDe,0x20,0x00);
  SETUP_7148_a(0x00,0xDf,0x20,0x00);
  

  //第二步设置:配置寄存器1
//  SETUP_7148_a(0x00,0x00,0x02,0xB2);
  SETUP_7148_a(0x00,0x00,0x01,0x12);
  
  get7148value(&MRD[1],&MRD[0],0x00,0x0A);
  SETUP_7148_a(0x00,0x02,0x32,0x33);
  SETUP_7148_a(0x00,0x03,0x08,0x19);
//  SETUP_7148_a(0x00,0x02,0x32,0x3B);
//  SETUP_7148_a(0x00,0x03,0x0A,0x19);
  SETUP_7148_a(0x00,0x04,0x08,0x32);
  SETUP_7148_a(0x00,0x05,0x00,0x00);
  SETUP_7148_a(0x00,0x06,0x00,0x00);
  SETUP_7148_a(0x00,0x07,0x00,0x01);
//  SETUP_7148_a(0x00,0x07,0x00,0x00);
  
  //第三步设置
  SETUP_7148_a(0x00,0x01,0x0f,0xff);

  get7148value(&MRD[1],&MRD[0],0x00,0x0A);
  
  get7148value(&MRD[1],&MRD[0],0x00,0x17);
  
#获取STAGE0--STAGE11数据
  1.   while(1)
  2.   {
  3.    
  4.    
  5.     //n=0;
  6.     //dat[0] =0;
  7.     //dat[1] =0;
  8.     //发送一帧数据,两个帧头,八个传感器数据,两个帧尾
  9.       sendbyte_uart(0xa1);  //帧头‘a1’
  10.       sendbyte_uart(0xa5);  //帧头‘a2’
  11.     //getAD7148value:主机向AD7148发送地址数据--从寄存器3读取数据存入MRD数组
  12.     //函数原型void get7148value(unsigned char *ph,unsigned char *pl,unsigned char addrh,unsigned char addrl)
  13.    
  14.     get7148value(&MRD[1],&MRD[0],0x00,0x0b);
  15.     get7148value(&MRD[1],&MRD[0],0x00,0x0c);
  16.     get7148value(&MRD[1],&MRD[0],0x00,0x0d);
  17.     get7148value(&MRD[1],&MRD[0],0x00,0x0e);
  18.     get7148value(&MRD[1],&MRD[0],0x00,0x0f);
  19.     get7148value(&MRD[1],&MRD[0],0x00,0x10);
  20.     get7148value(&MRD[1],&MRD[0],0x00,0x11);
  21.     get7148value(&MRD[1],&MRD[0],0x00,0x12);
  22.     get7148value(&MRD[1],&MRD[0],0x00,0x13);
  23.     get7148value(&MRD[1],&MRD[0],0x00,0x14);
  24.     get7148value(&MRD[1],&MRD[0],0x00,0x15);
  25.     get7148value(&MRD[1],&MRD[0],0x00,0x16);
  26.       //sendbyte_uart(dat[0]);
  27.       //sendbyte_uart(dat[1]);
  28.     delay(1);
  29.   }
复制代码










友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。