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.

CCS/LAUNCHXL-F28379D: Simultaneous Sampling in F28379D

Expert 1985 points
Part Number: LAUNCHXL-F28379D
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

  • Hi Amin,

    You could duplicate the FPU_initADCA() function that's already in the example for a start and then change it so that it uses ADCB. From there you can change the other settings (like conversion trigger, channel, etc...)

    You can read through the descriptions of the ADC registers in the TRM for help www.ti.com/.../spruhm8

    Whitney
  • 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

  • Hi Amin,

    Sorry for not getting back to you sooner. I was out of the office for several days. Do you have any updates on your project? Did you get ePWM2 running again?

    Thanks,
    Whitney

  • Hi Whitney,

    Now it's working properly, but I do not know why it did not work the first time.
    By adding a second channel sampling frequency is halved?

    Thanks and regards,
    Amin
  • ADCA and ADCB are separate modules that can run simultaneously. Your sampling frequency should not be halved if one channel is on ADCA and the other on ADCB. Does it appear to be halved for you?

    Whitney
  • The problem was memory allocation(.cmd file). solved. Thank you.
    My last question is:
    You've said in previous posts:
    "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."
    What do you mean? I need to change part of the code ?
    Thanks for your help.

    Regards,
    Amin
  • I meant that ADCA and ADCB conversions will finish at the same time, so you don't need an interrupt from both ADCA and ADCB. A single interrupt from ADCA is sufficient to tell you that they are both done.

    In the code in FPU_initADCA(), this just means that you can set AdcbRegs.ADCINTSEL1N2.bit.INT1E to 0 instead of 1.

    Thanks,
    Whitney
  • Thanks for your help.

    Regards,
    Amin