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.

TMS320F28377D: ADC Sampling Frequency(rate) setting

Part Number: TMS320F28377D
Other Parts Discussed in Thread: C2000WARE

Greetings for the day,

I am working on ADC peripheral of TMS320F28377D for my application. I wants to set ADC sampling frequency to 10KHz. I have reffered datasheet of F28377D and some E2E questions, but not able to find the solution. Please tell me how to set ADC Sampling frequency to 10Khz.

I am using adc_soc_software_sync example code from C2000 ware(ControlSuit).

Thank You.

Regards,

Balaji

  • Hi,

    The easiest way to sample at 10kHz with your ADC would be to use the adc_ex2_soc_epwm example. This triggers the ADC samples with an epwm signal, which you could configure to be a 10kHz pwm signal.

    Please let me know if you have any trouble with this.

    Best Regards,

    Ben Collier

  • Hi Ben Collier,

    Thank you for the response. The reason I am using adc_soc_software_sync examples beacuse I am having 3 analog inputs which should be converted in synch. I think for my application I should stick with this example.

     

    So is it not possible to change Sampling frequency in this example? If we can change means, how to do that?

    Regards,

    Balaji

  • Hi,

    I would still recommend that you use the epwm module to trigger your ADC conversions, since that doesn't require CPU overhead. It is possible to synchronously trigger all conversions with the epwm module, and you would just need a 10 kHz PWM signal. 

    It would be possible to change the sampling frequency in the adc_soc_software_sync example by adding some delay in the while(1) loop and removing the ESTOP0 command. I think a better way to do this, however, would be to use the CPU timer ISR to trigger the ADC conversion. The timer example shows how to set up the timer ISR, and you could copy from the adc_soc_software_sync to set up the ADC and trigger it with software.

    Best Regards,

    Ben Collier

  • Hi Ben Collier,

    Sure I will try as per your suggessions. 

    I have one doubt with respect ADC trigger source. I have code from different application(its ADC sampling frequency is 10KHz), in that ADC trigger source is configured as XBAR Input 5 i.e. GPIO4. I saw the schematics of that application, where 10KHz clock is connected to GPIO4. So is this clock is responsible for 10KHz sampling frequency? 

    If so, then can we set 48KHz sampling frequency by giving 48KHz clock on GPIO4 pin(XBAR Input 5)?

    I am attaching the snippet of ADC configuration and XBAR configuration from already implemented application(i.e. 10KHz sampling frequency code)

    ADC Configuration:

    AdcaRegs.ADCSOC0CTL.bit.CHSEL = 2; /*SOC0 will convert pin A2 and A3in differential mode*/
    AdcaRegs.ADCSOC0CTL.bit.ACQPS = acqps; /*sample window is acqps + 1 SYSCLK cycles*/
    AdcaRegs.ADCSOC0CTL.bit.TRIGSEL = 4; /*line 5 of the input X-BAR will trigger the ADC*/
    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*/

    XBAR Configuration:

    InputXbarRegs.INPUT5SELECT = 4; /*GPIO4 will trigger the input XBAR line 5*/
    GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0;
    GpioCtrlRegs.GPADIR.bit.GPIO4 = 0; /*GPIO4 is input*/
    GPIO_SetupXINT2Gpio(4); /*XINT2 connected to GPIO4*/
    XintRegs.XINT2CR.bit.POLARITY = 1; /*Rising edge interrupt*/
    XintRegs.XINT2CR.bit.ENABLE = 1; /*Enable XINT2*/

    I am little confused, how the ADC sampling frequency is configure. Please tell me how the sampling frequency is confiured to 10Khz in the above code.

    Thank You.

    Regards,

    Balaji

  • Hi,

    In your code snippets, it looks like the ADCA SOC0 will be triggered by the INPUT5 of the XBAR. I don't think that XINT2 is actually needed in this setup. 

    I think you are correct in assuming that a 48kHz clock on GPIO4 would result in a 48kHz sampling frequency.

    Best Regards,

    Ben Collier

  • Hi Benjamin Collier,

    Thank you for the clarification. Actually in our board we ahve only 10KHz clock connected to GPIO4. We dont have facility to connect 48KHz. 

    So if we wants to configure ADC with 48KHz sampling frequency means. What should we do? Can use this example adc_ex2_soc_epwm code? Or any other solution is there?

    Regards,

    Balaji

  • Hi,

    I would absolutely recommend the adc_ex2_soc_epwm example. It will show you how to configure an ePWM signal that will trigger as many ADC sample and conversions as you need, then you will just need to adjust the ePWM frequency. 

    Please let me know if you have any questions about how to do this.

    Best Regards,

    Ben Collier

  • Hi Benjamin Collier,

    I am not able to find adc_ex2_soc_epwm example in C2000Ware. There is only adc_soc_epwm example present. Is both same?

    What sampling frequency is configured in the above mentioned example? What all the registers I need to focus on for changing the sampling frequency to 48KHz and 12KHz?

    Thank You.

    Regards,

    Balaji TS 

  • Hi,

    What version of C2000WARE are you using? It may be the same, but I see this window when using the latest version:

    In the example, you will need to adjust the EPWM Counter Compare Value and the Time Base Period to adjust your sampling frequency: 

    It is probably best to read about the meaning of these values in the technical reference manual. Please let me know if you have any more questions. 

    Best Regards,

    Ben Collier

  • Hi Benjamin Collier,

    Thank you. I found the example. adc_ex2_soc_epwm example uses API's but I want to use registers. In C2000ware I found adc_soc_epwm in location C:\ti\C2000Ware_4_02_00_00\device_support\f2837xd\examples\cpu1\adc_soc_epwm. This exmaple configuration is similar to adc_ex2_soc_epwm example but adc_ex2_soc_epwm uses API's and adc_soc_epwm uses Registers.

    So can I use adc_soc_epwm example instead of adc_ex2_soc_epwm to generate 48KHz/12KHz sampling rate?

    Thank You.

    Regards,
    Balaji TS

  • Hi,

    Ok, you will be able to change the sampling rate by changing the period of the epwm signal. Please read the description at the top of the example and read the comments. To change the epwm period, you will need to write to the EPwm1Regs.TBPRD register. 

    Best Regards,

    Ben Collier

  • Hi Benjamin Collier,

    Thank you for your suggession.

    I will use adc_soc_epwm example and make the suggessed changes for genaring different sampling rates.

    Regards,

    Balaji

  • Ok, please let me know if you have any more questions.