看程序吧一、主程序:
#include "DSP28_Device.h"
float ADResult;
unsigned int k=0;
float adclo;
interrupt void ADC_ISR(void);
void main(void)
{
InitSysCtrl(); //初始化系统
DINT; //关中断
IER = 0x0000;
IFR = 0x0000;
InitPieCtrl(); //初始化PIE控制寄存器
InitPieVectTable(); //初始化PIE参数表
InitEv();
InitAdc(); //初始化ADC
adclo=0;
PieCtrl.PIEIER1.bit.INTx6=1;
EALLOW;
PieVectTable.ADCINT=&ADC_ISR;
EDIS;
IER |= M_INT1; // Enable INT14 which is connected to CPU-Timer 2:
EINT; // Enable INTM
ERTM; // Enable DBGM
EvaRegs.T1CON.bit.TENABLE=1;
for(;;)
{
}
}
interrupt void ADC_ISR(void)
{
ADResult=((AdcRegs.RESULT0>>4)*3)/4095.0+adclo;
PieCtrl.PIEACK.all=0x0001;
AdcRegs.ADC_ST_FLAG.bit.INT_SEQ1_CLR=1;
AdcRegs.ADCTRL2.bit.RST_SEQ1=1; //在这里设置断点
EINT;
} |