电子元器件论坛
直播中

菠萝油和番薯仔的故事

7年用户 10经验值
私信 关注

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

利用附上的代码,实现与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.   }











回帖(3)

菠萝油和番薯仔的故事

2018-4-18 20:02:52
  1. #寄存器配置代码:
  2.   //AD7147寄存器设置,SETUP_7148_a(高位地址,低位地址,高位配置数据,低位配置数据)
  3.   //第一步设置:配置寄存器二,7个阶段即实现cin0:7的配置
  4.       //Stage0   - CIN0--CIN11(+)
  5.   SETUP_7148_a(0x00,0x80,0x2A,0xAA);
  6.   SETUP_7148_a(0x00,0x81,0x3A,0xAA);
  7.   SETUP_7148_a(0x00,0x82,0x01,0x00);
  8.   SETUP_7148_a(0x00,0x83,0x26,0x26);
  9.   SETUP_7148_a(0x00,0x84,0x20,0x00);
  10.   SETUP_7148_a(0x00,0x85,0x20,0x00);
  11.   SETUP_7148_a(0x00,0x86,0x20,0x00);
  12.   SETUP_7148_a(0x00,0x87,0x20,0x00);
  13.   
  14.     //Stage1   - CIN1(+)   
  15.   SETUP_7148_a(0x00,0x88,0x3F,0xFB);
  16.   SETUP_7148_a(0x00,0x89,0x3F,0xFF);
  17.   SETUP_7148_a(0x00,0x8A,0x01,0x00);
  18.   SETUP_7148_a(0x00,0x8B,0x26,0x26);
  19.   SETUP_7148_a(0x00,0x8C,0x20,0x00);
  20.   SETUP_7148_a(0x00,0x8D,0x20,0x00);
  21.   SETUP_7148_a(0x00,0x8E,0x20,0x00);
  22.   SETUP_7148_a(0x00,0x8F,0x20,0x00);
  23.   
  24.     //Stage2   - CIN2(+)
  25.   SETUP_7148_a(0x00,0x90,0x3F,0xEF);
  26.   SETUP_7148_a(0x00,0x91,0x1F,0xFF);
  27.   SETUP_7148_a(0x00,0x92,0x01,0x00);
  28.   SETUP_7148_a(0x00,0x93,0x26,0x26);
  29.   SETUP_7148_a(0x00,0x94,0x20,0x00);
  30.   SETUP_7148_a(0x00,0x95,0x20,0x00);
  31.   SETUP_7148_a(0x00,0x96,0x20,0x00);
  32.   SETUP_7148_a(0x00,0x97,0x20,0x00);
  33.   
  34.     //Stage3   - CIN3(+)
  35.   SETUP_7148_a(0x00,0x98,0x3F,0xBF);
  36.   SETUP_7148_a(0x00,0x99,0x1F,0xFF);
  37.   SETUP_7148_a(0x00,0x9A,0x01,0x00);
  38.   SETUP_7148_a(0x00,0x9B,0x26,0x26);
  39.   SETUP_7148_a(0x00,0x9C,0x20,0x00);
  40.   SETUP_7148_a(0x00,0x9D,0x20,0x00);
  41.   SETUP_7148_a(0x00,0x9E,0x20,0x00);
  42.   SETUP_7148_a(0x00,0x9F,0x20,0x00);
  43.   
  44.     //Stage4   - CIN4(+)
  45.   SETUP_7148_a(0x00,0xA0,0x3E,0xFF);
  46.   SETUP_7148_a(0x00,0xA1,0x1F,0xFF);
  47.   SETUP_7148_a(0x00,0xA2,0x01,0x00);
  48.   SETUP_7148_a(0x00,0xA3,0x26,0x26);
  49.   SETUP_7148_a(0x00,0xA4,0x20,0x00);
  50.   SETUP_7148_a(0x00,0xA5,0x20,0x00);
  51.   SETUP_7148_a(0x00,0xA6,0x20,0x00);
  52.   SETUP_7148_a(0x00,0xA7,0x20,0x00);
  53.   
  54.     //Stage5  - CIN5(+)
  55.   SETUP_7148_a(0x00,0xA8,0x3B,0xFF);
  56.   SETUP_7148_a(0x00,0xA9,0x1F,0xFF);
  57.   SETUP_7148_a(0x00,0xAA,0x01,0x00);
  58.   SETUP_7148_a(0x00,0xAB,0x26,0x26);
  59.   SETUP_7148_a(0x00,0xAC,0x20,0x00);
  60.   SETUP_7148_a(0x00,0xAD,0x20,0x00);
  61.   SETUP_7148_a(0x00,0xAE,0x20,0x00);
  62.   SETUP_7148_a(0x00,0xAF,0x20,0x00);


  63.     //Stage6   - CIN6(+)
  64.   SETUP_7148_a(0x00,0xb0,0x2F,0xFF);
  65.   SETUP_7148_a(0x00,0xb1,0x1F,0xFF);
  66.   SETUP_7148_a(0x00,0xb2,0x01,0x00);
  67.   SETUP_7148_a(0x00,0xb3,0x26,0x26);
  68.   SETUP_7148_a(0x00,0xb4,0x20,0x00);
  69.   SETUP_7148_a(0x00,0xb5,0x20,0x00);
  70.   SETUP_7148_a(0x00,0xb6,0x20,0x00);
  71.   SETUP_7148_a(0x00,0xb7,0x20,0x00);
  72.   
  73.     //Stage7   - CIN7(+)
  74.   SETUP_7148_a(0x00,0xb8,0x3F,0xFF);
  75.   SETUP_7148_a(0x00,0xb9,0x1F,0xFE);
  76.   SETUP_7148_a(0x00,0xbA,0x01,0x00);
  77.   SETUP_7148_a(0x00,0xbB,0x26,0x26);
  78.   SETUP_7148_a(0x00,0xbC,0x20,0x00);
  79.   SETUP_7148_a(0x00,0xbD,0x20,0x00);
  80.   SETUP_7148_a(0x00,0xbE,0x20,0x00);
  81.   SETUP_7148_a(0x00,0xbF,0x20,0x00);
  82.   
  83.    //Stage8  - CIN8(+)
  84.   SETUP_7148_a(0x00,0xC0,0x3F,0xFF);
  85.   SETUP_7148_a(0x00,0xC1,0x1F,0xFB);
  86.   SETUP_7148_a(0x00,0xC2,0x01,0x00);
  87.   SETUP_7148_a(0x00,0xC3,0x26,0x26);
  88.   SETUP_7148_a(0x00,0xC4,0x20,0x00);
  89.   SETUP_7148_a(0x00,0xC5,0x20,0x00);
  90.   SETUP_7148_a(0x00,0xC6,0x20,0x00);
  91.   SETUP_7148_a(0x00,0xC7,0x20,0x00);

  92.     //Stage9  -CIN9(+)
  93.   SETUP_7148_a(0x00,0xC8,0x3F,0xFF);
  94.   SETUP_7148_a(0x00,0xC9,0x1F,0xEF);
  95.   SETUP_7148_a(0x00,0xCa,0x01,0x00);
  96.   SETUP_7148_a(0x00,0xCb,0x26,0x26);
  97.   SETUP_7148_a(0x00,0xCc,0x20,0x00);
  98.   SETUP_7148_a(0x00,0xCd,0x20,0x00);
  99.   SETUP_7148_a(0x00,0xCe,0x20,0x00);
  100.   SETUP_7148_a(0x00,0xCf,0x20,0x00);
  101.   
  102.     //Stage10  -CIN10(+)
  103.   SETUP_7148_a(0x00,0xD0,0x3F,0xFF);
  104.   SETUP_7148_a(0x00,0xD1,0x1E,0xBF);
  105.   SETUP_7148_a(0x00,0xD2,0x01,0x00);
  106.   SETUP_7148_a(0x00,0xD3,0x26,0x26);
  107.   SETUP_7148_a(0x00,0xD4,0x20,0x00);
  108.   SETUP_7148_a(0x00,0xD5,0x20,0x00);
  109.   SETUP_7148_a(0x00,0xD6,0x20,0x00);
  110.   SETUP_7148_a(0x00,0xD7,0x20,0x00);
  111.   
  112.     //Stage11  -CIN11(+)
  113.   SETUP_7148_a(0x00,0xD8,0x3F,0xFF);
  114.   SETUP_7148_a(0x00,0xD9,0x1E,0xFF);
  115.   SETUP_7148_a(0x00,0xDa,0x01,0x00);
  116.   SETUP_7148_a(0x00,0xDb,0x26,0x26);
  117.   SETUP_7148_a(0x00,0xDc,0x20,0x00);
  118.   SETUP_7148_a(0x00,0xDd,0x20,0x00);
  119.   SETUP_7148_a(0x00,0xDe,0x20,0x00);
  120.   SETUP_7148_a(0x00,0xDf,0x20,0x00);
  121.   

  122.   //第二步设置:配置寄存器1
  123. //  SETUP_7148_a(0x00,0x00,0x02,0xB2);
  124.   SETUP_7148_a(0x00,0x00,0x01,0x12);
  125.   
  126.   get7148value(&MRD[1],&MRD[0],0x00,0x0A);
  127.   SETUP_7148_a(0x00,0x02,0x32,0x33);
  128.   SETUP_7148_a(0x00,0x03,0x08,0x19);
  129. //  SETUP_7148_a(0x00,0x02,0x32,0x3B);
  130. //  SETUP_7148_a(0x00,0x03,0x0A,0x19);
  131.   SETUP_7148_a(0x00,0x04,0x08,0x32);
  132.   SETUP_7148_a(0x00,0x05,0x00,0x00);
  133.   SETUP_7148_a(0x00,0x06,0x00,0x00);
  134.   SETUP_7148_a(0x00,0x07,0x00,0x01);
  135. //  SETUP_7148_a(0x00,0x07,0x00,0x00);
  136.   
  137.   //第三步设置
  138.   SETUP_7148_a(0x00,0x01,0x0f,0xff);

  139.   get7148value(&MRD[1],&MRD[0],0x00,0x0A);
  140.   
  141.   get7148value(&MRD[1],&MRD[0],0x00,0x17);
举报

菠萝油和番薯仔的故事

2018-4-18 20:05:06
从调试助手出来的结果是   : 00 01  00 01 14 72 A1 A5 94 98 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A1 A5 94 96 00……………………
举报

曲终人散

2018-4-19 10:03:51
好长的代码
举报

更多回帖

发帖
×
20
完善资料,
赚取积分