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.

Compiler/TMS320F28075: TMS320F28075

Part Number: TMS320F28075


Tool/software: TI C/C++ Compiler

Hi,

 I am using TMS320F28075 Microcontroller. I have DC voltage sensing  through ADC A2. also used PWM1A,1B. I want to trip (low) both the pwm when DC voltage adc count is go above 3500. For that I have used Compare module . I have done the following coding for the same.   

// CMPSs init 

Cmpss1Regs.COMPCTL.bit.ASYNCHEN = 0; // Synchronous trip for high comparator

Cmpss1Regs.COMPCTL.bit.CTRIPHSEL = 3; // Use filtered and latched trip for high comparator
Cmpss1Regs.COMPCTL.bit.COMPHINV = 0; // Trip when value > DAC for high comparator
Cmpss1Regs.COMPCTL.bit.COMPHSOURCE = 0; // Compare with DAC value for high comparator

Cmpss1Regs.COMPHYSCTL.bit.COMPHYS = 1; // Typical hysteresis for comparator

Cmpss1Regs.COMPSTSCLR.bit.HSYNCCLREN = 0; // PWMSYNC will not reset latch for high comparator
Cmpss1Regs.COMPSTSCLR.bit.HLATCHCLR = 1; // Clear latch for high comparator now

Cmpss1Regs.COMPDACCTL.bit.SWLOADSEL = 0; // DAC value updated on SYSCLK
Cmpss1Regs.COMPDACCTL.bit.SELREF = 0; // VDDA used as DAC reference
Cmpss1Regs.COMPDACCTL.bit.DACSOURCE = 0; // Ramp generator not used

Cmpss1Regs.DACHVALS.bit.DACVAL = 4000; 

// Cmpss1Regs.CTRIPLFILCTL.bit.FILINIT = 1; // Initialize all data in filter to input value
// Cmpss1Regs.CTRIPLFILCTL.bit.THRESH = VOTE_MAJ; // Number of high samples in window for trip
// Cmpss1Regs.CTRIPLFILCTL.bit.SAMPWIN = VOTE_WIN; // Number of samples in voting window = SAMPWIN+1
// Cmpss1Regs.CTRIPLFILCLKCTL.bit.CLKPRESCALE = 0; // No prescaling of SYSCLK used

Cmpss1Regs.CTRIPHFILCTL.bit.FILINIT = 1; // Initialize all data in filter to input value
Cmpss1Regs.CTRIPHFILCTL.bit.THRESH = VOTE_MAJ; // Number of high samples in window for trip
Cmpss1Regs.CTRIPHFILCTL.bit.SAMPWIN = VOTE_WIN; // Number of samples in voting window = SAMPWIN+1

Cmpss1Regs.CTRIPHFILCLKCTL.bit.CLKPRESCALE = 0; // No prescaling of SYSCLK used

 Cmpss1Regs.COMPLOCK.bit.CTRIP = 1; // Lock CTRIP registers
 Cmpss1Regs.COMPLOCK.bit.DACCTL = 1; // Lock DACCTL registers
 Cmpss1Regs.COMPLOCK.bit.COMPHYSCTL = 1; // Lock COMPHYSCTL registers
 Cmpss1Regs.COMPLOCK.bit.COMPCTL = 1; // Lock COMPCTL registers

// PWM init
EPwm1Regs.TZSEL.bit.DCBEVT2 = TZ_ENABLE; // One shot trip on DCBEVT1
EPwm1Regs.TZSEL.bit.DCAEVT2 = TZ_ENABLE; // One shot trip on DCAEVT1

EPwm1Regs.TZCTL.bit.DCBEVT2 = TZ_FORCE_LO; // Force low on DCBEVT1
EPwm1Regs.TZCTL.bit.DCAEVT2 = TZ_FORCE_LO; // Force low on DCAEVT1

EPwm1Regs.DCBCTL.bit.EVT2SRCSEL = DC_EVT2; // EVT1 source for DCB
EPwm1Regs.DCACTL.bit.EVT2SRCSEL = DC_EVT2; // EVT1 source for DCA

