以下是我初始化ADC和CPUtimer0的程序,为何ADC上电程序为何要放在CPUtimer0初始化之前,即:
AdcPowerUp();
InitAdc();
InitCputimer();
否则就不能进入CPUtimer0的中断?
写成这样的话CPU中断就进不去:
InitCputimer();
AdcPowerUp();
InitAdc();
求大神们解答
void InitCputimer(void)
{ EALLOW;
CpuTimer0Regs.TPR.all = 149;
CpuTimer0Regs.TPRH.all= 0;
CpuTimer0Regs.PRD.all = 9999;
CpuTimer0Regs.TCR.all =0xf000;
EDIS;
}
void InitAdc(void)
{
AdcRegs.ADCTRL1.bit.SEQ_CASC = 0; //双序列工作模式
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0; //顺序采样
AdcRegs.ADCTRL1.bit.CONT_RUN = 0; //启停方式
AdcRegs.ADCTRL1.bit.CPS = 1; //核时钟预定标器:ADC_CLK=ADCLKPS/2=3.125M
AdcRegs.ADCTRL1.bit.ACQ_PS = 0xf; //采样窗口为16
AdcRegs.ADCTRL3.bit.ADCCLKPS = 0x2; //核时钟分频:ADCLKPS=HSPCLK/4=6.25M ;
AdcRegs.ADCMAXCONV.all = 0x0000; //转换通道数:1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0xf; //转换通道选择:ADCINB7
}
void AdcPowerUp(void)
{
Uint32 i;
AdcRegs.ADCTRL3.bit.ADCBGRFDN = 0x3; //ADC带隙和参考电路加电
for (i=0; i<1000000; i++){} //至少5ms延时
AdcRegs.ADCTRL3.bit.ADCPWDN = 1; //ADC核模拟电路加电
for (i=0; i<10000; i++){} //至少20us延时
} |