📄 ad.c
字号:
#include "DSP28_Device.h"
extern float a0[3];
extern int a1[3];
extern int b1[400];
extern int b2[400];
extern int b3[400];
extern int c1[3];
extern int c2[3];
extern int c3[3];
extern int temp;
extern int temp1;
extern int a3,aa2;
extern unsigned int a2;
extern float adclo;
extern int press,oxsg,flux;
extern int cishu;
// Prototype statements for functions found within this file.
//interrupt void ad(void);
//void Mid(int *d);
//void press_C(float x);
//void oxsg_C(float x);
//void flux_C(float x);
//void AD(void)
//{
//InitSysCtrl();
//DINT;
//IER = 0x0000;
//IFR = 0x0000;
//InitPieCtrl();
//PieCtrl.PIEIER1.bit.INTx6 = 1;
//InitPieVectTable();
//EALLOW; // This is needed to write to EALLOW protected registers
//PieVectTable.ADCINT=&ad;//对中断入口向量进行映射
//EDIS; // This is needed to disable write to EALLOW protected registers
//InitAdc();
// Enable INT14 which is connected to CPU-Timer 2:
//IER |= M_INT1;//使INT1口使能,因为ADC中断在此进入
//KickDog();
// Enable global Interrupts and higher priority real-time debug events:
//EINT; // Enable Global interrupt INTM//全局中断使能
//ERTM; // Enable Global realtime interrupt DBGM
// while(AdcRegs.ADC_ST_FLAG.bit.SEQ1_BSY==0)//当SEQ1处于空闲状态时
//{
//AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;// 启动数摸转换器
//aa2=1;
//}
//aa2=0;
//while(aa2==0)//等待中断
//{
// KickDog();
// }
//}
/*interrupt void ad(void)
{
IFR=0x0000;//
// PieCtrl.PIEIFR1.all = 0;
PieCtrl.PIEACK.all=0xffff;
a0[0]=((float)AdcRegs.RESULT0)*3.0/4095+adclo;
a0[1]=((float)AdcRegs.RESULT1)*3.0/4095+adclo;
a0[2]=((float)AdcRegs.RESULT2)*3.0/4095+adclo;
AdcRegs.ADC_ST_FLAG.bit.INT_SEQ1_CLR=1;//SEQ1中断复位以便下次执行中断
AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;//关断数摸转换
EINT;//中断返回
press_C(a0[0]);a1[0]=temp1;
oxsg_C(a0[1]);a1[1]=temp1;
flux_C(a0[2]);a1[2]=temp1;
c1[a2]=a1[0];
c2[a2]=a1[1];
c3[a2]=a1[2];
a2++;
if(a2==3)
{
Mid(c1);
b1[a3]=temp;
Mid(c2);
b2[a3]=temp;
Mid(c3);
b3[a3]=temp;
a2=0;a3++;
}
if(a3%30==0)
{press=b1[a3];oxsg=b2[a3];flux+=b3[a3];cishu++;}
if(a3==399)
{
a3=0;
}
aa2=0;
}
void Mid(int *d)
{
if((*d<*(d+1))&&(*(d+1)<*(d+2))||(*d>*(d+1))&&(*(d+1)>*(d+2)))
{
temp=(*(d+1));
}
if((*(d+1)<*d)&&(*d<*(d+2))||(*d<*(d+1))&&(*d>*(d+2)))
{
temp=(*d);
}
temp=(*(d+2));
}
void press_C(float x)
{
temp1=(int)(x*100/2.652);
}
void oxsg_C(float x)
{
temp1=(int)((x-2.106)/0.648*100);
}*/
//void flux_C(float x)
//{
//temp1=(int)();
//}
//===========================================================================
// No more.
//===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -