C2000Ware Digital Power SDK  5.03.00.00
type4_pwm_protection_source.h
Go to the documentation of this file.
1 //###########################################################################
2 //
3 // FILE: type4_pwm_protection_source.h
4 //
5 // TITLE: Prototypes and Definitions for the Type 4 PWM Delayed Protection
6 // Library
7 //
8 //#############################################################################
9 // $TI Release: C2000Ware DigitalPower SDK v5.03.00.00 $
10 // $Release Date: Mon Aug 12 12:17:45 CDT 2024 $
11 // $Copyright:
12 // Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/
13 //
14 // ALL RIGHTS RESERVED
15 // $
16 //#############################################################################
17 
18 #ifndef TYPE4_PWM_PROTECTION_SOURCE_H
19 #define TYPE4_PWM_PROTECTION_SOURCE_H
20 
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24 
25 //*****************************************************************************
26 //
29 //
30 //*****************************************************************************
31 
32 
33 #include "driverlib.h"
34 #include "device.h"
35 
45 void initEPWM_aux_trip(uint32_t aux_pwm_base,
46  EPWM_DigitalCompareTripInput system_trip_source,
47  uint16_t trip_delay)
48 {
49 
50  EALLOW;
51  EPWM_setTimeBasePeriod(aux_pwm_base, 2500);
52  EPWM_setTimeBaseCounter(aux_pwm_base,0);
53  EPWM_setPhaseShift(aux_pwm_base,0);
54  EPWM_disablePhaseShiftLoad(aux_pwm_base);
55  EPWM_setTimeBaseCounterMode(aux_pwm_base,EPWM_COUNTER_MODE_UP_DOWN);
56  EPWM_setClockPrescaler(aux_pwm_base, EPWM_CLOCK_DIVIDER_1,
57  EPWM_HSCLOCK_DIVIDER_1);
58 
59  // S1 = 1
60  EPWM_setDeadBandDelayMode(aux_pwm_base,EPWM_DB_RED, true);
61  // S2 = 0
62  EPWM_setDeadBandDelayPolarity(aux_pwm_base, EPWM_DB_RED,
63  EPWM_DB_POLARITY_ACTIVE_HIGH);
64 
65  // S4 = 0
66  EPWM_setRisingEdgeDeadBandDelayInput(aux_pwm_base, EPWM_DB_INPUT_EPWMA);
67  EPWM_setRisingEdgeDelayCount(aux_pwm_base, trip_delay);
68 
69  //
70  // DCBH = TRIPIN4 = INPUT X-BAR 1 = EPWM8A in this example
71  //
72  EPWM_selectDigitalCompareTripInput(aux_pwm_base, system_trip_source,
73  EPWM_DC_TYPE_DCBH);
74  //
75  //Trigger DCBEVT1 when system_trip_source signal goes low(fault occurs)
76  //Trigger DCBEVT2 when system_trip_source signal goes high(recover from fault)
77  //
78  EPWM_setTripZoneDigitalCompareEventCondition(aux_pwm_base,
79  EPWM_TZ_DC_OUTPUT_B1,
80  EPWM_TZ_EVENT_DCXH_LOW);
81  EPWM_setTripZoneDigitalCompareEventCondition(aux_pwm_base,
82  EPWM_TZ_DC_OUTPUT_B2,
83  EPWM_TZ_EVENT_DCXH_HIGH);
84  //
85  // DCBEVT1/2 event as AQ T1/2
86  //
87  // T1 = DCBEVT1
88  EPWM_setActionQualifierT1TriggerSource(aux_pwm_base,
89  EPWM_AQ_TRIGGER_EVENT_TRIG_DCB_1);
90  // T2 = DCBEVT2
91  EPWM_setActionQualifierT2TriggerSource(aux_pwm_base,
92  EPWM_AQ_TRIGGER_EVENT_TRIG_DCB_2);
93 
94  //
95  // EPWMA Trip on AQ T1/T2
96  //
97  EPWM_setActionQualifierAction(aux_pwm_base,
98  EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH,
99  EPWM_AQ_OUTPUT_ON_T1_COUNT_UP);
100  EPWM_setActionQualifierAction(aux_pwm_base,
101  EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_HIGH,
102  EPWM_AQ_OUTPUT_ON_T1_COUNT_DOWN);
103  EPWM_setActionQualifierAction(aux_pwm_base,
104  EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW,
105  EPWM_AQ_OUTPUT_ON_T2_COUNT_UP);
106  EPWM_setActionQualifierAction(aux_pwm_base,
107  EPWM_AQ_OUTPUT_A, EPWM_AQ_OUTPUT_LOW,
108  EPWM_AQ_OUTPUT_ON_T2_COUNT_DOWN);
109 
110  EPWM_setTripZoneAction(aux_pwm_base ,EPWM_TZ_ACTION_EVENT_DCAEVT1,
111  EPWM_TZ_ACTION_DISABLE);
112  EPWM_setTripZoneAction(aux_pwm_base, EPWM_TZ_ACTION_EVENT_DCAEVT2,
113  EPWM_TZ_ACTION_DISABLE);
114  EPWM_setTripZoneAction(aux_pwm_base, EPWM_TZ_ACTION_EVENT_DCBEVT1,
115  EPWM_TZ_ACTION_DISABLE);
116  EPWM_setTripZoneAction(aux_pwm_base, EPWM_TZ_ACTION_EVENT_DCBEVT2,
117  EPWM_TZ_ACTION_DISABLE);
118  EPWM_setTripZoneAction(aux_pwm_base, EPWM_TZ_ACTION_EVENT_TZA,
119  EPWM_TZ_ACTION_DISABLE);
120  EPWM_setTripZoneAction(aux_pwm_base, EPWM_TZ_ACTION_EVENT_TZB,
121  EPWM_TZ_ACTION_DISABLE);
122  EDIS;
123 }
124 
129 void configEPWMDelayTrip(uint32_t base1,
130  EPWM_DigitalCompareTripInput aux_trip_source)
131 {
132  //
133  // Set force high actions for PWMxB during initialization
134  //
135  // Action When One-Time Software Force B is Invoked
136  EPWM_setActionQualifierSWAction(base1, EPWM_AQ_OUTPUT_B,
137  EPWM_AQ_OUTPUT_HIGH);
138  // Initiates a single software forced event
139  //
140  EPWM_forceActionQualifierSWAction(base1,EPWM_AQ_OUTPUT_B);
141 
142  //
143  // Configure EPWM DCBEVT1/2 as T1/2
144  // DCBEVT1/2 generation based on aux PWM ouput set high and clear low
145  //
146 
147  // DCBL = TRIPIN7 = INPUT X-BAR 3 = EPWM7A in this example
148  EPWM_selectDigitalCompareTripInput(base1, aux_trip_source,
149  EPWM_DC_TYPE_DCBL);
150 
151  //
152  // DCBL = High, Trigger DCBEVT1 when auxiliary PWM goes high
153  //
154  EPWM_setTripZoneDigitalCompareEventCondition(base1, EPWM_TZ_DC_OUTPUT_B1,
155  EPWM_TZ_EVENT_DCXL_HIGH);
156 
157  //
158  // DCBL = low, Trigger DCBEVT2 when auxiliary PWM goes low
159  //
160  EPWM_setTripZoneDigitalCompareEventCondition(base1, EPWM_TZ_DC_OUTPUT_B2,
161  EPWM_TZ_EVENT_DCXL_LOW);
162 
163  //
164  // DCBEVT1/2 event as AQ T1/2
165  // T1 = DCBEVT1
166  // T2 = DCBEVT2
167  //
168  EPWM_setActionQualifierT1TriggerSource(base1,
169  EPWM_AQ_TRIGGER_EVENT_TRIG_DCB_1);
170  EPWM_setActionQualifierT2TriggerSource(base1,
171  EPWM_AQ_TRIGGER_EVENT_TRIG_DCB_2);
172 
173  //
174  // set T1/T2 action setting for EPWMxB
175  //
176  EPWM_setActionQualifierAction(base1, EPWM_AQ_OUTPUT_B,
177  EPWM_AQ_OUTPUT_LOW,
178  EPWM_AQ_OUTPUT_ON_T1_COUNT_UP);
179  EPWM_setActionQualifierAction(base1, EPWM_AQ_OUTPUT_B,
180  EPWM_AQ_OUTPUT_LOW,
181  EPWM_AQ_OUTPUT_ON_T1_COUNT_DOWN);
182  EPWM_setActionQualifierAction(base1, EPWM_AQ_OUTPUT_B,
183  EPWM_AQ_OUTPUT_HIGH,
184  EPWM_AQ_OUTPUT_ON_T2_COUNT_UP);
185  EPWM_setActionQualifierAction(base1,EPWM_AQ_OUTPUT_B,
186  EPWM_AQ_OUTPUT_HIGH,
187  EPWM_AQ_OUTPUT_ON_T2_COUNT_DOWN);
188 }
189 
190 
191 
192 //*****************************************************************************
193 //
194 // Close the Doxygen group.
196 //
197 //*****************************************************************************
198 
199 #ifdef __cplusplus
200 }
201 #endif // extern "C"
202 
203 #endif // end of TYPE4_PWM_PROTECTION_SOURCE_H definition
configEPWMDelayTrip
void configEPWMDelayTrip(uint32_t base1, EPWM_DigitalCompareTripInput aux_trip_source)
Configures the delay trip action for inner switches(PWMxB).
Definition: type4_pwm_protection_source.h:129
initEPWM_aux_trip
void initEPWM_aux_trip(uint32_t aux_pwm_base, EPWM_DigitalCompareTripInput system_trip_source, uint16_t trip_delay)
Defines the initialization steps for an auxiliary PWM output.
Definition: type4_pwm_protection_source.h:45