|
本帖最后由 linux-0405209 于 2017-6-7 12:31 编辑
(若发的板块不对,请告知修改)
环境: STM32F407 SPI3 AD7616
程序配置如下:
// AD7616 Reg addr
#define AD7616_CONFIG_REG 0x02
#define AD7616_CHANLE_REG 0x03
#define AD7616_PUINA1_REG 0x04
#define AD7616_PUINA2_REG 0x05
#define AD7616_PUINB1_REG 0x06
#define AD7616_PUINB2_REG 0x07
#define AD7616_STATUS_REG 0x08
#define AD7616_STACKx_REG(n) (0x20+n*0x01)
u16 parame[32] = {
0x88, 0x99, 0xBB, 0x00, 0x133, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// Init the range register, which has the register address = 0x04, 0x05, 0x06, 0x07
// set +/-10V for all channels
chanle = 0x00FF; //range:±10V
for(chanle = 0; chanle < 4; chanle++){
writeAD7616(AD7616_PUINA1_REG+chanle, chanle); //write ad7616 reg
dd1 = readAD7616(AD7616_PUINA1_REG+chanle); //read ad7616 reg, return 16bit data
while(dd1 != chanle){
writeAD7616(AD7616_PUINA1_REG+chanle, chanle);
dd1 = readAD7616(AD7616_PUINA1_REG+chanle);
}
}
// Init Sequencer
// Set the sequencer as Vcc->ALDO->self testing->0->3
for(chanle = 0; chanle < 32; chanle++){
writeAD7616(AD7616_STACKx_REG(chanle), parame[chanle]);
dd1 = readAD7616(AD7616_STACKx_REG(chanle));
while(dd1 != parame[chanle]){
writeAD7616(AD7616_STACKx_REG(chanle), parame[chanle]);
dd1 = readAD7616(AD7616_STACKx_REG(chanle));
}
}
// Init the configuration register, which has the register address = 0x02
// bit 7 - self error dection, '1' error, '0' no error
// bit 6 - set '1' to active the burst mode, set '0' to disable
// bit 5 - set '1' to active the auto sequencer, set '0' to disable
// bit 4~2 - "000" no OS; "001" OS by 2, "010" OS by 4, ... "111" OS by 128
// bit 1 - set '1' to output the status word after conversion data, set '0' to disable
// bit 0 - set '1' to output the CRC word after conversion/status data, set '0' to disable
chanle = 0x007E;
writeAD7616(AD7616_CONFIG_REG, chanle);
dd1 = readAD7616(AD7616_CONFIG_REG);
while(dd1 != chanle){
writeAD7616(AD7616_CONFIG_REG, chanle);
dd1 = readAD7616(AD7616_CONFIG_REG);
}
以上的配置在我的程序中读写都能正确显示;
以下为采集回来的数据显示:
以上为串口终端显示的内容
> chanle[00]: 3944 ----> 4.473877 // 此处为Acc数据 Acc万用表量得为4.92V
> chanle[01]: 3D9B ----> 4.812927 // 此处为Acc数据
> chanle[02]: CC0C ----> -4.058838 // 此处为ALDO数据 ALDO应该为1.8V,在手册上写着
> chanle[03]: CA79 ----> -4.181824 // 此处为ALDO数据
> chanle[04]: AAAA ----> -6.666870 // 此处为自测通道A数据 在手册上写着固定返回AAAA
> chanle[05]: 5555 ----> 6.666565 // 此处为自测通道B数据 在手册上写着固定返回5555
> chanle[06]: 1D5D ----> 2.294006 // 此处为自测通道A0数据 次通道接入一个直流4.1V左右
> chanle[07]: E8CD ----> -1.812439 // 此处为自测通道B0数据 没接入
> chanle[08]: E8C7 ----> -1.814270 // 此处为自测通道A3数据 没接入
> chanle[09]: E8CC ----> -1.812744 // 此处为自测通道B3数据 没接入
> chanle[10]: 3327 ----> 3.996277 // 此处为状态寄存器的数据
从上面数据可见:
返回来的数据 通道A0 B0 A3 B3都有一个1.8V左右的偏差;
但读回来的自测通道和状态寄存器的值是准确的;
Acc的数值就有点偏;
ALDO是错的比较离谱了;
各位有谁调试过AD7616的给点提示,这问题纠结几天了,还没解决,在这谢谢各位。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
阿莫论坛20周年了!感谢大家的支持与爱护!!
月入3000的是反美的。收入3万是亲美的。收入30万是移民美国的。收入300万是取得绿卡后回国,教唆那些3000来反美的!
|