我现在想要采集ADCINA0-ADCINA7的输入电压,通过DMA传输,一直连续不断采集,我的配置代码如下
EALLOW;
SysCtrlRegs.HISPCP.all = ADC_MODCLK; // 150 / (2*3) = 25M
EDIS;
InitAdc();
AdcRegs.ADCTRL1.bit.ACQ_PS = ADC_SHCLK; // Sequential mode: Sample rate = 1/[(2+ACQ_PS)*ADC clock in ns]
// = 1/(2*40ns) =12.5MHz (for 150 MHz SYSCLKOUT)
AdcRegs.ADCTRL3.bit.ADCCLKPS = ADC_CKPS; // ADC module clock = HSPCLK/1 = 25.5MHz/(1) = 25.0 MHz
AdcRegs.ADCTRL1.bit.CPS = 0;
AdcRegs.ADCTRL1.bit.SEQ_CASC = 1; // 级联操作模式
AdcRegs.ADCTRL1.bit.CONT_RUN = 1; // 连续模式
AdcRegs.ADCTRL3.bit.SMODE_SEL = 0; // 顺序采样
AdcRegs.ADCTRL1.bit.SEQ_OVRD = 1; // Enable Sequencer override feature
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 7; // 8个转换通道
AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 0x1; // 中断启用
AdcRegs.ADCTRL2.bit.RST_SEQ1 = 0x1;
AdcRegs.ADCMAXCONV.bit.MAX_CONV1 = 7; // 8个转换通道
AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0x0; //ADCINA0
AdcRegs.ADCCHSELSEQ1.bit.CONV01 = 0x1; //ADCINA1
AdcRegs.ADCCHSELSEQ1.bit.CONV02 = 0x2;
AdcRegs.ADCCHSELSEQ1.bit.CONV03 = 0x3;
AdcRegs.ADCCHSELSEQ2.bit.CONV04 = 0x4;
AdcRegs.ADCCHSELSEQ2.bit.CONV05 = 0x5;
AdcRegs.ADCCHSELSEQ2.bit.CONV06 = 0x6;
AdcRegs.ADCCHSELSEQ2.bit.CONV07 = 0x7;
dmadest = dma_adcbuf;
dmasource = &AdcMirror.ADCRESULT0; //Point DMA source to ADC result register base
DMACH1AddrConfig(dmadest, dmasource);
DMACH1BurstConfig(7, 1, 10);
DMACH1TransferConfig(9, 1, 1);
DMACH1WrapConfig(1, 0, 80, 0);
DMACH1ModeConfig(DMA_SEQ1INT, PERINT_ENABLE,ONESHOT_DISABLE, CONT_DISABLE,SYNC_DISABLE, SYNC_SRC,OVRFLOW_DISABLE, SIXTEEN_BIT,CHINT_END, CHINT_ENABLE);
StartDMACH1();
AdcRegs.ADCTRL2.bit.SOC_SEQ1 = 0x1;
并配置了相应的中断函数,但是我发现,传输完成进入到中断函数之后,貌似不会再继续采集转换了,并且发现每次采集到的值并不是那么准确,请问是我的配置有问题吗
Green Deng:
你可以参考一下TI的官方例程,例程就是ADC采样之后通过DMA传输的:C:\ti\c2000\C2000Ware_3_02_00_00\device_support\f2833x\examples\adc_dma
Tony Liu4:
回复 Green Deng:
参考的就是例程,我发现也是进了中断,然后处理完我采集到的数据之后,不会接着采集,不会进第二次中断了