How to turn off epwm using software force logic in c2000 f28388d?
Show older comments
Hi,
I am using an F28388D to control a 3-phase full bridge inverter. I am utilizing a code with a state diagram for this purpose. I have a requirement to completely turn off the third leg of the inverter at one point for a few seconds based on inputs from Stateflow. I tried using the software force logic, but I am unable to turn off the switches. The attached diagram shows the settings I have tried for this. I provided an input of 1 to the SW input port whenever I needed to turn off the leg, but it's not working, and I am unable to find any resources on how to implement this.
Is there anyone who can help with this?
Thanks in advance.
Regards,
Kripa

Answers (2)
Shivam Gothi
on 28 Aug 2024
Edited: Shivam Gothi
on 28 Aug 2024
1 vote
Hello,
The parameters you configured appear to be correct. However, since I don't have access to the hardware, I am unable to determine why the PWM module is behaving unpredictably. I can suggest an alternative solution to address this issue.
To achieve the desired outcome, consider using the "TZFRC" (force a trip event) and "TZCLR" (clear trip event) registers of the F28388D microcontroller. By setting the bit EPwm1Regs.TZFRC.bit.OST to logic "1", you can trigger a one-shot event on the PWM1 module, which will disable the PWM for both the top and bottom switches (EPWM1a and EPWM1b). Similarly, setting the bit EPwm1Regs.TZCLR.bit.OST to "1" will clear the trip flag, re-enabling the PWM.
The same approach applies to the PWM2, PWM3, and PWM4 modules. For example, writing "1" to the bit EPwm2Regs.TZFRC.bit.OST will trigger a one-shot event on the PWM2 module, disabling the pulses for EPWM2a and EPWM2b.
In Simulink, you can manually write to these registers using the "Register ReadWrite" block. You can find more information on this in the MATLAB documentation linked here: https://www.mathworks.com/help/ti-c2000/ref/epwmtype14.html
In this way, you can avoid configuring any continuous software forcing logic.
Suggested Approach:
Create the following model in Simulink.

The detailed explanation for “PWM1 control logic block” is given below. Follow the same for other two “control logic block” also.
(NOTE: here, two “Register ReadWrite” blocks are used. One of it is named as “write TZFRC register” and other is named as “write TZCLR register”)
- Open the “block parameters” for “write TZFRC register” block, as shown below.

- Fill all the “unspecified” fields appropriately to get the register bit : “EPwm1Regs.TZFRC.bit.OST”. (NOTE: If the parameters on the block are 'Unspecified', configure the hardware setup using 'c2000setup' command.)
- Now open the “block parameters” for “write TZCLR register” block.
- Again, fill all the “unspecified” fields appropriately to get the register bit : “EPwm1Regs.TZCLR.bit.OST”.
- Working logic:
- When the above system receives the logic “1” from the stateflow algorithm, “Write TZFRC register” block writes “1” to the “EPwm1Regs.TZFRC.bit.OST” register bit fields. This forces a one shot event on PWM 1 module and stop the pulses .
- When the above system receives the logic “0” from the stateflow algorithm, “Write TZCLR register” block writes “1” to the “EPwm1Regs.TZCLR.bit.OST” register bit fields. This clears the trip flag and enables the PWM pulses.
I hope this is as per your expectation!
3 Comments
Shivam Gothi
on 29 Aug 2024
Hello,
I tried the approach stated by you on hardware. I created "SFA" input port on ePWM block as mentioned by you and passed the inputs through a "constant" block as shown in below figure.

I monitored the PWM on CRO. When I made "constant" value to 1, the pulses which disabled and both the PWM outputs were cleared to "0". When I changed the "constant" value to 0, the software forcing was disabled and the PWM pulses were back again.
Please cheak the output of your stateflow algorithm. May be the stateflow algorithm might be inputting some incorrect value to "SFA" port of PWM block.
Or, try to manually pass the logic "0" and "1" by using "constant" block as shown in the above figure.
Can you please share your simulink file if possible?
Hari
on 30 Sep 2024
Ibrahim
on 14 Nov 2024
Hello Hari,
Were you able to figure out why the TZCLR.OST register was not setting? I am having the same issue.
Can anyone support with this, please?
Hello together,
forcing a trip event by writing to TZFRC register and reseting it with TZCLR as described by @Shivam Gothi is sufficient, if TZCTL register is initialized.
For turning both ePWMs off (low logic level) in case of a trip event, TZCTL must be set to "2" (= 1,0 binary). For more information visit the technical reference manual ( https://www.ti.com/lit/ug/spruiw9c/spruiw9c.pdf?ts=1772722747833 ), especially chapter 20.9.2 at page 2272.
Categories
Find more on Sources in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
