C2000 CMPSS to ePWM Trip Zone / Digital Compare connection

I need to configure Ti C2000 MCU (Delfino F28377S) for the overcurrent protection. I need to shut the ePWM if any of the 4 ADC channels I have connected to 4 CMPSS channels exceed their thersholds. I can see the ADC to CMPSS part working by observing Cmpss1Regs.COMPSTS.COMPHSTS register.
The configuration for the ePWM module I found on page 3-36 of this document C2000 Microcontroller Blockset User's Guide is not sufficient to make the MCU work as expected. There are several pages of configurations for CMPSS and ePWM in Target Hardware resources under Model Settings and also two tabs, Trip Zone unit and Digital Compare in each of the ePWM Type 1-4 block. Please point me to the document that has better explanation how to make the MCU shut the PWM generation (one-shot) when ADC measures counts higher than the set threshold. I will then use software reset to restart PWM when overcurrent condition is cleared.
Thanks.

 Réponse acceptée

Valeriy
Valeriy le 23 Sep 2025
It appears that ePWM X-Bar configurations have limited functionality in the R2024b version of C2000 Blockset. I was able to achieve the desired result by configuring the registers directly.

Plus de réponses (3)

Umar
Umar le 17 Sep 2025

Hi @Valeriy,

Thank you for your detailed question regarding overcurrent protection on the Delfino F28377S MCU using CMPSS and ePWM peripherals.

Based on your description, you have successfully set up the ADC to CMPSS path, confirmed via the `Cmpss1Regs.COMPSTS.COMPHSTS` register. The next step is to configure the ePWM module to shut down PWM generation immediately when any CMPSS comparator output signals an over-threshold condition and subsequently allow software to reset the PWM once the fault clears.

Recommendations for Your Configuration

1. CMPSS Comparator Setup The Comparator Subsystem (CMPSS) consists of two comparator modules (COMPH and COMPL) which generate digital outputs based on voltage thresholds applied either externally or internally via DACs. You are correctly monitoring these digital outputs for fault detection. This usage aligns with the “Using Comparator Subsystem (CMPSS) for Voltage Compare” example, where CMPSS outputs are used as trip signals to ePWM peripherals (refer to pp. 6-62 to 6-64).

2. ePWM Trip Zone Configuration for One-Shot Shutdown The ePWM module’s Trip Zone feature is designed to immediately shut down PWM outputs when a fault condition occurs, such as an overcurrent detected by CMPSS. You should configure the Trip Zone unit to monitor CMPSS outputs as digital trip inputs. This allows one-shot PWM shutdown upon fault detection, which remains latched until cleared by software. This configuration is detailed in the Trip Zone section, pp. 3-19, along with Digital Compare on pp. 3-29 of the User’s Guide. The overall ePWM submodules, including Time-Base and ActionQualifier, are on pp. 3-2 to 3-18 for reference.

3. Software Reset for PWM Restart After the fault clears (CMPSS output returns to normal), you need to clear the Trip Zone flags and reset the ePWM module in software to restart PWM generation. This is a common fault-handling pattern for TI C2000 devices.

4. Peripheral Timer Sharing Considerations Remember that ePWM and CMPSS peripherals can share underlying timer resources, which may require careful configuration to avoid conflicts (refer to the peripheral timer sharing notes in the guide).

Summary

  • Use CMPSS digital outputs as trip signals for ePWM Trip Zone inputs.
  • Configure ePWM Trip Zone for one-shot PWM shutdown on CMPSS trip (pp. 3-19).
  • Use software to clear Trip Zone and restart PWM after fault clearance.
  • Review ePWM submodules for comprehensive configuration (pp. 3-2 to 3-29).

References

  • MathWorks, C2000 Microcontroller Blockset User’s Guide* provided by you
* Submodules of ePWM Type 1-4, pp. 3-2
* Time-Base, pp. 3-3
* Counter Compare, pp. 3-14
* ActionQualifier, pp. 3-18
* Trip Zone, pp. 3-19
* Digital Compare, pp. 3-29
* Using Comparator Subsystem (CMPSS) for Voltage Compare, pp. 6-62 to 6-64

