Other Parts Discussed in Thread: CONTROLSUITE
Tool/software: Code Composer Studio
Hi,
How can I add a second ADC channel (Simultaneous) to controlSUITE: "2837x_rfft_adc_rt" project?
Thank you for your help.
Regards,
Amin
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Code Composer Studio
Hi,
How can I add a second ADC channel (Simultaneous) to controlSUITE: "2837x_rfft_adc_rt" project?
Thank you for your help.
Regards,
Amin
Hi Whitney,
I did all changes, but for input signal in the second channel (ADC B2) does not accept data and does not work.
main.c :
uint16_t RFFTin1Buff[2*RFFT_SIZE];
uint16_t RFFTin2Buff[2*RFFT_SIZE];//<-----------------------------------new
__interrupt void adcaIsr()
{
RFFTin1Buff[sampleIndex++] = AdcaResultRegs.ADCRESULT0;
RFFTin2Buff[sampleIndex++] = AdcbResultRegs.ADCRESULT0;//<----------------------------new
if(sampleIndex == (RFFT_SIZE - 1) ){
sampleIndex = 0;
flagInputReady = 1;
}
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //clear INT1 flag//<----------------------------new
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}
examples_setup.c :
void FPU_initADCA(void)
{
EALLOW;
//write configurations
AdcaRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4
AdcbRegs.ADCCTL2.bit.PRESCALE = 6; //set ADCCLK divider to /4 //<-----------------------------------new
AdcSetMode(ADC_ADCA, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);
AdcSetMode(ADC_ADCB, ADC_RESOLUTION_12BIT, ADC_SIGNALMODE_SINGLE);//<-----------------------------------new
//Set pulse positions to early
AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 0;
AdcbRegs.ADCCTL1.bit.INTPULSEPOS = 0;//<-----------------------------------new
//power up the ADC
AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
AdcbRegs.ADCCTL1.bit.ADCPWDNZ = 1;//<-----------------------------------new
//delay for 1ms to allow ADC time to power up
DELAY_US(1000);
//Select the channels to convert and end of conversion flag ADCA
AdcaRegs.ADCSOC0CTL.bit.CHSEL = 0; //SOC0 will convert pin A0
AdcaRegs.ADCSOC0CTL.bit.ACQPS = 14; //sample window is 15 SYSCLK cycles
AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C
AdcaRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //EOC0 is set to trigger ADCINT1
AdcaRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag
AdcaRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared
AdcbRegs.ADCSOC0CTL.bit.CHSEL = 2; //SOC0 will convert pin A0//<-----------------------------------new
AdcbRegs.ADCSOC0CTL.bit.ACQPS = 14; //sample window is 15 SYSCLK cycles//<-----------------------------------new
AdcbRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //trigger on ePWM1 SOCA/C//<-----------------------------------new
AdcbRegs.ADCINTSEL1N2.bit.INT1SEL = 0; //EOC0 is set to trigger ADCINT1//<-----------------------------------new
AdcbRegs.ADCINTSEL1N2.bit.INT1E = 1; //enable INT1 flag//<-----------------------------------new
AdcbRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //make sure INT1 flag is cleared//<-----------------------------------new
EDIS;
}
Thanks for your help.
Regards,
Amin
The way you're incrementing sampleIndex looks off. I would think you would want to do something like:
RFFTin1Buff[sampleIndex] = AdcaResultRegs.ADCRESULT0;
RFFTin2Buff[sampleIndex++] = AdcbResultRegs.ADCRESULT0;
Also, there should be no need to enable the interrupt for ADCB. The conversions should finish simultaneously and you're reading both results in the same ISR.
If the fixes above don''t fix the issue, can you give me a little more details about what's going wrong? Are the results wrong? Are the conversions not triggering?
Whitney
Hi Whitney,
Thank you for your help. Both ADC channels working good.
What do you mean?:
"Also, there should be no need enable the interrupt for ADCB. The conversions should finish simultaneously and you're reading both results in the same ISR."
I realized after adding a second ADC channel pwm generator (ePWM2) does not work. All changes that have been shown in a previous post and I have not changed the default program(rfft_adc_rt).
Regards,
Amin