EPwm1Regs.DCBCTL.bit.EVT2FRCSYNCSEL = DC_EVT_ASYNC; // Asynchronous use of event
EPwm1Regs.DCACTL.bit.EVT2FRCSYNCSEL = DC_EVT_ASYNC; // Asynchronous use of event

EPwm1Regs.TZDCSEL.bit.DCBEVT2 = TZ_DCBH_HI; // Event on DCBH->high
EPwm1Regs.TZDCSEL.bit.DCAEVT2 = TZ_DCAH_HI; // Event on DCAH->high

EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 0; // DCBH on trip combo
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 0; // DCAH on trip combo
EPwm1Regs.DCBHTRIPSEL.bit.TRIPINPUT4 = 1;

EPwm1Regs.DCAHTRIPSEL.bit.TRIPINPUT4 = 1; // Trip 4 used (phase overcurrent)

With this setting I get PWM low always even my DC voltage is less.Is the Initialisation is correct for the PWM and CMPSS

Regards,

Sagar

  • Sagar,

    1. Step one: Should be to enable the comparator's output to a pin and observe it with a oscilloscope. Once you have the comparator functioning as expected then...
    2. Step two: You can test the PWMs function.
    3. Step three: After all pieces are working you should then try to combine them by connecting the comparator's output to the PWM module.

    Try the above steps and reply back here with your results!

    Regards,
    Cody 

  • Sagar,

    I suspect that the CMPSS latch is getting tripped during initialization, which would interfere with your desired behavior.

    There is a CMPSS digital filter initialization sequence in the TRM that you will want to follow for best results.

    -Tommy

  • Hi Cody,

    Thanks for reply.

    I am follow the sample code for the same.(cmpss_async_cpu01 ).I am using the same function and output xbar pin for my application but its is not working. but I f I run the example it is working. I have disable all other peripherals except cmpss Init. but I did not get output.
    How to check The Cmpss is get Initialised or not.

    Regards,
    Sagar
  • Hi cody,

    I have done accordingly your step and it is working.But I want to do with more cmpss input.
    For example I want to low Pwm for CMpss1p and cmpss1N.
    CMPss1P is use for Voltage read and CMpss1N is use for current read. If both the input are goes above dac value I want to low the pwm.
    PWM is low only for cmpss1P but it is not working for cmpss1N.
    Please guide me for the same.

    Regards,
    Sagar
  • Hi cody,

    The software is working ok with cmpss1P. But with cmpss1n PWM will not trip.
    May I know what is the procedure for trip the pwm with cmpss1n.

    Regards,
    sagar
  • Sagar,

    I assume that you mean CMPSS1.CTRIPH and CMPSS1.CTRIPL?

    Did you reconfigure the ePWM X-BAR to pass through both signals?  You can use an OR'd signal of both CTRIP signals or configure a second ePWM TRIP signal sourced from CTRIPL.

    From the TRM:

    -Tommy

  • Tommy,

     Yes, I want to OR'd CMPSS.CTRPH and CTRPL signals.I reconfigure the signal but Its not working.

    May I konw how to configure EPWM x-bar for both CTRIP signals.

    Regards,

    Sagar  

  • Sagar,

    If you take another look at the cmpss_async_cpu01  example, you will see the EPWM and OUTPUT x-bars being configured:

    //
    // Configure CTRIPOUTH output pin
    // Configure OUTPUTXBAR3 to be CTRIPOUT1H
    //
    OutputXbarRegs.OUTPUT3MUX0TO15CFG.bit.MUX0 = 0;

    //
    //Enable OUTPUTXBAR3 Mux for Output
    //
    OutputXbarRegs.OUTPUT3MUXENABLE.bit.MUX0 = 1;

    and

    //
    //Configure TRIP4 to be CTRIP1H
    //
    EPwmXbarRegs.TRIP4MUX0TO15CFG.bit.MUX0 = 0;

    //
    //Enable TRIP4 Mux for Output
    //
    EPwmXbarRegs.TRIP4MUXENABLE.bit.MUX0 = 1;

    You just need to change the MUX selection for your program.

    -Tommy