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.

TMS320F280025C: SOC configuration

Part Number: TMS320F280025C


Hi,

I am developing a digital regulation, and I've an issue with my Start Of Conversion configuration, I have to perform an averaging of the self current.

You can see a drawing.

I'm on UP DOWN count for TBCTR register. 

Is it possible to generate different SOCs for the same TBCTR counter period?

void adc_init(void)
{
    SetVREF(ADC_ADCA, ADC_INTERNAL, ADC_VREF3P3);
    EALLOW;
    /// Set ADCCLK divider to /2
    AdcaRegs.ADCCTL2.bit.PRESCALE = 2;
    /// Interrupt pulse generation occurs at the end of the conversion.
    AdcaRegs.ADCCTL1.bit.INTPULSEPOS = 1;
    /// Power up the ADC, enable ADC
    AdcaRegs.ADCCTL1.bit.ADCPWDNZ = 1;
    /// Delay for power.
    DELAY_US(1000);

    /// Enable the ADC Start Of Conversion Pulse
    EPwm1Regs.ETSEL.bit.SOCBEN = 1;
    /// Generate  pulse at TBCTR equal 0.
    EPwm1Regs.ETSEL.bit.SOCBSEL = 1;
    /// Generate the EPWM1SOCB pulse on the first event.
    EPwm1Regs.ETPS.bit.SOCBPRD = 1;

    /// SOC0 will convert ADCINC6 : MU_TRAC_BATT_PCH_FLT signal
    AdccRegs.ADCSOC0CTL.bit.CHSEL = 6;
    /// Time total for one sample equal 550ns
    AdccRegs.ADCSOC0CTL.bit.ACQPS = 8;
    /// Trigger on ePWM1 ADCSOCB
    AdccRegs.ADCSOC0CTL.bit.TRIGSEL = 6;
    
    EDIS;
}

void epwm_init_spwm_u(void)
{
    EALLOW;
    /// Disable counting
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
    EDIS;

    /// Setup counter mode
    /// Configure pre-scaler and high speed pre-scaler, divide by 1.
    EPwm1Regs.TBCTL.bit.CLKDIV = 0;
    EPwm1Regs.TBCTL.bit.HSPCLKDIV = 0;
    /// Up Down count mode.
    EPwm1Regs.TBCTL.bit.CTRMODE = 2;

    /// Setup time base counter.
    /// Immediate mode, a write or read to the TBPRD register accesses the active register.
    EPwm1Regs.TBCTL.bit.PRDLD = 1;
    EPwm1Regs.TBPRD = TBPRD_VALUE;
    /// Clear counter
    EPwm1Regs.TBCTR = 0;

    /// Phase settings
    /// Select EPWMxSYNCOUT signal when TBCTR = 0 for master signal.
    EPwm1Regs.EPWMSYNCOUTEN.bit.ZEROEN = 1;
    /// Do not load the time base counter (TBCTR) from the time base phase register (TBPHS).
    EPwm1Regs.TBCTL.bit.PHSEN = 0;
    /// Synchronization event is ignored.
    EPwm1Regs.TBPHS.bit.TBPHS = 0;

    /// Setup counter compare.
    /// Immediate mode, all writes and reads directly access the active register for immediate actions.
    EPwm1Regs.CMPCTL.bit.SHDWAMODE = 1;
    EPwm1Regs.CMPCTL.bit.SHDWBMODE = 1;
    /// To have 50% duty cycle
    EPwm1Regs.CMPA.bit.CMPA = CMP_VALUE;
    EPwm1Regs.CMPB.bit.CMPB = CMP_VALUE;

    /// Actions
    /// When TBCTR = CMPA on UP count, force EPWMxA output low.
    EPwm1Regs.AQCTLA.bit.CAU = 1;
    /// When TBCTR = CMPA on DOWN count, force EPWMxA output low.
    EPwm1Regs.AQCTLA.bit.CAD = 2;

    /// Actions
    /// When TBCTR = CMPB on UP count, force EPWMxB output high.
    EPwm1Regs.AQCTLB.bit.CBU = 2;
    /// When TBCTR = CMPB on DOWN count, force ePWMxB output high.
    EPwm1Regs.AQCTLB.bit.CBD = 1;

    /// Enable counting
    EALLOW;
    CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
    EDIS;
}

I would like to generate SOC0 at TBCTR = 0, then SOC1 at CMPA incrementing then SOC2 at TBPRD then SOC3 at CMPA decrementing then after make my average by triggering an interrupt at EOC3 to come my corresponding ADCRESULT. Is this possible? I see that by the register ETSEL.SOCBSEL I can configure a state of triggering of SOC, but I would like to link a SOCx to a particular trigger on this ramp.

How can I do this please?

Here my code :

Thanks

Damien

  • Hello Damien,

    While the ePWM only supports SOCA & SOCB from a single ePWM, I did think of a quick workaround for a system with a spare ePWM. Essentially, by configuring that ePWM as secondary to your primary ePWM via linking and synchronization, you can independently the Event Trigger submodule for the secondary to trigger your second set of 2 SOCs. This requires one additional ePWM with ignored overall output, but gives you your additional SOCs.

    Regards,

    Jason Osborn

    (The specific linking/synchronization settings in question would be to, in your secondary ePWM, link the values of your CMPx and PRD to your primary using EPWMXLINK. Additionally, select PHSEN=1 and set the primary ePWM's syncout signal as the secondary ePWM's syncin signal. This gives you a second ePWM that is a clone of the first in the counter-compare and time-base submodules.)

  • Hi Jason,

    Sorry for the late response, It's all right now, I take only two sample per period for my ADC : one sample at count equal TBPRD and an other when count equal 0.

    Thanks

    Damien