在使用EPwm中断的程序中,我将ADC初始化InitAdc()函数放在EPWM模块的TBCLK(时基时钟)关闭和开启前,AdcResult全为0,如果放在TBCLK(时基时钟)关闭和开启后,AdcResult就有值。
想请问下这是什么问题。
我不确定我是否理解您的问题。 您的问题是 ADC 被意外触发了吗?
void InitAdc(void)
{
extern void DSP28x_usDelay(Uint32 Count);
// *IMPORTANT*
// The Device_cal function, which copies the ADC calibration values from TI reserved
// OTP into the ADCREFSEL and ADCOFFTRIM registers, occurs automatically in the
// Boot ROM. If the boot ROM code is bypassed during the debug process, the
// following function MUST be called for the ADC to function according
// to specification. The clocks to the ADC MUST be enabled before calling this
// function.
// See the device data manual and/or the ADC Reference
// Manual for more information.
EALLOW;
SysCtrlRegs.PCLKCR0.bit.ADCENCLK = 1;
(*Device_cal)();
EDIS;
// To powerup the ADC the ADCENCLK bit should be set first to enable
// clocks, followed by powering up the bandgap, reference circuitry, and ADC core.
// Before the first conversion is performed a 5ms delay must be observed
// after power up to give all analog circuits time to power up and settle
// Please note that for the delay function below to operate correctly the
// CPU_RATE define statement in the DSP2803x_Examples.h file must
// contain the correct CPU clock period in nanoseconds.
EALLOW;
AdcRegs.ADCCTL1.bit.ADCBGPWD = 1; // Power ADC BG
AdcRegs.ADCCTL1.bit.ADCREFPWD = 1; // Power reference
AdcRegs.ADCCTL1.bit.ADCPWDN = 1; // Power ADC
AdcRegs.ADCCTL1.bit.ADCENABLE = 1; // Enable ADC
AdcRegs.ADCCTL1.bit.ADCREFSEL = 0; // Select interal BG
EDIS;
DELAY_US(ADC_usDELAY); // Delay before converting ADC channels
}
您好,
为了更快地跟进您的问题,以及便于其他人查阅,请您再开一个新帖,感谢您的配合。
您能否分享您的 ADC 设置? 您使用哪一个 PWM 作为触发器?
void ADC28035_Init(void)
{
EALLOW;
AdcRegs.ADCCTL1.bit.INTPULSEPOS = 1; // ʼ
AdcRegs.INTSEL1N2.bit.INT1E = 1;
AdcRegs.INTSEL1N2.bit.INT1CONT = 1;
AdcRegs.INTSEL1N2.bit.INT2CONT = 1;
AdcRegs.INTSEL1N2.bit.INT1SEL = 0;
AdcRegs.INTSEL1N2.bit.INT2SEL = 0;
AdcRegs.ADCSOC0CTL.bit.CHSEL = 0; //set SOC0 channel select to ADCINA0SOC0 ƼĴ SOC15 ƼĴ
AdcRegs.ADCSOC1CTL.bit.CHSEL = 1; //set SOC1 channel select to ADCINA1
AdcRegs.ADCSOC2CTL.bit.CHSEL = 2; //set SOC2 channel select to ADCINA2
AdcRegs.ADCSOC3CTL.bit.CHSEL = 3; //set SOC3 channel select to ADCINA3
AdcRegs.ADCSOC4CTL.bit.CHSEL = 4; //set SOC4 channel select to ADCINA4
AdcRegs.ADCSOC5CTL.bit.CHSEL = 5;
AdcRegs.ADCSOC6CTL.bit.CHSEL = 6;
AdcRegs.ADCSOC7CTL.bit.CHSEL = 7;
AdcRegs.ADCSOC8CTL.bit.CHSEL = 8;
AdcRegs.ADCSOC9CTL.bit.CHSEL = 9;
AdcRegs.ADCSOC10CTL.bit.CHSEL = 10; //set SOC4 channel select to ADCINA4
AdcRegs.ADCSOC11CTL.bit.CHSEL = 11;
AdcRegs.ADCSOC12CTL.bit.CHSEL = 12;
AdcRegs.ADCSOC13CTL.bit.CHSEL = 13;
AdcRegs.ADCSOC14CTL.bit.CHSEL = 5;
AdcRegs.ADCSOC15CTL.bit.CHSEL = 5;
//SOCx Դѡ λ
AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 1; //set SOC0 start trigger on TIME0, due to round-robin SOC0 converts first then SOC1
AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 1; //set SOC1 start trigger on TIME0, due to round-robin SOC0 converts first then SOC1
AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 1; //set SOC2 start trigger on TIME0, due to round-robin SOC0 converts first then SOC1
AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 1; //set SOC3 start trigger on TIME0, due to round-robin SOC0 converts first then SOC1
AdcRegs.ADCSOC4CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC5CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC6CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC7CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC8CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC9CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC10CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC11CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC12CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC13CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC14CTL.bit.TRIGSEL = 1;
AdcRegs.ADCSOC15CTL.bit.TRIGSEL = 1;
//SOCx ɼ Ԥ Ƶ λ λ ڿ SOCx / ִ ڵij ȣ Сֵ Ϊ 6
AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC2CTL.bit.ACQPS = 6; //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC3CTL.bit.ACQPS = 6; //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
AdcRegs.ADCSOC4CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC5CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC6CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC7CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC8CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC9CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC10CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC11CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC12CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC13CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC14CTL.bit.ACQPS = 6;
AdcRegs.ADCSOC15CTL.bit.ACQPS = 6;
EDIS;
EALLOW;
AdcRegs.ADCSOCFRC1.all=0xffff; // ǿ ƴ ʹ
AdcRegs.ADCINTSOCSEL1.all=0x5555; // Ӧ Ҫ С
// AdcRegs.ADCINTSOCSEL2.all=0x5555;
EDIS;
}
这是我的ADC配置,没有使用PWM触发,是在配置下图EPWM时钟时,如果把ADC配置放到下图后面就会导致ADC的值一直为0,。
您好,
一般来说,在将SOC脉冲发送到ADC之前配置ADC是一个好主意。