有没有用过ADS7864的朋友 求教!
最近在调一块ads7864的板子,发现内置输出的基准电压时而不准,不知道是什么问题
还有就是采样保持之后去读输出数据,总是有时能读到 ,有时读不到,或者读出的不对,怀疑是时序的问题,求教各位高手,能不能给个详细的例程演示!
1、REF问题
请再REFout管脚接两个电容,10uF和0.1uF。
2、读输出数据
跟你的应用的模式有关系,Cycle mode还是FIFO mode, 根据中断来读取还是查询读取。
软件流程是怎么样的?
没有ADS7864的,
给一个类似的ADS8363的,是16位版本的,可以参照一下。
这个是中断读取的函数:
void IRQ_TIME0(void)
{
int16 i = 0;
uint32 bak1 = 0; /*中断嵌套设置*/
bak1 = VICIntEnable; /*备份初始中断使能设置*/
VICIntEnClr = (1<<4)|(1<<5)|(1<<9)|(1<<13); /*屏蔽当前优先级以及比当前优先级别低的中断*/
VICVectAddr = 0x00; /*重写向量中断地址重置优先级别*/
T0IR = 1; /*清除定时器0中断标志*/
T0TCR = 0x00; /*重新设置采样频率*/
T0TC = 0;
T0PR = 0;
T0MCR = 0x03;
TimerAD = Pinlvf*64/100;
if(TimerAD>3840 || TimerAD<2560) TimerAD = 3200;
T0MR0 = Fpclk/TimerAD - 87; /*重置采样频率*/
T0TCR = 0x01;
//AD CONVST引脚:P1.23
IO1CLR = IO1CLR | (1<<23); /*启动AD转换*/
Delay(1);
IO1SET = IO1SET | (1<<23);
Delay(5);
Convnum--;
if(Convnum > 200) Convnum = AD_NUM - 1;
EnableIRQ(); /*开中断,允许高优先级别中断打断当前中断*/
/*读取U6的采样值*/
low_ad = AD_RESULT1;
low_ad = AD_RESULT1;
high_ad = AD_RESULT1;
ADresult[CH_UC][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT1;
low_ad = AD_RESULT1;
high_ad = AD_RESULT1;
ADresult[CH_UB][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT1;
low_ad = AD_RESULT1;
high_ad = AD_RESULT1;
ADresult[CH_UA][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT1;
low_ad = AD_RESULT1;
high_ad = AD_RESULT1;
ADresult[CH_ICm][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT1;
low_ad = AD_RESULT1;
high_ad = AD_RESULT1;
ADresult[CH_IBm][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT1;
low_ad = AD_RESULT1;
high_ad = AD_RESULT1;
ADresult[CH_IAm][Convnum] = low_ad + (high_ad<<8);
/*读取U5的采样值*/
low_ad = AD_RESULT2;
low_ad = AD_RESULT2;
high_ad = AD_RESULT2;
ADresult[CH_UN][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT2;
low_ad = AD_RESULT2;
high_ad = AD_RESULT2;
ADresult[CH_US][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT2;
low_ad = AD_RESULT2;
high_ad = AD_RESULT2;
ADresult[CH_IN][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT2;
low_ad = AD_RESULT2;
high_ad = AD_RESULT2;
ADresult[CH_ICp][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT2;
low_ad = AD_RESULT2;
high_ad = AD_RESULT2;
ADresult[CH_IBp][Convnum] = low_ad + (high_ad<<8);
low_ad = AD_RESULT2;
low_ad = AD_RESULT2;
high_ad = AD_RESULT2;
ADresult[CH_IAp][Convnum] = low_ad + (high_ad<<8);
Delay(1);
Yxchaxun(); /*遥信采集*/
if (t_tap >= 3) /*16点录波*/
{
Report_gzlb(); /*故障录波*/
t_tap = 0;
}
else
{
t_tap++;
}
soft_freq(ADresult[CH_US],Convnum);/*软件测频*/
/*计算零漂值*/
s_pr_num--;
if (s_pr_num < 0)
{
s_pr_num = SPRNUM - 1;
for (i = CH_NUM- 1; i >= 0 ;i-- )
{
s_pr[1][i] = s_pr[0][i]/SPRNUM;
s_pr[0][i] = 0;
}
}
else
{
for (i = CH_NUM- 1; i >= 0 ;i-- )
{
s_pr[0][i] += ADresult[i][Convnum];
}
}
VICIntEnable = bak1; /*恢复初始中断使能设置*/
}