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

配置了三个ADC模块(ADCA/ADCB/ADCC),每个模块两路,但是只有A模块能收到采样数据

用的是F28379LaunchPAD,能否帮我看下哪里配置错误?

以下是代码

1.ADC配置函数

void ConfigureADC(void)
{
EALLOW;

//
//write configurations
//
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4 100Mhz/4=25Mhz
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);

AdccRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcSetMode(ADC_ADCC, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);

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

//
//power up the ADCs
//
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;
AdccRegs.ADCCTL1.bit.ADCPWDNZ = 1;
//
//delay for 1ms to allow ADC time to power up
//
DELAY_US(2000);

EDIS;
}

2.ADC设置函数

void SetupADC(void)//result0对应adc3管脚,result1对应adc2管脚
{
Uint16 acqps;

//
//determine minimum acquisition window (in SYSCLKS) based on resolution
//
if(ADC_RESOLUTION_12BIT == AdcaRegs.ADCCTL2.bit.RESOLUTION)
{
acqps = 29; //75ns
}
else //resolution is 16-bit
{
acqps = 63; //320ns
}
//
//Select the channels to convert and end of conversion flag
//ADCB
// 07h ADCTRIG7- ePWM2,ADCSOCA
//
EALLOW;
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 3; //SOC0 will convert pin A3
AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 0x07;//ePWM2,ADCSOCA

AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
// AdcaRegs.ADCINTSEL1N2.bit.INT1CONT = 1;//ADC Continuous Mode Enable

AdcbRegs.ADCSOC0CTL.bit.CHSEL = 3; //SOC1 will convert pin B3
AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 0x07;//ePWM2,ADCSOCA

AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC1 will set INT1 flag
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
// AdcbRegs.ADCINTSEL1N2.bit.INT1CONT = 1;//ADC Continuous Mode Enable

//ADCC
AdccRegs.ADCSOC0CTL.bit.CHSEL = 3; //SOC0 will convert pin C3
AdccRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 0x07;//ePWM2,ADCSOCA

AdccRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //end of SOC1 will set INT1 flag
AdccRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
// AdccRegs.ADCINTSEL1N2.bit.INT1CONT = 1;//ADC Continuous Mode Enable

//第二套
//A
AdcaRegs.ADCSOC1CTL.bit.CHSEL = 2; //SOC0 will convert pin A3
AdcaRegs.ADCSOC1CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdcaRegs.ADCSOC1CTL.bit.TRIGSEL = 0x07;//ePWM2,ADCSOCA

AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
//B
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC1 will convert pin B3
AdcbRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps +
AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 0x07;//ePWM2,ADCSOCA

AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
//ADCC
AdccRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC0 will convert pin C3
AdccRegs.ADCSOC0CTL.bit.ACQPS = acqps; //sample window is acqps + 1 SYSCLK cycles
AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 0x07;//ePWM2,ADCSOCA

AdccRegs.ADCINTSEL1N2.bit.INT1SEL = 1; //end of SOC1 will set INT1 flag
AdccRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdccRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
EDIS;
}

3.ADC启动函数

void StartADC(void)
{
EALLOW;
//start conversions immediately via software, ADCA
AdcaRegs.ADCSOCFRC1.all = 0x0003;//0x000f;//0x0001; //SOC0
//start conversions immediately via software, ADCB
AdcbRegs.ADCSOCFRC1.all = 0x0003;//0x000f;//0x0001; //SOC0
//start conversions immediately via software, ADCC
AdccRegs.ADCSOCFRC1.all = 0x000f; //SOC0,1,2,3/
EDIS;
}

4.主函数中ADC相关部分

ConfigureADC();
SetupADC();

5.PWM定时中断中ADC采样部分

__interrupt void epwm2_isr(void)
{   

StartADC();

GetADCResult();

//
// Clear INT flag for this timer
//
EPwm2Regs.ETCLR.bit.INT = 1;

//
// Acknowledge this interrupt to receive more interrupts from group 3
//
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}

Green Deng:

看了一下你的代码,没看出来有什么问题。你确定你测量用的PIN连接正确了吗?
屏蔽ADCA模块的话ADCB、ADCC模块能正常使用吗?

EE搬砖工:

回复 Green Deng:

感谢回复,已经可以了。是因为B/C模块SOC的配置错误导致的

Green Deng:

回复 EE搬砖工:

好的

赞(0)
未经允许不得转载:TI中文支持网 » 配置了三个ADC模块(ADCA/ADCB/ADCC),每个模块两路,但是只有A模块能收到采样数据
分享到: 更多 (0)