在线调试时,为什么程序跑到3F806D 6F00 SB 0,UNC 就停住了?
[复制链接]
想利用2812实现简单的四路AD转换,主程序编写如下,可在线调试时,一跑到3F806D就停住了,四路a1,a2,a3,a4固定为77,不知道为什么,求大牛赐教,感激不尽!
interrupt void adc_isr(void);
Uint16 a1;
Uint16 a2;
Uint16 a3;
Uint16 a4;
main()
{
InitSysCtrl();
EALLOW;
SysCtrlRegs.HISPCP.all = 0x3; // HSPCLK = SYSCLKOUT/6
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
InitAdc(); // For this example, init the ADC
PieCtrlRegs.PIEIER1.bit.INTx6 = 1;
IER |= M_INT1; // Enable CPU Interrupt 1
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
AdcRegs.ADCTRL1.bit.RESET=1;
asm("NOP");
AdcRegs.ADCTRL1.bit.RESET=0;
AdcRegs.ADCTRL1.bit.SUSMOD=3;
AdcRegs.ADCTRL1.bit.ACQ_PS=0;
AdcRegs.ADCTRL1.bit.CPS=0;
AdcRegs.ADCTRL1.bit.CONT_RUN=1; //连续运转模式,当接收到EOC信号后,排序器将从CONV00(对于SEQ1)状态重新开始装换
AdcRegs.ADCTRL1.bit.SEQ_CASC=1; //级联模式,SEQ1与SEQ2作为一个单16状态序列发生器操作
AdcRegs.ADCTRL3.bit.ADCCLKPS=1;
AdcRegs.ADCTRL3.bit.SMODE_SEL=0;
AdcRegs.ADCMAXCONV.all = 0x0003; // Setup 2 conv's on SEQ1
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x2; // Setup ADCINA2 as 1st SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x3; // Setup ADCINA3 as 2nd SEQ1 conv.
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x4;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x5;
AdcRegs.ADCTRL2.bit.EVB_SOC_SEQ=0;
AdcRegs.ADCTRL2.bit.RST_SEQ1=0;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1=1;
AdcRegs.ADCTRL2.bit.INT_MOD_SEQ1=0;
AdcRegs.ADCTRL2.bit.EVA_SOC_SEQ1=0;
AdcRegs.ADCTRL2.bit.EXT_SOC_SEQ1=0;
AdcRegs.ADCTRL2.bit.RST_SEQ2=0;
AdcRegs.ADCTRL2.bit.SOC_SEQ2=0;
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ2=0;
AdcRegs.ADCTRL2.bit.INT_MOD_SEQ2=0;
AdcRegs.ADCTRL2.bit.EVB_SOC_SEQ2=0;
while(AdcRegs.ADCST.bit.SEQ1_BSY==0)
{
AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;
}
}
interrupt void adc_isr(void)
{
a1 = AdcRegs.ADCRESULT0 >>4;
a2 = AdcRegs.ADCRESULT1 >>4;
a3 = AdcRegs.ADCRESULT2 >>4;
a4 = AdcRegs.ADCRESULT3 >>4;
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
return;
}