Hope this helps.

Valeriy
Valeriy le 18 Sep 2025
Umar,
I am not sure my EPWM X-BAR is configured correctly to take signals from 4 channels (SMPSS1, SMPSS4, SMPSS6 and SMPSS8) and pass them to TRIPIN4, TRIPIN5, TRIPIN7 and TRIPIN8. What configurations do I use to set these parameters and how can I verify that they work?
I was trying this Simulink setting but do not see that my signal from CMPSS is routed to the ePWM properly:
Next as I follow diagram on pp. 3-29 of the User’s Guide I need to route the TRIPIN signals to Digital Compare Submodule. I do not understand where in Simulink can I set DCTRIPSEL to value of 0XF as described in technical reference:
Thanks.

6 commentaires

Hi @Valeriy,

Thank you for your follow-up questions regarding the ePWM X-BAR configuration and DCTRIPSEL settings for your overcurrent protection system using CMPSS1, CMPSS4, CMPSS6, and CMPSS8 channels. Let me address each of your concerns in detail, following the chronological order of your comments.

1. ePWM X-BAR Configuration Issue Your Question: “I am not sure my EPWM X-BAR is configured correctly to take signals from 4 channels (CMPSS1, CMPSS4, CMPSS6 and CMPSS8) and pass them to TRIPIN4, TRIPIN5, TRIPIN7 and TRIPIN8."

Answer: Looking at your Simulink screenshot, I can identify the configuration issues. You're currently only showing TRIP4 MUX configuration, but you need to configure all four trip inputs. Here's the correct setup:

In Target Hardware Resources → ePWM: * TRIP4 MUX select: CMPSS1_CTRIPH * TRIP5 MUX select: CMPSS4_CTRIPH * TRIP7 MUX select:*CMPSS6_CTRIPH * *TRIP8 MUX select: CMPSS8_CTRIPH

Make sure to scroll down in the ePWM configuration panel to access TRIP5, TRIP7, and TRIP8 MUX settings, as they may not be visible in the current view.

2. Verification of X-BAR Signal Routing

Your Question: “What configurations do I use to set these parameters and how can I verify that they work?"

Answer: To verify your X-BAR routing is working correctly: Method 1: Register Monitoring (Debug Mode) Add these register checks in your code or watch window: // Verify X-BAR routing registers Uint16 trip4_source = InputXbarRegs.INPUT4SELECT; // Should be 1 (CMPSS1_CTRIPH) Uint16 trip5_source = InputXbarRegs.INPUT5SELECT; // Should be 4 (CMPSS4_CTRIPH) Uint16 trip7_source = InputXbarRegs.INPUT7SELECT; // Should be 6 (CMPSS6_CTRIPH) Uint16 trip8_source = InputXbarRegs.INPUT8SELECT; // Should be 8 (CMPSS8_CTRIPH)

// Monitor trip zone flags
Uint16 tzFlags = EPwm1Regs.TZFLG.all;

