大家帮我看一下为什么我的ADC结果寄存器的值为0呢,但是实际测得时候肯定有值,下边为我的程序:
#include "DSP2833x_Project.h" // Device Headerfile and Examples Include File
interrupt void adc_isr(void);
void adc_init(void);
Uint16 LoopCount;
Uint16 ConversionCount;
Uint16 Voltage1;
Uint16 Voltage2;
Uint16 A;
void main()
{
InitSysCtrl();
EALLOW;
#if (CPU_FRQ_150MHZ) // Default - 150 MHz SYSCLKOUT
#define ADC_MODCLK 0x3 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 150/(2*3) = 25.0 MHz
#endif
#if (CPU_FRQ_100MHZ)
#define ADC_MODCLK 0x2 // HSPCLK = SYSCLKOUT/2*ADC_MODCLK2 = 100/(2*2) = 25.0 MHz
#endif
EDIS;
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected register
PieVectTable.ADCINT = &adc_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
LoopCount = 0;
ConversionCount = 0;
A=0;
Voltage1=0;
Voltage2=0;
adc_init(); // For this example, init the ADC
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;//启动一次转换过程
// Wait for ADC interrupt
for(;;)
{
LoopCount++;
}
}
void adc_init(void)
{
InitAdc();
EALLOW;
SysCtrlRegs.HISPCP.all = ADC_MODCLK; // HSPCLK = SYSCLKOUT/ADC_MODCLK
EDIS;
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0; //核心时钟分频(不分频)
AdcRegs.ADCTRL1.bit.CPS = 1; //进行2分频,则ADCCLK=HSPCLK=12.5MHZ
AdcRegs.ADCTRL1.bit.ACQ_PS = 2; //采样窗口,即采样时间为3个1/12.5M=240ns
//工作模式设置
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; //级联模式
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0; //顺序采样
AdcRegs.ADCMAXCONV.all = 1; //2路信号
AdcRegs.ADCCHSELSEQ1.bit.CONV00=0x8; //转换通道为ADCINB0
AdcRegs.ADCCHSELSEQ1.bit.CONV01=0x9; //转换通道为ADCINB1
AdcRegs.ADCTRL1.bit.CONT_RUN = 0; //启动/停止模式
//AdcRegs.ADCTRL1.bit.SEQ_OVRD = 0; //允许完成MAX_CONV1+1次后回绕
//使能中断且设置启动转换ADC方式
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1; // Enable SEQ1 interrupt (every EOS)
AdcRegs.ADCTRL2.bit.INT_MOD_SEQ1 = 0; //INT_SEQ1的中断在每次SEQ1序列结束时被置位
}
interrupt void adc_isr(void)
{
Voltage1 = AdcRegs.ADCRESULT0 >>4;
Voltage2= AdcRegs.ADCRESULT1 >>4;
A=A+1;
// Reinitialize for next ADC sequence
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; // Clear INT SEQ1 bit
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge interrupt to PIE
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 1;//启动一次转换过程
//return;
}
|