已回答假定已回答

ad7172-2多通道切换的问题

xiaomeng_ 在 2016-11-12 詢問的問題
最後回覆由xiaomeng_於2016-11-16提供

         您好!

          1.如何利用RDY引脚触发SPI中断进行数据接收?

          2.另外我现在需要采集多路模拟信号,但是在进行通道切换的时候无法正常读取数据,我通过置位接口模式寄存器配置中的AD717X_IFMODE_REG_DATA_STAT位,数据输出为32位,[24..31]位为状态寄存器的值,以此来判断我每次读取的是哪个通道的。寄存器初始化配置如下:

ad717x_st_reg ad7172_2_regs[] =

{

       { AD717X_STATUS_REG, 0x00, 1 },

       { AD717X_ADCMODE_REG, 0x0000, 2 },

       {

            AD717X_IFMODE_REG,

            AD717X_IFMODE_REG_DOUT_RESET | AD717X_IFMODE_REG_CRC_EN |             AD717X_IFMODE_REG_DATA_STAT,

            2

       },

       { AD717X_REGCHECK_REG, 0x0000, 3},

       { AD717X_DATA_REG, 0x0000, 4 },

       { AD717X_GPIOCON_REG, 0x0000, 2 },

       { AD717X_ID_REG, 0x0000, 2 },

       {

            AD717X_CHMAP0_REG,

            AD717X_CHMAP_REG_CH_EN | AD717X_CHMAP_REG_AINPOS(0) | AD717X_CHMAP_REG_AINNEG(0x16), 

            2

       },

       {

            AD717X_CHMAP1_REG,

            AD717X_CHMAP_REG_CH_EN,| AD717X_CHMAP_REG_AINPOS(1) | AD717X_CHMAP_REG_AINNEG(0x16), 

            2

       },

       {

            AD717X_CHMAP2_REG,

            AD717X_CHMAP_REG_CH_EN | AD717X_CHMAP_REG_AINPOS(2) | AD717X_CHMAP_REG_AINNEG(0x16), 

            2

       },

       {

            AD717X_CHMAP3_REG,

            AD717X_CHMAP_REG_CH_EN | AD717X_CHMAP_REG_AINPOS(3) | AD717X_CHMAP_REG_AINNEG(0x16),  

            2

       },

       { AD717X_SETUPCON0_REG, 0x0000, 2 },

       { AD717X_SETUPCON1_REG, 0x0000, 2 },

       { AD717X_SETUPCON2_REG, 0x0000, 2 },

       { AD717X_SETUPCON3_REG, 0x0000, 2 },

       {

            AD717X_FILTCON0_REG,

            /*通道0 滤波器设置:*/

            AD717X_FILT_CONF_REG_ENHFILT(2) | AD717X_FILT_CONF_REG_ODR(14),

            2

       },

       {

            AD717X_FILTCON1_REG,

            AD717X_FILT_CONF_REG_ENHFILT(2),

            2

       },

       {

            AD717X_FILTCON2_REG,

            AD717X_FILT_CONF_REG_ENHFILT(2),

            2

       },

       {

            AD717X_FILTCON3_REG,

            AD717X_FILT_CONF_REG_ENHFILT(2),

            2

        },

        { AD717X_OFFSET0_REG, 0, 3 },

       { AD717X_OFFSET1_REG, 0, 3 },

       { AD717X_OFFSET2_REG, 0, 3 },

       { AD717X_OFFSET3_REG, 0, 3 },

       { AD717X_GAIN0_REG, 0, 3 },

       { AD717X_GAIN1_REG, 0, 3 },

       { AD717X_GAIN2_REG, 0, 3 },

       { AD717X_GAIN3_REG, 0, 3 },

};

 

数据读取如下:

void Get_AD717X_Data(void)

{

     AD717X_ReadData(&my_ad7172_2,&AD7172_Data);

     switch((uint8_t)(AD7172_Data>>24)&0x3)

     {

          case 0x00: buf[0]= AD7172_Data&(0xffffff);break;

          case 0x01: buf[1]= AD7172_Data&(0xffffff);break;

          case 0x02: buf[2]= AD7172_Data&(0xffffff);break;

          case 0x03: buf[3]= AD7172_Data&(0xffffff);break;

          default:break;

     }

}

結果