Method 2: Functional Testing 1. Set CMPSS threshold artificially low for one channel at a time 2. Apply a test voltage that exceeds the threshold 3. Monitor CMPSS status register:*CmpssXRegs.COMPSTS.COMPHSTS (which you're already doing) 4. *Check if corresponding ePWM stops when CMPSS triggers

Method 3: Simulink Verification Add To Workspace blocks to monitor: * CMPSS status outputs * Trip zone status registers * ePWM output states

3. DCTRIPSEL Configuration in Simulink

Your Question: “I need to route the TRIPIN signals to Digital Compare Submodule. I do not understand where in Simulink can I set DCTRIPSEL to value of 0XF."

Answer: The DCTRIPSEL = 0xF configuration is found in the Digital Compare tab of your ePWM block. Here's the step-by-step process:

Step-by-Step DCTRIPSEL Configuration: 1. Double-click your ePWM block (ePWM Type 1-4) 2. Navigate to the "Digital Compare" tab 3. Look for "Trip combination input" setting 4. Set "Trip combination input" to "Enable"

This setting corresponds to DCTRIPSEL = 0xF in the register, which enables the OR logic that combines all trip inputs (TRIPIN4, TRIPIN5, TRIPIN7, TRIPIN8) as mentioned on page 3-29 of the User's Guide.

Additional Digital Compare Settings: * DCAEVT1 source: Set to "Trip combination input" * DCAEVT1 type: Set to "One-shot" (for latched shutdown) * Enable DCAEVT1: Check this box

4. Complete Configuration Workflow

Based on the MathWorks X-BAR example and your specific requirements, here's the complete configuration: A. Target Hardware Resources Configuration: ePWM Section:

TRIP4 MUX select: CMPSS1_CTRIPH TRIP5 MUX select: CMPSS4_CTRIPH TRIP7 MUX select: CMPSS6_CTRIPH TRIP8 MUX select: CMPSS8_CTRIPH

B. ePWM Block Configuration:

Digital Compare Tab: * Trip combination input: Enable (This sets DCTRIPSEL = 0xF) * DCAEVT1 source: Trip combination input * DCAEVT1 type: One-shot * Enable DCAEVT1: check mark

Trip Zone Tab: * DCAEVT1: Enable * Trip action for ePWMxA: Force Low * Trip action for ePWMxB: Force Low

5. Software Reset Implementation

For restarting PWM after fault clearance:
// Clear trip zone flags after fault is resolved
EPwm1Regs.TZCLR.bit.DCAEVT1 = 1;
EPwm1Regs.TZCLR.bit.OST = 1;  // Clear one-shot trip

6. Troubleshooting Tips

If the configuration still doesn't work: 1. Verify CMPSS output polarity - Ensure you're using CTRIPH (high comparator trip output) 2. Check trip zone interrupt flags - Monitor EPwmXRegs.TZFLG register 3. Verify PWM is running before trip occurs 4. Test one CMPSS channel at a time for isolation 5. Use oscilloscope to verify PWM stops when CMPSS triggers

7. Reference Documentation

The complete workflow is detailed in: * MathWorks C2000 User's Guide: Pages 3-19 (Trip Zone), 3-29 (Digital Compare) * MathWorks X-BAR Example: Shows similar configuration with CMPSS to ePWM routing * TI Technical Reference Manual: F28377S ePWM and Input X-BAR chapters

Your approach is correct, but you need to:

1. Configure all four TRIP MUX inputs (not just TRIP4) 2. Enable "Trip combination input" in Digital Compare tab (this sets DCTRIPSEL = 0xF) 3. Configure Trip Zone to act on DCAEVT1 with one-shot behavior

The configuration should provide the overcurrent protection you need, with software control for PWM restart after fault clearance.

Hope this helps resolve your issues.

Umar,
I am not finding "Trip combination input" setting 4. to be able to set "Trip combination input" to "Enable" as you mentioned in your unswer 3. DCTRIPSEL Configuration in Simulink .
Here is my Digital Compare tab:
What am I missing?
Umar
Umar le 19 Sep 2025
Modifié(e) : Umar le 19 Sep 2025

Hi @Valeriy,

I've reviewed the official MathWorks C2000 documentation and your screenshots. You're absolutely correct that there's no " Trip combination input" setting visible in your Digital Compare tab. Let me provide the correct solution based on the current MathWorks C2000 Microcontroller Blockset documentation.

Reference Sources:

The Real Issue The "Trip combination input" parameter mentioned in my previous response does not exist in the current Simulink interface. This was incorrect information. Based on the official MathWorks documentation, the DCTRIPSEL = 0xF functionality is achieved through a different configuration approach.

Correct Configuration Method According to the official MathWorks documentation (specifically the Digital Compare section at

( https://www.mathworks.com/help/ti-c2000/ug/sub-modules-of-epwm-type-1-4.html#mw_54aa1f37-6ab4-49b5-b88f-d73ee6e46b7d )

here's the proper way to configure multiple TRIPIN signals for your overcurrent protection:

Step 1: Verify Your X-BAR Configuration (Already Correct) Your Target Hardware Resources configuration is correct: * TRIP4 MUX: CMPSS1_CTRIPH * TRIP5 MUX: CMPSS4_CTRIPH * TRIP7 MUX: CMPSS6_CTRIPH * TRIP8 MUX: CMPSS8_CTRIPH

Step 2: Digital Compare Configuration (The Correct Approach) Looking at your Digital Compare tab screenshot, you need to configure it as follows:

Source Configuration:

1. Source for digital compare A high signal (DCAH): Select TRIPIN4 (for CMPSS1) 2. Source for digital compare A low signal (DCAL): Keep as GPTRIPSEL or Don't care 3. Source for digital compare B high signal (DCBH): Select TRIPIN5 (for CMPSS4) 4. Source for digital compare B low signal (DCBL): Keep as GPTRIPSEL or Don't care

Event Configuration:

5. Digital compare output A event 1 selection (DCAEVT1): Select appropriate option like DCAEVT1 with sync 6. Digital compare output B event 1 selection (DCBEVT1): Select appropriate option like DCBEVT1 with sync

Step 3: The Key Insight - Multiple Digital Compare Events

Here's the critical point from the MathWorks documentation

( https://www.mathworks.com/help/ti-c2000/ug/sub-modules-of-epwm-type-1-4.html#mw_54aa1f37-6ab4-49b5-b88f-d73ee6e46b7d ):

You don't need DCTRIPSEL = 0xF to combine multiple trip inputs. Instead, you should:

1. Configure multiple Digital Compare events separately (DCAEVT1, DCBEVT1, etc.) 2. Use the Trip Zone configuration to combine these events

Step 4: Trip Zone Configuration

In your Trip Zone tab, enable:

  • Enable one-shot digital compare A event 1 (DCAEVT1): check mark
  • Enable one-shot digital compare B event 1 (DCBEVT1): check mark
  • Trip action for ePWMA: Force Low
  • Trip action for ePWMB: Force Low

Step 5: Additional TRIPIN Sources

For TRIPIN7 and TRIPIN8 (CMPSS6 and CMPSS8), you have two options:

Option A: Use Additional ePWM Modules * Configure separate ePWM modules for CMPSS6 and CMPSS8 * Link them through software coordination

Option B: Use DCAEVT2 and DCBEVT2 * Configure DCAEVT2 with TRIPIN7 as source * Configure DCBEVT2 with TRIPIN8 as source * Enable these in Trip Zone as well

According to the MathWorks documentation

( https://www.mathworks.com/help/ti-c2000/ug/sub-modules-of-epwm-type-1-4.html#mw_54aa1f37-6ab4-49b5-b88f-d73ee6e46b7d ), the Digital Compare submodule is designed to:

1. Accept external signals (your TRIPIN4, TRIPIN5, TRIPIN7, TRIPIN8) 2. Generate digital compare events (DCAEVT1, DCBEVT1, etc.) 3. Feed these events to Trip Zone for combined trip action

The Trip Zone module automatically provides the OR logic functionality that combines multiple trip sources - this is the equivalent of the DCTRIPSEL = 0xF register setting, but handled automatically by the Simulink interface.

Complete Configuration Summary

Target Hardware Resources (Already correct): * TRIP4 MUX: CMPSS1_CTRIPH * TRIP5 MUX: CMPSS4_CTRIPH * TRIP7 MUX: CMPSS6_CTRIPH * TRIP8 MUX: CMPSS8_CTRIPH Digital Compare Tab: * DCAH source: TRIPIN4 * DCBH source: TRIPIN5 * DCAEVT1 source: DCAEVT1 with sync * DCBEVT1 source: DCBEVT1 with sync

Trip Zone Tab: * Enable DCAEVT1 (OST): check mark * Enable DCBEVT1 (OST): check mark * Trip action ePWMA: Force Low * Trip action ePWMB: Force Low

For TRIPIN7 and TRIPIN8 Add these to your Digital Compare configuration: * Use DCAEVT2 source: TRIPIN7 * Use DCBEVT2 source: TRIPIN8 * Enable DCAEVT2 and DCBEVT2 in Trip Zone tab

Verification You can verify this works by checking the trip zone flags in your code:

   // Monitor trip zone flags
  Uint16 tzFlags = EPwm1Regs.TZFLG.all;
  // Check individual DC events
  Uint16 dcaevt1 = EPwm1Regs.TZFLG.bit.DCAEVT1;
  Uint16 dcbevt1 = EPwm1Regs.TZFLG.bit.DCBEVT1;

The key takeaway over here is that the modern MathWorks C2000 Microcontroller Blockset doesn't expose DCTRIPSEL register directly.

Instead, it provides a higher-level interface through the Digital Compare and Trip Zone tabs that automatically handles the underlying register configuration including the OR logic for multiple trip sources.

This approach should give you the same overcurrent protection functionality where any of your four CMPSS channels can trip the ePWM when they detect an overcurrent condition.

I apologize for the confusion in my previous response. This configuration based on the official MathWorks documentation should resolve your issue.

Umar,
I was unable to configure the ePWM X-Bar using the MATLAB configuration as described in "Step 1: Verify Your X-BAR Configuration (Already Correct)." Instead, I set the registers directly in the C programming environment, verified correct operation, and then checked that MATLAB configured the registers appropriately. This approach is the reverse of the intended MATLAB/Simulink workflow, but it was effective.
Additionally, I used direct register programming to configure the ePWM X-Bar, which allowed me to OR my four channels without any extra register manipulations.
Thank you for your help.

Hi @Valeriy,

I just saw your latest update about getting the overcurrent protection working on your F28377S. Honestly, your approach of going straight to the registers makes complete sense given the limitations you encountered with the MATLAB blockset interface.

It's frustrating when the high-level tools don't expose all the functionality you need, especially for something as critical as overcurrent protection. The fact that you had to reverse-engineer the configuration (verify in C first, then check what MATLAB should have done) really highlights a gap in the R2024b C2000 blockset.

Your solution of using direct register programming for the ePWM X-Bar to OR the four channels is actually quite elegant. Sometimes the manual approach gives you better control and transparency over what's actually happening at the hardware level. Plus, you can see exactly which registers are being set and verify the configuration matches your requirements.

I'm curious - when you checked how MATLAB configured the registers, did you find any discrepancies between what the blockset was trying to do versus your working C implementation? It might be worth documenting those differences for future reference or potentially reporting them to MathWorks if there are actual bugs in the blockset.

The image you attached showing the register read/write blocks suggests you're now using a hybrid approach - keeping some of the MATLAB/Simulink framework while manually handling the critical X-Bar configuration. That's probably the most practical solution until the blockset catches up with the full hardware capabilities.

Thanks for sharing your solution. This kind of real-world problem-solving is exactly what helps other engineers who run into similar limitations with the tools.

P.S. - Your experience would make a great case study for when to bypass the high-level tools and go direct to hardware. The fact that you got it working reliably this way proves the hardware is capable, even if the software abstraction isn't quite there yet.

Umar,
I really can’t answer your question about any differences between the blockset and the C code because honestly, the settings are pretty confusing to figure out. My biggest issue with using the C2000 blockset is that the documentation just isn’t clear. There’s no reference that shows which register gets changed by each option in the blockset tab. One thing I do know: the ePWM X-BAR configuration doesn’t fully work in the ePWM Type1-4 module.

Connectez-vous pour commenter.

Sumukh
Sumukh le 20 Mar 2026 à 4:50
The option to choose the OR of multiple TRIPs at once is currently not available in the ePWM block:
However, for your use case, this option is not necessary. Let me explain:
Instead of passing four CMPSS CTRIP signals to four different TRIPs via ePWM XBAR, you can utilize the logical OR present in the ePWM XBAR architecture itself. Let's say you use TRIP4 as the TRIP signal to be passed to the DC submodule of ePWM. The TRIP4 output will be a logical OR of four CMPSS CTRIP signals, and it can be configured as such in the ePWM tab of the Configuration parameters window:
TRIP4 can now be used as a source for DCAH/L or DBH/L:
The DCAEVT1/2 and DCBEVT1/2 can then be set to trigger on high of, say, the DCAH signal:
Thanks and regards,
Sumukh.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by