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/TMS320F28377D: How to make the ADC sampling every 2 or 3 switching cycles?

Part Number: TMS320F28377D

Tool/software: Code Composer Studio

Hi,

In my circuit, the switching frequency is 300kHz, so the switching time is 3.3us.

SOC starts on the epwm CTR=0 match,  so ADC happens every switching cycle. Please see below the blue one, which is ePWM counter, and at the time of A1, A2, A3, SOC occurs.

I think my time is not enough, so I want to do ADCs every 2 switching cycles. Please see below the red one, which includes two switching cycles or 2 original ePWM counters. How to do it or what is the settings?

Thanks!

  • Is this right if I make the following setting? Does this mean the SOCs occurs every 2 switching cycles? I don't know how to check to see if it is right or not?
    EPwm10Regs.ETPS.bit.SOCAPRD = 2; //Generate pulse on 2st event, 150kHz sampling freq.
    Do I miss some settings? -Thanks!

    void InitEPwm10(void) //for sampling
    {
    EALLOW;
    SyncSocRegs.SYNCSELECT.bit.EPWM10SYNCIN=0;

    EPwm10Regs.TBCTL.bit.CTRMODE = 3; // Freeze counter for now
    EPwm10Regs.TBPRD = SW_PRD; // 300kHz switching frequency
    EPwm10Regs.TBCTR = 0x0000; // Clear counter
    EPwm10Regs.TBCTL.bit.HSPCLKDIV = 0;//MAX speed 100MHz; set ratio to 1/2 SYSCLK
    EPwm10Regs.TBCTL.bit.CLKDIV = 0; // same as HSPCLKDIV?

    EPwm10Regs.ETSEL.bit.SOCAEN = 0; // Disable SOC on A group
    EPwm10Regs.ETSEL.bit.SOCASEL = 1; //Select SOCA on - 1: zero,
    EPwm10Regs.ETPS.bit.SOCAPRD = 2; //Gen. pulse on 2st event, 150kHz sampling freq.
    EDIS;

    // Start ePWM 10 to begin ADC sampling and interrupts
    EPwm10Regs.ETSEL.bit.SOCAEN = 1; Enable the ADC SOCA (EPWMxSOCA) Pulse
    EPwm10Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; //enable up-down mode
    }
  • Hi Hongmei,

    Yeah, the ETPS is what you want. This should let you scale the frequency of the trigger events.