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/TMS320F28335: using DELAY_US in interrupt void epwm1_timer_isr(void)

Part Number: TMS320F28335
Other Parts Discussed in Thread: C2000WARE, CONTROLSUITE

Tool/software: Code Composer Studio

#############################################

interrupt void epwm1_timer_isr(void)
{
EPwm1_Count++;

Vo = AdcRegs.ADCRESULT0 >>4;
Vin = (AdcRegs.ADCRESULT1 >>4);
IL = AdcRegs.ADCRESULT2 >>4;

'/###########Buck mode

if(.......... )
{
........
{
EPwm1Regs.AQCSFRC.bit.CSFA = 2;
EPwm1Regs.AQCSFRC.bit.CSFB = 1;
}
else if (..........)
{'''''''''''''''
DELAY_US(2L);
EPwm1Regs.AQCSFRC.bit.CSFA = 1; 
EPwm1Regs.AQCSFRC.bit.CSFB = 2; 

DELAY_US(2L);

}
else

#################################################

I used the DELAY() function and set 2L in (). then I used oscilloscope to check it which is approximate 5.6mS.
I found the formula that is "((A * 1000)/16.67 -9)/5", this number must be 0.316uS.
Is the setting wrong??

  • Hi Wei,

    The DELAY_US() macro is defined to take a delay in the desired number of microseconds, so the line: DELAY_US(2L); should result in a 2 microsecond delay, if the macro is defined properly. You may have already seen that this macro is defined in DSP2833x_Examples.h. CPU_RATE should be set to the cycle time in nanoseconds. The default CPU_RATE for F28335 is 6.67 (corresponding to 6.67 ns cycle time) as 150MHz is the default SYSCLKOUT for the device.

    Regards,
    Elizabeth
  • Hello Elizabeth,

    I'm appreciated your support,and I have checked this setup that was 6.67L.

    for(;;) //IDLE loop
    {

    if (IL < 500 && Boost == 1) //Boost mode ,IL < -3 OCP
    {
    DELAY_US(1); // 36uS , 
    EPwm1Regs.AQCSFRC.bit.CSFA = 2; //HG on
    EPwm1Regs.AQCSFRC.bit.CSFB = 1; //LG off
    DELAY_US(1); // 38.4uS
    }

    }

    DELAY_US(1) equal to 36uS~38.4uS on oscilloscope, I think it that is ADC&ePWM limitation of bandwidth.

    my DSP2833x_Examples.h. as below

    // TI File $Revision: /main/9 $
    // Checkin $Date: July 2, 2008 14:31:12 $
    //###########################################################################
    //
    // FILE: DSP2833x_Examples.h
    //
    // TITLE: DSP2833x Device Definitions.
    //
    //###########################################################################
    // $TI Release: DSP2833x/DSP2823x C/C++ Header Files V1.31 $
    // $Release Date: August 4, 2009 $
    //###########################################################################

    #ifndef DSP2833x_EXAMPLES_H
    #define DSP2833x_EXAMPLES_H


    #ifdef __cplusplus
    extern "C" {
    #endif

    -----------------------------------------------------------------------------*/
    #define CPU_RATE 6.667L // for a 150MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 7.143L // for a 140MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 8.333L // for a 120MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 10.000L // for a 100MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 13.330L // for a 75MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 20.000L // for a 50MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 33.333L // for a 30MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 41.667L // for a 24MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 50.000L // for a 20MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 66.667L // for a 15MHz CPU clock speed (SYSCLKOUT)
    //#define CPU_RATE 100.000L // for a 10MHz CPU clock speed (SYSCLKOUT)

    -----------------------------------------------------------------------------*/
    #if DSP28_28332 // DSP28_28332 device only
    #define CPU_FRQ_100MHZ 1 // 100 Mhz CPU Freq (20 MHz input freq)
    #define CPU_FRQ_150MHZ 0
    #else
    #define CPU_FRQ_100MHZ 0 // DSP28_28335||DSP28_28334
    #define CPU_FRQ_150MHZ 1 // 150 MHz CPU Freq (30 MHz input freq) by DEFAULT
    #endif


    // DO NOT MODIFY THIS LINE.
    #define DELAY_US(A) DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L)


    #ifdef __cplusplus
    }
    #endif /* extern "C" */

    #endif // end of DSP2833x_EXAMPLES_H definition


    //===========================================================================
    // End of file.
    //===========================================================================

    and I have other question is how to using FIR or IIR filter to realize second order filter. I searched TI and google website .I can't reach it 

  • Hello,

    While profiling on the oscilloscope is a great option, another option is to use the CCS clock feature in the debug session described at the link below. This way you can profile only the DELAY_US() call.

    processors.wiki.ti.com/.../Profiling_on_C28x_Targets

    The following FIR example found in C2000Ware was implemented for the F2837x but it can give you a starting point for F2833x.
    C:\ti\c2000\C2000Ware_1_00_03_00\libraries\dsp\FPU\c28\examples\filter\2837x_fir

    Regards,
    Elizabeth
  • Dear Elizabeth,

    Thanks,

    I got it , so F28335 is unable to using FIR

    and I would like to using ADC to detect the inductor current for zero current detection and over current protection in real-time (cycle by cycle on switching frequency 100kHz ).

    Zero current detection (ZCD) , if the inductor current is going negative ,the low side MOSFET must be turns off immediately (< 1uS)
    Over current protection (OCP) , if the inductor current is going too much,the high side MOSFET must be turns off immediately (< 1uS).

    I using ePWM1A and ePWM1B for high and low side MOSFET, and using AdcRegs.ADCRESULT2 to detect the 100kHz inductor current

  • Hi Wei,

    You should still be able to implement FIR on F2833x by porting the F2837x example I had referred in my last post.

    On the inductor current use case, if you've already referred to the technical user's guides and software examples in controlSUITE/C2000Ware, and still have remaining issues, I'd recommend starting a new post with more details on problems you're facing or specific questions on peripheral functionality. This will route your post to an expert on that subject and also we can better sort and track posts based on topic.

    Regards,
    Elizabeth
  • Hello Elizabeth,

    Sorry, I will start 2 topics that are inductor current functionality and FIR .

    but the DELAY_US implement "interrupt void epwm1_timer_isr(void)" is incorrect timer . however it is not suitable to implement on ZCD or OCP .

    Thanks.

  • If you are looking for a second order implementation you could take the DF22 compensator from the Digital Control Library in C2000Ware, here:

     C:\ti\c2000\C2000Ware_1_00_03_00\libraries\control\DCL\c28

    Those are floating point C28x functions you can just add to your F28335 project. 

    Regards,

    Richard