TI中文支持网
TI专业的中文技术问题咨询交流网站

28377d读取16路AD

通过epwm中断启动ADC采样,采样完成进入ADC中断。现在我是所有的中断都能正常进行,但是我的AD数据能读到一路不知道我那里配置错了。

EALLOW;

//
//write configurations
// AdcRegs.ADCSAMPLEMODE.bit.SIMULEN0 = 1;
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
AdcbRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

//
//Set pulse positions to late
//
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 1;

//
//power up the ADC
//
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;

//
//delay for 1ms to allow ADC time to power up
//

if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
{
acqps = 14; //75ns
}
else //resolution is 16-bit
{
acqps = 63; //320ns
}

//
//Select the channels to convert and end of conversion flag
//
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL =0;// channel; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C

AdcbRegs.ADCSOC0CTL.bit.CHSEL =8;// channel; //SOC0 will convert pin A0
AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is 100 SYSCLK cycles
AdcbRegs.ADCSOC8CTL.bit.TRIGSEL = 5;
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC0 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
EDIS;

interrupt void adca1_isr(void)
{

READAD();
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}

void READAD(void)
{
// static unsigned int m; //做AD采样判断用的
ReadADNUB=AdcaResultRegs.ADCRESULT0;
//AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1; //adc的seq1序列转换完成后,软件清零中断标志int_seq1
// Reinitialize for next ADC sequence
//AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1; // Reset SEQ1
}

Green Deng:

你好,程序中是采样率两路?但是你只能读取一路的数据?
AdcaRegs.ADCSOC0CTL.bit.CHSEL =0;

AdcbRegs.ADCSOC0CTL.bit.CHSEL =8;

TI有提供PWM触发ADC的例程,不知道你是否有参考?C:\ti\c2000\C2000Ware_3_03_00_00\device_support\f2837xd\examples\cpu1\adc_soc_epwm

赞(0)
未经允许不得转载:TI中文支持网 » 28377d读取16路AD
分享到: 更多 (0)