1/*
2 * File: Inverter_001.c
3 *
4 * Code generated for Simulink model 'Inverter_001'.
5 *
6 * Model version : 1.139
7 * Simulink Coder version : 8.14 (R2018a) 06-Feb-2018
8 * C/C++ source code generated on : Wed Apr 14 17:37:41 2021
9 *
10 * Target selection: ert.tlc
11 * Embedded hardware selection: Texas Instruments->C2000
12 * Code generation objectives: Unspecified
13 * Validation result: Not run
14 */
15
16#include "Inverter_001.h"
17#include "Inverter_001_private.h"
18
19/* Block signals (default storage) */
20B_Inverter_001_T Inverter_001_B;
21
22/* Block states (default storage) */
23DW_Inverter_001_T Inverter_001_DW;
24
25/* Real-time model */
26RT_MODEL_Inverter_001_T Inverter_001_M_;
27RT_MODEL_Inverter_001_T *const Inverter_001_M = &Inverter_001_M_;
28static void rate_monotonic_scheduler(void);
29static uint16_T adcDInitFlag = 0;
30static uint16_T adcAInitFlag = 0;
31static uint16_T adcCInitFlag = 0;
32
33/*
34 * Set which subrates need to run this base step (base rate always runs).
35 * This function must be called prior to calling the model step function
36 * in order to "remember" which rates need to run this base step. The
37 * buffering of events allows for overlapping preemption.
38 */
39void Inverter_001_SetEventsForThisBaseStep(boolean_T *eventFlags)
40{
41 /* Task runs when its counter is zero, computed via rtmStepTask macro */
42 eventFlags[1] = ((boolean_T)rtmStepTask(Inverter_001_M, 1));
43 eventFlags[2] = ((boolean_T)rtmStepTask(Inverter_001_M, 2));
44 eventFlags[3] = ((boolean_T)rtmStepTask(Inverter_001_M, 3));
45}
46
47/*
48 * This function updates active task flag for each subrate
49 * and rate transition flags for tasks that exchange data.
50 * The function assumes rate-monotonic multitasking scheduler.
51 * The function must be called at model base rate so that
52 * the generated code self-manages all its subrates and rate
53 * transition flags.
54 */
55static void rate_monotonic_scheduler(void)
56{
57 /* To ensure a deterministic data transfer between two rates,
58 * data is transferred at the priority of a fast task and the frequency
59 * of the slow task. The following flags indicate when the data transfer
60 * happens. That is, a rate interaction flag is set true when both rates
61 * will run, and false otherwise.
62 */
63
64 /* tid 0 shares data with slower tid rates: 1, 3 */
65 Inverter_001_M->Timing.RateInteraction.TID0_1 =
66 (Inverter_001_M->Timing.TaskCounters.TID[1] == 0);
67 Inverter_001_M->Timing.RateInteraction.TID0_3 =
68 (Inverter_001_M->Timing.TaskCounters.TID[3] == 0);
69
70 /* Compute which subrates run during the next base time step. Subrates
71 * are an integer multiple of the base rate counter. Therefore, the subtask
72 * counter is reset when it reaches its limit (zero means run).
73 */
74 (Inverter_001_M->Timing.TaskCounters.TID[1])++;
75 if ((Inverter_001_M->Timing.TaskCounters.TID[1]) > 1) {/* Sample time: [0.0001s, 0.0s] */
76 Inverter_001_M->Timing.TaskCounters.TID[1] = 0;
77 }
78
79 (Inverter_001_M->Timing.TaskCounters.TID[2])++;
80 if ((Inverter_001_M->Timing.TaskCounters.TID[2]) > 3) {/* Sample time: [0.0002s, 0.0s] */
81 Inverter_001_M->Timing.TaskCounters.TID[2] = 0;
82 }
83
84 (Inverter_001_M->Timing.TaskCounters.TID[3])++;
85 if ((Inverter_001_M->Timing.TaskCounters.TID[3]) > 1999) {/* Sample time: [0.1s, 0.0s] */
86 Inverter_001_M->Timing.TaskCounters.TID[3] = 0;
87 }
88}
89
90real32_T rt_roundf_snf(real32_T u)
91{
92 real32_T y;
93 if (fabsf(u) < 8.388608E+6F) {
94 if (u >= 0.5F) {
95 y = (real32_T)floor(u + 0.5F);
96 } else if (u > -0.5F) {
97 y = u * 0.0F;
98 } else {
99 y = (real32_T)ceil(u - 0.5F);
100 }
101 } else {
102 y = u;
103 }
104
105 return y;
106}
107
108/* Model step function for TID0 */
109void Inverter_001_step0(void) /* Sample time: [5.0E-5s, 0.0s] */
110{
111 /* local block i/o variables */
112 int32_T rtb_FloattoIQN4[3];
113 int32_T rtb_FloattoIQN[3];
114 int32_T rtb_FloattoIQN4_g[9];
115 int32_T rtb_HighPassFilterOutput_m;
116 int32_T rtb_HighPassFilterOutput_ei;
117 int32_T rtb_HighPassFilterOutput_hd;
118 int32_T rtb_HighPassFilterOutput_au;
119 int32_T rtb_HighPassFilterOutput_hi;
120 int32_T rtb_HighPassFilterOutput;
121 int32_T rtb_HighPassFilterOutput_pm;
122 int32_T rtb_HighPassFilterOutput_a;
123 int32_T rtb_HighPassFilterOutput_l1;
124 int32_T rtb_Sum5_o;
125 int32_T rtb_Sum4_p;
126 int32_T rtb_Sum1_p;
127 int32_T rtb_Sum1;
128 real32_T rtb_Add7;
129 real32_T rtb_Add3;
130 real32_T rtb_Add4;
131 real32_T rtb_Add5;
132 real32_T rtb_Add16;
133 real32_T rtb_Add9;
134 real32_T rtb_Add10;
135 real32_T rtb_Add11;
136 real32_T rtb_DataTypeConversion2[3];
137 real32_T rtb_DataTypeConversion13;
138 real32_T rtb_TmpSignalConversionAtFloatt[9];
139
140 { /* Sample time: [5.0E-5s, 0.0s] */
141 rate_monotonic_scheduler();
142 }
143
144 /* RateTransition: '<Root>/TmpRTBAtConstant62Outport1' */
145 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
146 Inverter_001_B.TmpRTBAtConstant62Outport1 =
147 Inverter_001_DW.TmpRTBAtConstant62Outport1_Buff;
148
149 /* RateTransition: '<S2>/TmpRTBAtAdd11Inport2' */
150 Inverter_001_B.TmpRTBAtAdd11Inport2 =
151 Inverter_001_DW.TmpRTBAtAdd11Inport2_Buffer0;
152 }
153
154 /* End of RateTransition: '<Root>/TmpRTBAtConstant62Outport1' */
155
156 /* RateTransition: '<Root>/Rate Transition1' */
157 if (Inverter_001_M->Timing.RateInteraction.TID0_1) {
158 Inverter_001_B.RateTransition1 = Inverter_001_DW.RateTransition1_Buffer0;
159 }
160
161 /* End of RateTransition: '<Root>/Rate Transition1' */
162
163 /* Gain: '<S6>/Gain3' */
164 rtb_DataTypeConversion13 = Inverter_001_P.Gain3_Gain *
165 Inverter_001_B.RateTransition1;
166
167 /* S-Function (stiiqmath_iq): '<S6>/Float to IQN2' */
168
169 /* C28x IQmath Library (stiiqmath_iq) - '<S6>/Float to IQN2' */
170 {
171 rtb_HighPassFilterOutput_au = _IQ10 (rtb_DataTypeConversion13);
172 }
173
174 /* Product: '<S6>/Product5' incorporates:
175 * Constant: '<S6>/Constant10'
176 * Constant: '<S6>/Constant13'
177 * Constant: '<S6>/Constant14'
178 */
179 rtb_Add11 = (real32_T)rtb_HighPassFilterOutput_au * 0.0009765625F;
180 rtb_DataTypeConversion2[0] = rtb_Add11 * Inverter_001_P.Constant13_Value_c;
181 rtb_DataTypeConversion2[1] = rtb_Add11 * Inverter_001_P.Constant14_Value_p;
182 rtb_DataTypeConversion2[2] = rtb_Add11 * Inverter_001_P.Constant10_Value;
183
184 /* S-Function (stiiqmath_iq): '<S6>/Float to IQN' */
185
186 /* C28x IQmath Library (stiiqmath_iq) - '<S6>/Float to IQN' */
187 {
188 rtb_FloattoIQN[0] = _IQ10 (rtb_DataTypeConversion2[0]);
189 rtb_FloattoIQN[1] = _IQ10 (rtb_DataTypeConversion2[1]);
190 rtb_FloattoIQN[2] = _IQ10 (rtb_DataTypeConversion2[2]);
191 }
192
193 /* S-Function (scheckfractionlength): '<S33>/ ' */
194 rtb_HighPassFilterOutput_au = rtb_FloattoIQN[0];
195
196 /* Product: '<S34>/Product1' incorporates:
197 * Constant: '<S6>/Constant11'
198 * S-Function (scheckfractionlength): '<S34>/ '
199 */
200 rtb_Sum1 = Inverter_001_P.Constant11_Value;
201
202 /* S-Function (scheckfractionlength): '<S34>/ 1' incorporates:
203 * Constant: '<S6>/Constant8'
204 */
205 rtb_HighPassFilterOutput = Inverter_001_P.Constant8_Value_e;
206
207 /* S-Function (scheckfractionlength): '<S34>/ 2' incorporates:
208 * Constant: '<S6>/Constant9'
209 */
210 rtb_HighPassFilterOutput_pm = Inverter_001_P.Constant9_Value;
211
212 /* Sum: '<S34>/Sum2' incorporates:
213 * UnitDelay: '<S34>/Unit Delay'
214 */
215 Inverter_001_DW.UnitDelay_DSTATE_lw += rtb_Sum1;
216
217 /* Switch: '<S36>/Switch' incorporates:
218 * Constant: '<S36>/1'
219 * RelationalOperator: '<S36>/Relational Operator'
220 * Sum: '<S36>/Sum2'
221 */
222 if (Inverter_001_DW.UnitDelay_DSTATE_lw > Inverter_001_P.u_Value) {
223 Inverter_001_DW.UnitDelay_DSTATE_lw -= Inverter_001_P.u_Value;
224 }
225
226 /* End of Switch: '<S36>/Switch' */
227
228 /* Switch: '<S36>/Switch1' incorporates:
229 * Constant: '<S36>/-1'
230 * Constant: '<S36>/1'
231 * RelationalOperator: '<S36>/Relational Operator1'
232 * Sum: '<S36>/Sum1'
233 * UnitDelay: '<S34>/Unit Delay'
234 */
235 if (Inverter_001_DW.UnitDelay_DSTATE_lw < Inverter_001_P.u_Value_e) {
236 Inverter_001_DW.UnitDelay_DSTATE_lw += Inverter_001_P.u_Value;
237 }
238
239 /* End of Switch: '<S36>/Switch1' */
240
241 /* Product: '<S34>/Product2' incorporates:
242 * UnitDelay: '<S34>/Unit Delay'
243 */
244 rtb_Sum1 = __IQmpy(Inverter_001_DW.UnitDelay_DSTATE_lw,
245 rtb_HighPassFilterOutput, 29);
246
247 /* Sum: '<S34>/Sum1' */
248 rtb_Sum1 += rtb_HighPassFilterOutput_pm;
249
250 /* Switch: '<S37>/Switch2' incorporates:
251 * Constant: '<S37>/1'
252 * RelationalOperator: '<S37>/Relational Operator2'
253 * Sum: '<S37>/Sum4'
254 */
255 if (rtb_Sum1 > Inverter_001_P.u_Value_f) {
256 rtb_Sum1 -= Inverter_001_P.u_Value_f;
257 }
258
259 /* End of Switch: '<S37>/Switch2' */
260
261 /* Switch: '<S37>/Switch3' incorporates:
262 * Constant: '<S37>/-1'
263 * Constant: '<S37>/1'
264 * RelationalOperator: '<S37>/Relational Operator3'
265 * Sum: '<S37>/Sum3'
266 */
267 if (rtb_Sum1 < Inverter_001_P.u_Value_c) {
268 rtb_Sum1 += Inverter_001_P.u_Value_f;
269 }
270
271 /* End of Switch: '<S37>/Switch3' */
272
273 /* S-Function (stiiqmath_iqtof): '<S6>/IQN to Float3' */
274
275 /* C28x IQmath Library (stiiqmath_iqtof) - '<S6>/IQN to Float3' */
276 {
277 rtb_DataTypeConversion13 = _IQ29toF (rtb_Sum1);
278 }
279
280 /* Gain: '<S6>/Gain2' */
281 rtb_DataTypeConversion13 *= Inverter_001_P.Gain2_Gain;
282
283 /* S-Function (stiiqmath_iq): '<S6>/Float to IQN1' */
284
285 /* C28x IQmath Library (stiiqmath_iq) - '<S6>/Float to IQN1' */
286 {
287 rtb_Sum1 = _IQ10 (rtb_DataTypeConversion13);
288 }
289
290 /* S-Function (scheckfractionlength): '<S33>/ 2' */
291 rtb_HighPassFilterOutput_pm = rtb_Sum1;
292
293 /* S-Function (stiiqmath_iqtrig): '<S33>/cos IQN' */
294
295 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S33>/cos IQN' */
296 {
297 rtb_HighPassFilterOutput = _IQ10cos(rtb_HighPassFilterOutput_pm);
298 }
299
300 /* Product: '<S33>/Product2' */
301 rtb_HighPassFilterOutput_hi = __IQmpy(rtb_HighPassFilterOutput_au,
302 rtb_HighPassFilterOutput, 10);
303
304 /* S-Function (scheckfractionlength): '<S33>/ 1' */
305 rtb_HighPassFilterOutput = rtb_FloattoIQN[1];
306
307 /* S-Function (stiiqmath_iqtrig): '<S33>/sin IQN' */
308
309 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S33>/sin IQN' */
310 {
311 rtb_HighPassFilterOutput_a = _IQ10sin(rtb_HighPassFilterOutput_pm);
312 }
313
314 /* Product: '<S33>/Product3' */
315 rtb_Sum5_o = __IQmpy(rtb_HighPassFilterOutput, rtb_HighPassFilterOutput_a, 10);
316
317 /* S-Function (scheckfractionlength): '<S33>/ 3' */
318 rtb_HighPassFilterOutput_a = rtb_FloattoIQN[2];
319
320 /* Sum: '<S33>/Sum1' */
321 rtb_Sum1_p = (rtb_HighPassFilterOutput_hi - rtb_Sum5_o) +
322 rtb_HighPassFilterOutput_a;
323
324 /* S-Function (stiiqmath_iq): '<S33>/Float to IQN' incorporates:
325 * Constant: '<S33>/Constant'
326 */
327
328 /* C28x IQmath Library (stiiqmath_iq) - '<S33>/Float to IQN' */
329 {
330 rtb_Sum5_o = _IQ10 (Inverter_001_P.Constant_Value);
331 }
332
333 /* Sum: '<S33>/Sum3' */
334 rtb_HighPassFilterOutput_hi = rtb_HighPassFilterOutput_pm - rtb_Sum5_o;
335
336 /* S-Function (stiiqmath_iqtrig): '<S33>/cos IQN1' */
337
338 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S33>/cos IQN1' */
339 {
340 rtb_Sum4_p = _IQ10cos(rtb_HighPassFilterOutput_hi);
341 }
342
343 /* Product: '<S33>/Product4' */
344 rtb_HighPassFilterOutput_l1 = __IQmpy(rtb_HighPassFilterOutput_au, rtb_Sum4_p,
345 10);
346
347 /* S-Function (stiiqmath_iqtrig): '<S33>/sin IQN1' */
348
349 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S33>/sin IQN1' */
350 {
351 rtb_Sum4_p = _IQ10sin(rtb_HighPassFilterOutput_hi);
352 }
353
354 /* Product: '<S33>/Product5' */
355 rtb_HighPassFilterOutput_hi = __IQmpy(rtb_HighPassFilterOutput, rtb_Sum4_p, 10);
356
357 /* Sum: '<S33>/Sum4' */
358 rtb_Sum4_p = (rtb_HighPassFilterOutput_l1 - rtb_HighPassFilterOutput_hi) +
359 rtb_HighPassFilterOutput_a;
360
361 /* Sum: '<S33>/Sum' */
362 rtb_HighPassFilterOutput_l1 = rtb_HighPassFilterOutput_pm + rtb_Sum5_o;
363
364 /* S-Function (stiiqmath_iqtrig): '<S33>/cos IQN2' */
365
366 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S33>/cos IQN2' */
367 {
368 rtb_Sum5_o = _IQ10cos(rtb_HighPassFilterOutput_l1);
369 }
370
371 /* Product: '<S33>/Product6' */
372 rtb_HighPassFilterOutput_pm = __IQmpy(rtb_HighPassFilterOutput_au, rtb_Sum5_o,
373 10);
374
375 /* S-Function (stiiqmath_iqtrig): '<S33>/sin IQN2' */
376
377 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S33>/sin IQN2' */
378 {
379 rtb_Sum5_o = _IQ10sin(rtb_HighPassFilterOutput_l1);
380 }
381
382 /* Product: '<S33>/Product7' */
383 rtb_HighPassFilterOutput_l1 = __IQmpy(rtb_HighPassFilterOutput, rtb_Sum5_o, 10);
384
385 /* Sum: '<S33>/Sum5' */
386 rtb_Sum5_o = (rtb_HighPassFilterOutput_pm - rtb_HighPassFilterOutput_l1) +
387 rtb_HighPassFilterOutput_a;
388
389 /* RateTransition: '<Root>/Rate Transition60' */
390 if (Inverter_001_M->Timing.RateInteraction.TID0_1) {
391 Inverter_001_B.RateTransition60[0] = rtb_Sum1_p;
392 Inverter_001_B.RateTransition60[1] = rtb_Sum4_p;
393 Inverter_001_B.RateTransition60[2] = rtb_Sum5_o;
394 }
395
396 /* End of RateTransition: '<Root>/Rate Transition60' */
397
398 /* RelationalOperator: '<Root>/Relational Operator2' incorporates:
399 * Constant: '<Root>/Constant3'
400 */
401 Inverter_001_B.RelationalOperator2[0] = (rtb_Sum1_p >
402 Inverter_001_P.Constant3_Value);
403 Inverter_001_B.RelationalOperator2[1] = (rtb_Sum4_p >
404 Inverter_001_P.Constant3_Value);
405 Inverter_001_B.RelationalOperator2[2] = (rtb_Sum5_o >
406 Inverter_001_P.Constant3_Value);
407
408 /* S-Function (c280xgpio_do): '<Root>/Digital Output' */
409 {
410 if (Inverter_001_B.RelationalOperator2[0])
411 GpioDataRegs.GPBSET.bit.GPIO61 = 1;
412 else
413 GpioDataRegs.GPBCLEAR.bit.GPIO61 = 1;
414 }
415
416 /* S-Function (c280xgpio_do): '<Root>/Digital Output1' */
417 {
418 if (Inverter_001_B.RelationalOperator2[1])
419 GpioDataRegs.GPBSET.bit.GPIO63 = 1;
420 else
421 GpioDataRegs.GPBCLEAR.bit.GPIO63 = 1;
422 }
423
424 /* S-Function (c280xgpio_do): '<Root>/Digital Output2' */
425 {
426 if (Inverter_001_B.RelationalOperator2[2])
427 GpioDataRegs.GPCSET.bit.GPIO66 = 1;
428 else
429 GpioDataRegs.GPCCLEAR.bit.GPIO66 = 1;
430 }
431
432 /* Sum: '<S7>/Sum2' incorporates:
433 * UnitDelay: '<S7>/Unit Delay'
434 * UnitDelay: '<S7>/Unit Delay1'
435 */
436 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
437 Inverter_001_DW.UnitDelay_DSTATE * 0.0009765625F + (real32_T)
438 Inverter_001_DW.UnitDelay1_DSTATE * 0.0009765625F) * 1024.0F),
439 4.294967296E+9);
440 Inverter_001_DW.UnitDelay1_DSTATE = rtb_DataTypeConversion13 < 0.0F ?
441 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
442 rtb_DataTypeConversion13;
443
444 /* S-Function (stiiqmath_iqmpyiqx): '<S7>/IQN1 x IQN2' incorporates:
445 * Constant: '<S1>/Constant2'
446 */
447
448 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S7>/IQN1 x IQN2' */
449 {
450 rtb_HighPassFilterOutput_l1 = _IQ10mpyIQX (Inverter_001_P.Constant2_Value,
451 10, Inverter_001_DW.UnitDelay1_DSTATE, 10);
452 }
453
454 /* S-Function (c2802xadc): '<S2>/ADC2' */
455 {
456 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
457 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
458 AdcdRegs.ADCSOCFRC1.bit.SOC2 = 1;
459
460 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
461 asm(" RPT #75 || NOP");
462 Inverter_001_B.ADC2 = (AdcdResultRegs.ADCRESULT2);
463 }
464
465 /* DataTypeConversion: '<S2>/Data Type Conversion3' */
466 rtb_DataTypeConversion13 = Inverter_001_B.ADC2;
467
468 /* Sum: '<S2>/Add11' */
469 rtb_Add11 = rtb_DataTypeConversion13 + Inverter_001_B.TmpRTBAtAdd11Inport2;
470
471 /* RateTransition: '<S2>/TmpRTBAtAdd10Inport2' */
472 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
473 Inverter_001_B.TmpRTBAtAdd10Inport2 =
474 Inverter_001_DW.TmpRTBAtAdd10Inport2_Buffer0;
475 }
476
477 /* End of RateTransition: '<S2>/TmpRTBAtAdd10Inport2' */
478
479 /* S-Function (c2802xadc): '<S2>/ADC3' */
480 {
481 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
482 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
483 AdcdRegs.ADCSOCFRC1.bit.SOC5 = 1;
484
485 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
486 asm(" RPT #75 || NOP");
487 Inverter_001_B.ADC3 = (AdcdResultRegs.ADCRESULT5);
488 }
489
490 /* DataTypeConversion: '<S2>/Data Type Conversion4' */
491 rtb_DataTypeConversion13 = Inverter_001_B.ADC3;
492
493 /* Sum: '<S2>/Add10' */
494 rtb_Add10 = rtb_DataTypeConversion13 + Inverter_001_B.TmpRTBAtAdd10Inport2;
495
496 /* RateTransition: '<S2>/TmpRTBAtAdd9Inport2' */
497 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
498 Inverter_001_B.TmpRTBAtAdd9Inport2 =
499 Inverter_001_DW.TmpRTBAtAdd9Inport2_Buffer0;
500 }
501
502 /* End of RateTransition: '<S2>/TmpRTBAtAdd9Inport2' */
503
504 /* S-Function (c2802xadc): '<S2>/ADC4' */
505 {
506 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
507 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
508 AdcdRegs.ADCSOCFRC1.bit.SOC7 = 1;
509
510 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
511 asm(" RPT #75 || NOP");
512 Inverter_001_B.ADC4 = (AdcdResultRegs.ADCRESULT7);
513 }
514
515 /* DataTypeConversion: '<S2>/Data Type Conversion5' */
516 rtb_DataTypeConversion13 = Inverter_001_B.ADC4;
517
518 /* Sum: '<S2>/Add9' */
519 rtb_Add9 = rtb_DataTypeConversion13 + Inverter_001_B.TmpRTBAtAdd9Inport2;
520
521 /* RateTransition: '<Root>/TmpRTBAtConstant12Outport1' */
522 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
523 Inverter_001_B.TmpRTBAtConstant12Outport1 =
524 Inverter_001_DW.TmpRTBAtConstant12Outport1_Buff;
525
526 /* RateTransition: '<S2>/TmpRTBAtAdd16Inport2' */
527 Inverter_001_B.TmpRTBAtAdd16Inport2 =
528 Inverter_001_DW.TmpRTBAtAdd16Inport2_Buffer0;
529 }
530
531 /* End of RateTransition: '<Root>/TmpRTBAtConstant12Outport1' */
532
533 /* S-Function (c2802xadc): '<S2>/ADC5' */
534 {
535 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
536 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
537 AdcaRegs.ADCSOCFRC1.bit.SOC4 = 1;
538
539 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
540 asm(" RPT #75 || NOP");
541 Inverter_001_B.ADC5 = (AdcaResultRegs.ADCRESULT4);
542 }
543
544 /* DataTypeConversion: '<S2>/Data Type Conversion16' */
545 rtb_DataTypeConversion13 = Inverter_001_B.ADC5;
546
547 /* Sum: '<S2>/Add16' */
548 rtb_Add16 = rtb_DataTypeConversion13 + Inverter_001_B.TmpRTBAtAdd16Inport2;
549
550 /* RateTransition: '<S2>/TmpRTBAtAdd5Inport2' */
551 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
552 Inverter_001_B.TmpRTBAtAdd5Inport2 =
553 Inverter_001_DW.TmpRTBAtAdd5Inport2_Buffer0;
554 }
555
556 /* End of RateTransition: '<S2>/TmpRTBAtAdd5Inport2' */
557
558 /* S-Function (c2802xadc): '<S2>/ADC6' */
559 {
560 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
561 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
562 AdcaRegs.ADCSOCFRC1.bit.SOC6 = 1;
563
564 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
565 asm(" RPT #75 || NOP");
566 Inverter_001_B.LoadCurrentIa = (AdcaResultRegs.ADCRESULT6);
567 }
568
569 /* DataTypeConversion: '<S2>/Data Type Conversion9' */
570 rtb_DataTypeConversion13 = Inverter_001_B.LoadCurrentIa;
571
572 /* Sum: '<S2>/Add5' */
573 rtb_Add5 = rtb_DataTypeConversion13 + Inverter_001_B.TmpRTBAtAdd5Inport2;
574
575 /* RateTransition: '<S2>/TmpRTBAtAdd4Inport2' */
576 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
577 Inverter_001_B.TmpRTBAtAdd4Inport2 =
578 Inverter_001_DW.TmpRTBAtAdd4Inport2_Buffer0;
579 }
580
581 /* End of RateTransition: '<S2>/TmpRTBAtAdd4Inport2' */
582
583 /* S-Function (c2802xadc): '<S2>/ADC7' */
584 {
585 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
586 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
587 AdcaRegs.ADCSOCFRC1.bit.SOC8 = 1;
588
589 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
590 asm(" RPT #75 || NOP");
591 Inverter_001_B.InverterCurrentIc = (AdcaResultRegs.ADCRESULT8);
592 }
593
594 /* DataTypeConversion: '<S2>/Data Type Conversion11' */
595 rtb_DataTypeConversion13 = Inverter_001_B.InverterCurrentIc;
596
597 /* Sum: '<S2>/Add4' */
598 rtb_Add4 = rtb_DataTypeConversion13 + Inverter_001_B.TmpRTBAtAdd4Inport2;
599
600 /* RateTransition: '<S2>/TmpRTBAtAdd3Inport2' */
601 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
602 Inverter_001_B.TmpRTBAtAdd3Inport2 =
603 Inverter_001_DW.TmpRTBAtAdd3Inport2_Buffer0;
604 }
605
606 /* End of RateTransition: '<S2>/TmpRTBAtAdd3Inport2' */
607
608 /* S-Function (c2802xadc): '<S2>/ADC9' */
609 {
610 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
611 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
612 AdccRegs.ADCSOCFRC1.bit.SOC10 = 1;
613
614 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
615 asm(" RPT #75 || NOP");
616 Inverter_001_B.ADC9 = (AdccResultRegs.ADCRESULT10);
617 }
618
619 /* DataTypeConversion: '<S2>/Data Type Conversion12' */
620 rtb_DataTypeConversion13 = Inverter_001_B.ADC9;
621
622 /* Sum: '<S2>/Add3' */
623 rtb_Add3 = rtb_DataTypeConversion13 + Inverter_001_B.TmpRTBAtAdd3Inport2;
624
625 /* RateTransition: '<S2>/TmpRTBAtAdd7Inport2' */
626 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
627 Inverter_001_B.TmpRTBAtAdd7Inport2 =
628 Inverter_001_DW.TmpRTBAtAdd7Inport2_Buffer0;
629 }
630
631 /* End of RateTransition: '<S2>/TmpRTBAtAdd7Inport2' */
632
633 /* S-Function (c2802xadc): '<S2>/ADC10' */
634 {
635 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
636 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
637 AdccRegs.ADCSOCFRC1.bit.SOC11 = 1;
638
639 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
640 asm(" RPT #75 || NOP");
641 Inverter_001_B.ADC10 = (AdccResultRegs.ADCRESULT11);
642 }
643
644 /* DataTypeConversion: '<S2>/Data Type Conversion7' */
645 rtb_DataTypeConversion13 = Inverter_001_B.ADC10;
646
647 /* Sum: '<S2>/Add7' */
648 rtb_Add7 = rtb_DataTypeConversion13 + Inverter_001_B.TmpRTBAtAdd7Inport2;
649
650 /* RateTransition: '<S2>/TmpRTBAtAdd2Inport2' */
651 if (Inverter_001_M->Timing.RateInteraction.TID0_3) {
652 Inverter_001_B.TmpRTBAtAdd2Inport2 =
653 Inverter_001_DW.TmpRTBAtAdd2Inport2_Buffer0;
654 }
655
656 /* End of RateTransition: '<S2>/TmpRTBAtAdd2Inport2' */
657
658 /* S-Function (c2802xadc): '<S2>/ADC11' */
659 {
660 /* Internal Reference Voltage : Fixed scale 0 to 3.3 V range. */
661 /* External Reference Voltage : Allowable ranges of VREFHI(ADCINA0) = 3.3 and VREFLO(tied to ground) = 0 */
662 AdccRegs.ADCSOCFRC1.bit.SOC12 = 1;
663
664 /* Wait for the period of Sampling window and EOC result to be latched after trigger */
665 asm(" RPT #75 || NOP");
666 Inverter_001_B.ADC11 = (AdccResultRegs.ADCRESULT12);
667 }
668
669 /* DataTypeConversion: '<S2>/Data Type Conversion13' */
670 rtb_DataTypeConversion13 = Inverter_001_B.ADC11;
671
672 /* SignalConversion: '<Root>/TmpSignal ConversionAtFloat to IQN4Inport1' incorporates:
673 * Product: '<S2>/Product11'
674 * Product: '<S2>/Product12'
675 * Product: '<S2>/Product13'
676 * Product: '<S2>/Product14'
677 * Product: '<S2>/Product16'
678 * Product: '<S2>/Product4'
679 * Product: '<S2>/Product5'
680 * Product: '<S2>/Product6'
681 * Product: '<S2>/Product9'
682 * Sum: '<S2>/Add2'
683 */
684 rtb_TmpSignalConversionAtFloatt[0] = rtb_Add11 *
685 Inverter_001_B.TmpRTBAtConstant62Outport1;
686 rtb_TmpSignalConversionAtFloatt[1] = rtb_Add10 *
687 Inverter_001_B.TmpRTBAtConstant62Outport1;
688 rtb_TmpSignalConversionAtFloatt[2] = rtb_Add9 *
689 Inverter_001_B.TmpRTBAtConstant62Outport1;
690 rtb_TmpSignalConversionAtFloatt[3] = rtb_Add16 *
691 Inverter_001_B.TmpRTBAtConstant12Outport1;
692 rtb_TmpSignalConversionAtFloatt[4] = rtb_Add5 *
693 Inverter_001_B.TmpRTBAtConstant12Outport1;
694 rtb_TmpSignalConversionAtFloatt[5] = rtb_Add4 *
695 Inverter_001_B.TmpRTBAtConstant12Outport1;
696 rtb_TmpSignalConversionAtFloatt[6] = rtb_Add3 *
697 Inverter_001_B.TmpRTBAtConstant12Outport1;
698 rtb_TmpSignalConversionAtFloatt[7] = rtb_Add7 *
699 Inverter_001_B.TmpRTBAtConstant12Outport1;
700 rtb_TmpSignalConversionAtFloatt[8] = (rtb_DataTypeConversion13 +
701 Inverter_001_B.TmpRTBAtAdd2Inport2) *
702 Inverter_001_B.TmpRTBAtConstant12Outport1;
703
704 /* S-Function (stiiqmath_iq): '<Root>/Float to IQN4' */
705
706 /* C28x IQmath Library (stiiqmath_iq) - '<Root>/Float to IQN4' */
707 {
708 {
709 int_T i1;
710 const real32_T *u0 = &rtb_TmpSignalConversionAtFloatt[0];
711 int32_T *y0 = &rtb_FloattoIQN4_g[0];
712 for (i1=0; i1 < 9; i1++) {
713 y0[i1] = _IQ10 (u0[i1]);
714 }
715 }
716 }
717
718 /* DataTypeConversion: '<Root>/Data Type Conversion2' */
719 rtb_DataTypeConversion2[0] = (real32_T)rtb_Sum1_p * 0.0009765625F;
720 rtb_DataTypeConversion2[1] = (real32_T)rtb_Sum4_p * 0.0009765625F;
721 rtb_DataTypeConversion2[2] = (real32_T)rtb_Sum5_o * 0.0009765625F;
722
723 /* RateTransition: '<Root>/Rate Transition5' */
724 if (Inverter_001_M->Timing.RateInteraction.TID0_1) {
725 Inverter_001_B.RateTransition5[0] = rtb_DataTypeConversion2[0];
726
727 /* RateTransition: '<Root>/Rate Transition62' */
728 Inverter_001_B.RateTransition62[0] = rtb_FloattoIQN[0];
729 Inverter_001_B.RateTransition5[1] = rtb_DataTypeConversion2[1];
730
731 /* RateTransition: '<Root>/Rate Transition62' */
732 Inverter_001_B.RateTransition62[1] = rtb_FloattoIQN[1];
733 Inverter_001_B.RateTransition5[2] = rtb_DataTypeConversion2[2];
734
735 /* RateTransition: '<Root>/Rate Transition62' */
736 Inverter_001_B.RateTransition62[2] = rtb_FloattoIQN[2];
737 }
738
739 /* End of RateTransition: '<Root>/Rate Transition5' */
740
741 /* SignalConversion: '<S3>/TmpSignal ConversionAtFloat to IQN4Inport1' incorporates:
742 * Constant: '<S3>/Constant10'
743 * Constant: '<S3>/Constant13'
744 * Constant: '<S3>/Constant14'
745 */
746 rtb_DataTypeConversion2[0] = Inverter_001_P.Constant13_Value_cs;
747 rtb_DataTypeConversion2[1] = Inverter_001_P.Constant14_Value_o;
748 rtb_DataTypeConversion2[2] = Inverter_001_P.Constant10_Value_j;
749
750 /* Sum: '<S7>/Sum1' incorporates:
751 * UnitDelay: '<S7>/Unit Delay'
752 */
753 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
754 rtb_FloattoIQN4_g[0] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput_l1
755 * 0.0009765625F) * 1024.0F), 4.294967296E+9);
756 Inverter_001_DW.UnitDelay_DSTATE = rtb_DataTypeConversion13 < 0.0F ? -(int32_T)
757 (uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
758 rtb_DataTypeConversion13;
759
760 /* Sum: '<S7>/Sum3' incorporates:
761 * UnitDelay: '<S7>/Unit Delay'
762 */
763 rtb_HighPassFilterOutput_l1 = rtb_FloattoIQN4_g[0] -
764 Inverter_001_DW.UnitDelay_DSTATE;
765
766 /* Sum: '<S8>/Sum2' incorporates:
767 * UnitDelay: '<S8>/Unit Delay'
768 * UnitDelay: '<S8>/Unit Delay1'
769 */
770 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
771 Inverter_001_DW.UnitDelay_DSTATE_c * 0.0009765625F + (real32_T)
772 Inverter_001_DW.UnitDelay1_DSTATE_k * 0.0009765625F) * 1024.0F),
773 4.294967296E+9);
774 Inverter_001_DW.UnitDelay1_DSTATE_k = rtb_DataTypeConversion13 < 0.0F ?
775 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
776 rtb_DataTypeConversion13;
777
778 /* S-Function (stiiqmath_iqmpyiqx): '<S8>/IQN1 x IQN2' incorporates:
779 * Constant: '<S1>/Constant2'
780 */
781
782 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S8>/IQN1 x IQN2' */
783 {
784 rtb_HighPassFilterOutput_a = _IQ10mpyIQX (Inverter_001_P.Constant2_Value, 10,
785 Inverter_001_DW.UnitDelay1_DSTATE_k, 10);
786 }
787
788 /* Sum: '<S8>/Sum1' incorporates:
789 * UnitDelay: '<S8>/Unit Delay'
790 */
791 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
792 rtb_FloattoIQN4_g[1] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput_a *
793 0.0009765625F) * 1024.0F), 4.294967296E+9);
794 Inverter_001_DW.UnitDelay_DSTATE_c = rtb_DataTypeConversion13 < 0.0F ?
795 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
796 rtb_DataTypeConversion13;
797
798 /* Sum: '<S8>/Sum3' incorporates:
799 * UnitDelay: '<S8>/Unit Delay'
800 */
801 rtb_HighPassFilterOutput_a = rtb_FloattoIQN4_g[1] -
802 Inverter_001_DW.UnitDelay_DSTATE_c;
803
804 /* Sum: '<S9>/Sum2' incorporates:
805 * UnitDelay: '<S9>/Unit Delay'
806 * UnitDelay: '<S9>/Unit Delay1'
807 */
808 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
809 Inverter_001_DW.UnitDelay_DSTATE_f * 0.0009765625F + (real32_T)
810 Inverter_001_DW.UnitDelay1_DSTATE_j * 0.0009765625F) * 1024.0F),
811 4.294967296E+9);
812 Inverter_001_DW.UnitDelay1_DSTATE_j = rtb_DataTypeConversion13 < 0.0F ?
813 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
814 rtb_DataTypeConversion13;
815
816 /* S-Function (stiiqmath_iqmpyiqx): '<S9>/IQN1 x IQN2' incorporates:
817 * Constant: '<S1>/Constant2'
818 */
819
820 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S9>/IQN1 x IQN2' */
821 {
822 rtb_HighPassFilterOutput_pm = _IQ10mpyIQX (Inverter_001_P.Constant2_Value,
823 10, Inverter_001_DW.UnitDelay1_DSTATE_j, 10);
824 }
825
826 /* Sum: '<S9>/Sum1' incorporates:
827 * UnitDelay: '<S9>/Unit Delay'
828 */
829 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
830 rtb_FloattoIQN4_g[2] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput_pm
831 * 0.0009765625F) * 1024.0F), 4.294967296E+9);
832 Inverter_001_DW.UnitDelay_DSTATE_f = rtb_DataTypeConversion13 < 0.0F ?
833 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
834 rtb_DataTypeConversion13;
835
836 /* Sum: '<S9>/Sum3' incorporates:
837 * UnitDelay: '<S9>/Unit Delay'
838 */
839 rtb_HighPassFilterOutput_pm = rtb_FloattoIQN4_g[2] -
840 Inverter_001_DW.UnitDelay_DSTATE_f;
841
842 /* RateTransition: '<Root>/Rate Transition21' */
843 if (Inverter_001_M->Timing.RateInteraction.TID0_1) {
844 Inverter_001_B.RateTransition21[0] = rtb_HighPassFilterOutput_l1;
845 Inverter_001_B.RateTransition21[1] = rtb_HighPassFilterOutput_a;
846 Inverter_001_B.RateTransition21[2] = rtb_HighPassFilterOutput_pm;
847
848 /* RateTransition: '<Root>/Rate Transition61' */
849 Inverter_001_B.RateTransition61 = rtb_Sum1;
850 }
851
852 /* End of RateTransition: '<Root>/Rate Transition21' */
853
854 /* Sum: '<S10>/Sum2' incorporates:
855 * UnitDelay: '<S10>/Unit Delay'
856 * UnitDelay: '<S10>/Unit Delay1'
857 */
858 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
859 Inverter_001_DW.UnitDelay_DSTATE_g * 0.0009765625F + (real32_T)
860 Inverter_001_DW.UnitDelay1_DSTATE_l * 0.0009765625F) * 1024.0F),
861 4.294967296E+9);
862 Inverter_001_DW.UnitDelay1_DSTATE_l = rtb_DataTypeConversion13 < 0.0F ?
863 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
864 rtb_DataTypeConversion13;
865
866 /* S-Function (stiiqmath_iqmpyiqx): '<S10>/IQN1 x IQN2' incorporates:
867 * Constant: '<S1>/Constant2'
868 */
869
870 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S10>/IQN1 x IQN2' */
871 {
872 rtb_HighPassFilterOutput = _IQ10mpyIQX (Inverter_001_P.Constant2_Value, 10,
873 Inverter_001_DW.UnitDelay1_DSTATE_l, 10);
874 }
875
876 /* Sum: '<S10>/Sum1' incorporates:
877 * UnitDelay: '<S10>/Unit Delay'
878 */
879 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
880 rtb_FloattoIQN4_g[3] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput *
881 0.0009765625F) * 1024.0F), 4.294967296E+9);
882 Inverter_001_DW.UnitDelay_DSTATE_g = rtb_DataTypeConversion13 < 0.0F ?
883 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
884 rtb_DataTypeConversion13;
885
886 /* Sum: '<S10>/Sum3' incorporates:
887 * UnitDelay: '<S10>/Unit Delay'
888 */
889 rtb_HighPassFilterOutput = rtb_FloattoIQN4_g[3] -
890 Inverter_001_DW.UnitDelay_DSTATE_g;
891
892 /* Sum: '<S11>/Sum2' incorporates:
893 * UnitDelay: '<S11>/Unit Delay'
894 * UnitDelay: '<S11>/Unit Delay1'
895 */
896 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
897 Inverter_001_DW.UnitDelay_DSTATE_k * 0.0009765625F + (real32_T)
898 Inverter_001_DW.UnitDelay1_DSTATE_h * 0.0009765625F) * 1024.0F),
899 4.294967296E+9);
900 Inverter_001_DW.UnitDelay1_DSTATE_h = rtb_DataTypeConversion13 < 0.0F ?
901 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
902 rtb_DataTypeConversion13;
903
904 /* S-Function (stiiqmath_iqmpyiqx): '<S11>/IQN1 x IQN2' incorporates:
905 * Constant: '<S1>/Constant2'
906 */
907
908 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S11>/IQN1 x IQN2' */
909 {
910 rtb_HighPassFilterOutput_hi = _IQ10mpyIQX (Inverter_001_P.Constant2_Value,
911 10, Inverter_001_DW.UnitDelay1_DSTATE_h, 10);
912 }
913
914 /* Sum: '<S11>/Sum1' incorporates:
915 * UnitDelay: '<S11>/Unit Delay'
916 */
917 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
918 rtb_FloattoIQN4_g[4] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput_hi
919 * 0.0009765625F) * 1024.0F), 4.294967296E+9);
920 Inverter_001_DW.UnitDelay_DSTATE_k = rtb_DataTypeConversion13 < 0.0F ?
921 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
922 rtb_DataTypeConversion13;
923
924 /* Sum: '<S11>/Sum3' incorporates:
925 * UnitDelay: '<S11>/Unit Delay'
926 */
927 rtb_HighPassFilterOutput_hi = rtb_FloattoIQN4_g[4] -
928 Inverter_001_DW.UnitDelay_DSTATE_k;
929
930 /* Sum: '<S12>/Sum2' incorporates:
931 * UnitDelay: '<S12>/Unit Delay'
932 * UnitDelay: '<S12>/Unit Delay1'
933 */
934 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
935 Inverter_001_DW.UnitDelay_DSTATE_p * 0.0009765625F + (real32_T)
936 Inverter_001_DW.UnitDelay1_DSTATE_i * 0.0009765625F) * 1024.0F),
937 4.294967296E+9);
938 Inverter_001_DW.UnitDelay1_DSTATE_i = rtb_DataTypeConversion13 < 0.0F ?
939 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
940 rtb_DataTypeConversion13;
941
942 /* S-Function (stiiqmath_iqmpyiqx): '<S12>/IQN1 x IQN2' incorporates:
943 * Constant: '<S1>/Constant2'
944 */
945
946 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S12>/IQN1 x IQN2' */
947 {
948 rtb_HighPassFilterOutput_au = _IQ10mpyIQX (Inverter_001_P.Constant2_Value,
949 10, Inverter_001_DW.UnitDelay1_DSTATE_i, 10);
950 }
951
952 /* Sum: '<S12>/Sum1' incorporates:
953 * UnitDelay: '<S12>/Unit Delay'
954 */
955 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
956 rtb_FloattoIQN4_g[5] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput_au
957 * 0.0009765625F) * 1024.0F), 4.294967296E+9);
958 Inverter_001_DW.UnitDelay_DSTATE_p = rtb_DataTypeConversion13 < 0.0F ?
959 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
960 rtb_DataTypeConversion13;
961
962 /* Sum: '<S12>/Sum3' incorporates:
963 * UnitDelay: '<S12>/Unit Delay'
964 */
965 rtb_HighPassFilterOutput_au = rtb_FloattoIQN4_g[5] -
966 Inverter_001_DW.UnitDelay_DSTATE_p;
967
968 /* RateTransition: '<Root>/Rate Transition20' */
969 if (Inverter_001_M->Timing.RateInteraction.TID0_1) {
970 Inverter_001_B.RateTransition20[0] = rtb_HighPassFilterOutput;
971 Inverter_001_B.RateTransition20[1] = rtb_HighPassFilterOutput_hi;
972 Inverter_001_B.RateTransition20[2] = rtb_HighPassFilterOutput_au;
973 }
974
975 /* End of RateTransition: '<Root>/Rate Transition20' */
976
977 /* Sum: '<S13>/Sum2' incorporates:
978 * UnitDelay: '<S13>/Unit Delay'
979 * UnitDelay: '<S13>/Unit Delay1'
980 */
981 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
982 Inverter_001_DW.UnitDelay_DSTATE_d * 0.0009765625F + (real32_T)
983 Inverter_001_DW.UnitDelay1_DSTATE_hy * 0.0009765625F) * 1024.0F),
984 4.294967296E+9);
985 Inverter_001_DW.UnitDelay1_DSTATE_hy = rtb_DataTypeConversion13 < 0.0F ?
986 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
987 rtb_DataTypeConversion13;
988
989 /* S-Function (stiiqmath_iqmpyiqx): '<S13>/IQN1 x IQN2' incorporates:
990 * Constant: '<S1>/Constant2'
991 */
992
993 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S13>/IQN1 x IQN2' */
994 {
995 rtb_HighPassFilterOutput_hd = _IQ10mpyIQX (Inverter_001_P.Constant2_Value,
996 10, Inverter_001_DW.UnitDelay1_DSTATE_hy, 10);
997 }
998
999 /* Sum: '<S14>/Sum2' incorporates:
1000 * UnitDelay: '<S14>/Unit Delay'
1001 * UnitDelay: '<S14>/Unit Delay1'
1002 */
1003 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
1004 Inverter_001_DW.UnitDelay_DSTATE_j * 0.0009765625F + (real32_T)
1005 Inverter_001_DW.UnitDelay1_DSTATE_jm * 0.0009765625F) * 1024.0F),
1006 4.294967296E+9);
1007 Inverter_001_DW.UnitDelay1_DSTATE_jm = rtb_DataTypeConversion13 < 0.0F ?
1008 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
1009 rtb_DataTypeConversion13;
1010
1011 /* S-Function (stiiqmath_iqmpyiqx): '<S14>/IQN1 x IQN2' incorporates:
1012 * Constant: '<S1>/Constant2'
1013 */
1014
1015 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S14>/IQN1 x IQN2' */
1016 {
1017 rtb_HighPassFilterOutput_ei = _IQ10mpyIQX (Inverter_001_P.Constant2_Value,
1018 10, Inverter_001_DW.UnitDelay1_DSTATE_jm, 10);
1019 }
1020
1021 /* Sum: '<S15>/Sum2' incorporates:
1022 * UnitDelay: '<S15>/Unit Delay'
1023 * UnitDelay: '<S15>/Unit Delay1'
1024 */
1025 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
1026 Inverter_001_DW.UnitDelay_DSTATE_l * 0.0009765625F + (real32_T)
1027 Inverter_001_DW.UnitDelay1_DSTATE_p * 0.0009765625F) * 1024.0F),
1028 4.294967296E+9);
1029 Inverter_001_DW.UnitDelay1_DSTATE_p = rtb_DataTypeConversion13 < 0.0F ?
1030 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
1031 rtb_DataTypeConversion13;
1032
1033 /* S-Function (stiiqmath_iqmpyiqx): '<S15>/IQN1 x IQN2' incorporates:
1034 * Constant: '<S1>/Constant2'
1035 */
1036
1037 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S15>/IQN1 x IQN2' */
1038 {
1039 rtb_HighPassFilterOutput_m = _IQ10mpyIQX (Inverter_001_P.Constant2_Value, 10,
1040 Inverter_001_DW.UnitDelay1_DSTATE_p, 10);
1041 }
1042
1043 /* Sum: '<S13>/Sum1' incorporates:
1044 * UnitDelay: '<S13>/Unit Delay'
1045 */
1046 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
1047 rtb_FloattoIQN4_g[6] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput_hd
1048 * 0.0009765625F) * 1024.0F), 4.294967296E+9);
1049 Inverter_001_DW.UnitDelay_DSTATE_d = rtb_DataTypeConversion13 < 0.0F ?
1050 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
1051 rtb_DataTypeConversion13;
1052
1053 /* Sum: '<S13>/Sum3' incorporates:
1054 * UnitDelay: '<S13>/Unit Delay'
1055 */
1056 rtb_HighPassFilterOutput_hd = rtb_FloattoIQN4_g[6] -
1057 Inverter_001_DW.UnitDelay_DSTATE_d;
1058
1059 /* Sum: '<S14>/Sum1' incorporates:
1060 * UnitDelay: '<S14>/Unit Delay'
1061 */
1062 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
1063 rtb_FloattoIQN4_g[7] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput_ei
1064 * 0.0009765625F) * 1024.0F), 4.294967296E+9);
1065 Inverter_001_DW.UnitDelay_DSTATE_j = rtb_DataTypeConversion13 < 0.0F ?
1066 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
1067 rtb_DataTypeConversion13;
1068
1069 /* Sum: '<S14>/Sum3' incorporates:
1070 * UnitDelay: '<S14>/Unit Delay'
1071 */
1072 rtb_HighPassFilterOutput_ei = rtb_FloattoIQN4_g[7] -
1073 Inverter_001_DW.UnitDelay_DSTATE_j;
1074
1075 /* Sum: '<S15>/Sum1' incorporates:
1076 * UnitDelay: '<S15>/Unit Delay'
1077 */
1078 rtb_DataTypeConversion13 = (real32_T)fmod((real32_T)floor(((real32_T)
1079 rtb_FloattoIQN4_g[8] * 0.0009765625F - (real32_T)rtb_HighPassFilterOutput_m *
1080 0.0009765625F) * 1024.0F), 4.294967296E+9);
1081 Inverter_001_DW.UnitDelay_DSTATE_l = rtb_DataTypeConversion13 < 0.0F ?
1082 -(int32_T)(uint32_T)-rtb_DataTypeConversion13 : (int32_T)(uint32_T)
1083 rtb_DataTypeConversion13;
1084
1085 /* Sum: '<S15>/Sum3' incorporates:
1086 * UnitDelay: '<S15>/Unit Delay'
1087 */
1088 rtb_HighPassFilterOutput_m = rtb_FloattoIQN4_g[8] -
1089 Inverter_001_DW.UnitDelay_DSTATE_l;
1090
1091 /* RateTransition: '<Root>/Rate Transition19' */
1092 if (Inverter_001_M->Timing.RateInteraction.TID0_1) {
1093 Inverter_001_B.RateTransition19[0] = rtb_HighPassFilterOutput_hd;
1094 Inverter_001_B.RateTransition19[1] = rtb_HighPassFilterOutput_ei;
1095 Inverter_001_B.RateTransition19[2] = rtb_HighPassFilterOutput_m;
1096 }
1097
1098 /* End of RateTransition: '<Root>/Rate Transition19' */
1099
1100 /* S-Function (stiiqmath_iq): '<S3>/Float to IQN4' */
1101
1102 /* C28x IQmath Library (stiiqmath_iq) - '<S3>/Float to IQN4' */
1103 {
1104 rtb_FloattoIQN4[0] = _IQ10 (rtb_DataTypeConversion2[0]);
1105 rtb_FloattoIQN4[1] = _IQ10 (rtb_DataTypeConversion2[1]);
1106 rtb_FloattoIQN4[2] = _IQ10 (rtb_DataTypeConversion2[2]);
1107 }
1108
1109 /* MATLABSystem: '<Root>/DAC2' */
1110 MW_C2000DAC(2U, 0U);
1111}
1112
1113/* Model step function for TID1 */
1114void Inverter_001_step1(void) /* Sample time: [0.0001s, 0.0s] */
1115{
1116 /* local block i/o variables */
1117 real32_T rtb_Product15;
1118 real32_T rtb_Product17;
1119 real32_T rtb_Product21;
1120 real32_T rtb_Product19;
1121 int32_T rtb_IQN1xIQN6;
1122 int32_T rtb_IQN1xIQN6_j;
1123 int32_T rtb_IQN1xIQN6_n;
1124 int32_T rtb_cosIQN;
1125 int32_T rtb_cosIQN1;
1126 int32_T rtb_cosIQN2;
1127 int32_T rtb_sinIQN;
1128 int32_T rtb_sinIQN1;
1129 int32_T rtb_sinIQN2;
1130 int32_T rtb_IQN1xIQN6_m;
1131 int32_T rtb_IQN1xIQN6_i;
1132 int32_T rtb_IQN1xIQN6_c;
1133 int32_T rtb_cosIQN_p;
1134 int32_T rtb_sinIQN1_j;
1135 int32_T rtb_IQN1xIQN1;
1136 int32_T rtb_Sum3_kh;
1137 int32_T rtb_Sum9;
1138 int32_T rtb_Gain6;
1139 int32_T rtb_Sum1;
1140 int32_T rtb_Sum1_d;
1141 int32_T rtb_TmpSignalConversionAtGain1I[3];
1142 int32_T rtb_u_j0;
1143 int32_T rtb_Product7;
1144 int32_T rtb_Product5_p;
1145 int32_T rtb_Product6_n;
1146 int32_T rtb_u_ad;
1147 int32_T rtb_u_p;
1148 int64_T rtb_PhaseC;
1149 int64_T rtb_PhaseB;
1150 int32_T rtb_FloattoIQN_n;
1151 int32_T rtb_IQN1xIQN7;
1152 int32_T rtb_Sum_o;
1153 int32_T rtb_IQN1xIQN2;
1154 int32_T rtb_Sum_e;
1155 int32_T rtb_Gain1_idx_0;
1156 int32_T rtb_Gain1_idx_1;
1157 int32_T rtb_Gain1_d_idx_1;
1158 real32_T tmp;
1159 real_T v;
1160 uint16_T tmp_0;
1161 real_T u_tmp;
1162
1163 /* Saturate: '<Root>/Saturation4' */
1164 if (Inverter_001_B.RateTransition60[0] > Inverter_001_P.Saturation4_UpperSat)
1165 {
1166 rtb_TmpSignalConversionAtGain1I[0] = Inverter_001_P.Saturation4_UpperSat;
1167 } else if (Inverter_001_B.RateTransition60[0] <
1168 Inverter_001_P.Saturation4_LowerSat) {
1169 rtb_TmpSignalConversionAtGain1I[0] = Inverter_001_P.Saturation4_LowerSat;
1170 } else {
1171 rtb_TmpSignalConversionAtGain1I[0] = Inverter_001_B.RateTransition60[0];
1172 }
1173
1174 if (Inverter_001_B.RateTransition60[1] > Inverter_001_P.Saturation4_UpperSat)
1175 {
1176 rtb_TmpSignalConversionAtGain1I[1] = Inverter_001_P.Saturation4_UpperSat;
1177 } else if (Inverter_001_B.RateTransition60[1] <
1178 Inverter_001_P.Saturation4_LowerSat) {
1179 rtb_TmpSignalConversionAtGain1I[1] = Inverter_001_P.Saturation4_LowerSat;
1180 } else {
1181 rtb_TmpSignalConversionAtGain1I[1] = Inverter_001_B.RateTransition60[1];
1182 }
1183
1184 if (Inverter_001_B.RateTransition60[2] > Inverter_001_P.Saturation4_UpperSat)
1185 {
1186 rtb_TmpSignalConversionAtGain1I[2] = Inverter_001_P.Saturation4_UpperSat;
1187 } else if (Inverter_001_B.RateTransition60[2] <
1188 Inverter_001_P.Saturation4_LowerSat) {
1189 rtb_TmpSignalConversionAtGain1I[2] = Inverter_001_P.Saturation4_LowerSat;
1190 } else {
1191 rtb_TmpSignalConversionAtGain1I[2] = Inverter_001_B.RateTransition60[2];
1192 }
1193
1194 /* End of Saturate: '<Root>/Saturation4' */
1195
1196 /* Saturate: '<Root>/Saturation5' incorporates:
1197 * Constant: '<Root>/Constant8'
1198 */
1199 if (Inverter_001_P.Constant8_Value > Inverter_001_P.Saturation5_UpperSat) {
1200 rtb_u_ad = Inverter_001_P.Saturation5_UpperSat;
1201 } else if (Inverter_001_P.Constant8_Value <
1202 Inverter_001_P.Saturation5_LowerSat) {
1203 rtb_u_ad = Inverter_001_P.Saturation5_LowerSat;
1204 } else {
1205 rtb_u_ad = Inverter_001_P.Constant8_Value;
1206 }
1207
1208 /* End of Saturate: '<Root>/Saturation5' */
1209
1210 /* Gain: '<S5>/Gain' */
1211 rtb_Product19 = (real32_T)Inverter_001_P.Gain_Gain * 4.65661287E-10F *
1212 ((real32_T)rtb_u_ad * 0.0009765625F);
1213
1214 /* S-Function (stiiqmath_iq): '<S5>/Float to IQN1' */
1215
1216 /* C28x IQmath Library (stiiqmath_iq) - '<S5>/Float to IQN1' */
1217 {
1218 rtb_u_ad = _IQ10 (rtb_Product19);
1219 }
1220
1221 /* S-Function (stiiqmath_iqdiv): '<S5>/IQN // IQN' */
1222
1223 /* C28x IQmath Library (stiiqmath_iqdiv) - '<S5>/IQN // IQN' */
1224 {
1225 rtb_cosIQN_p = _IQ10div (rtb_TmpSignalConversionAtGain1I[0], rtb_u_ad);
1226 }
1227
1228 /* S-Function (stiiqmath_iqdiv): '<S5>/IQN // IQN1' */
1229
1230 /* C28x IQmath Library (stiiqmath_iqdiv) - '<S5>/IQN // IQN1' */
1231 {
1232 rtb_sinIQN1_j = _IQ10div (rtb_TmpSignalConversionAtGain1I[1], rtb_u_ad);
1233 }
1234
1235 /* S-Function (stiiqmath_iqdiv): '<S5>/IQN // IQN2' */
1236
1237 /* C28x IQmath Library (stiiqmath_iqdiv) - '<S5>/IQN // IQN2' */
1238 {
1239 rtb_u_p = _IQ10div (rtb_TmpSignalConversionAtGain1I[2], rtb_u_ad);
1240 }
1241
1242 /* MinMax: '<S31>/MinMax' */
1243 rtb_u_ad = rtb_cosIQN_p;
1244 if (!(rtb_cosIQN_p < rtb_sinIQN1_j)) {
1245 rtb_u_ad = rtb_sinIQN1_j;
1246 }
1247
1248 if (!(rtb_u_ad < rtb_u_p)) {
1249 rtb_u_ad = rtb_u_p;
1250 }
1251
1252 /* End of MinMax: '<S31>/MinMax' */
1253
1254 /* Gain: '<S31>/Gain' */
1255 rtb_PhaseC = (int64_T)Inverter_001_P.Gain_Gain_j * rtb_u_ad;
1256
1257 /* MinMax: '<S31>/MinMax1' */
1258 rtb_u_ad = rtb_cosIQN_p;
1259 if (!(rtb_cosIQN_p > rtb_sinIQN1_j)) {
1260 rtb_u_ad = rtb_sinIQN1_j;
1261 }
1262
1263 if (!(rtb_u_ad > rtb_u_p)) {
1264 rtb_u_ad = rtb_u_p;
1265 }
1266
1267 /* End of MinMax: '<S31>/MinMax1' */
1268
1269 /* Sum: '<S31>/Sum' incorporates:
1270 * Gain: '<S31>/Gain1'
1271 */
1272 rtb_PhaseC += (int64_T)Inverter_001_P.Gain1_Gain_o * rtb_u_ad;
1273
1274 /* Product: '<S4>/Product19' incorporates:
1275 * Constant: '<S4>/Constant13'
1276 * Constant: '<S4>/Constant14'
1277 * Constant: '<S4>/Constant15'
1278 * Product: '<S4>/Product18'
1279 * Sum: '<S4>/Add14'
1280 */
1281 rtb_Product19 = ((real32_T)rtb_PhaseC * 2.27373675E-13F +
1282 Inverter_001_P.Constant15_Value) *
1283 Inverter_001_P.Constant13_Value * Inverter_001_P.Constant14_Value;
1284
1285 /* Sum: '<S5>/Add17' */
1286 rtb_PhaseB = ((int64_T)rtb_sinIQN1_j << 32U) + rtb_PhaseC;
1287
1288 /* Product: '<S4>/Product15' incorporates:
1289 * Constant: '<S4>/Constant13'
1290 * Constant: '<S4>/Constant14'
1291 * Constant: '<S4>/Constant15'
1292 * Product: '<S4>/Product'
1293 * Sum: '<S4>/Add'
1294 */
1295 rtb_Product15 = ((real32_T)rtb_PhaseB * 2.27373675E-13F +
1296 Inverter_001_P.Constant15_Value) *
1297 Inverter_001_P.Constant13_Value * Inverter_001_P.Constant14_Value;
1298
1299 /* Product: '<S4>/Product17' incorporates:
1300 * Constant: '<S4>/Constant13'
1301 * Constant: '<S4>/Constant14'
1302 * Constant: '<S4>/Constant15'
1303 * Product: '<S4>/Product16'
1304 * Sum: '<S4>/Add13'
1305 * Sum: '<S5>/Add18'
1306 */
1307 rtb_Product17 = ((real32_T)(((int64_T)rtb_u_p << 32U) + rtb_PhaseC) *
1308 2.27373675E-13F + Inverter_001_P.Constant15_Value) *
1309 Inverter_001_P.Constant13_Value * Inverter_001_P.Constant14_Value;
1310
1311 /* Product: '<S4>/Product21' incorporates:
1312 * Constant: '<S4>/Constant13'
1313 * Constant: '<S4>/Constant14'
1314 * Constant: '<S4>/Constant15'
1315 * Product: '<S4>/Product20'
1316 * Sum: '<S4>/Add15'
1317 * Sum: '<S5>/Add16'
1318 */
1319 rtb_Product21 = ((real32_T)(((int64_T)rtb_cosIQN_p << 32U) + rtb_PhaseC) *
1320 2.27373675E-13F + Inverter_001_P.Constant15_Value) *
1321 Inverter_001_P.Constant13_Value * Inverter_001_P.Constant14_Value;
1322
1323 /* S-Function (c2802xpwm): '<S4>/ePWM' incorporates:
1324 * Constant: '<Root>/Constant2'
1325 */
1326
1327 /*-- Update CMPA value for ePWM5 --*/
1328 {
1329 EPwm5Regs.CMPA.bit.CMPA = (uint16_T)(rtb_Product21);
1330 }
1331
1332 /*-- Update CMPB value for ePWM5 --*/
1333 {
1334 EPwm5Regs.CMPB.bit.CMPB = (uint16_T)(rtb_Product21);
1335 }
1336
1337 EPwm5Regs.DBRED.bit.DBRED = Inverter_001_P.Constant2_Value_p;
1338 EPwm5Regs.DBFED.bit.DBFED = Inverter_001_P.Constant2_Value_p;
1339
1340 /* S-Function (c2802xpwm): '<S4>/ePWM1' incorporates:
1341 * Constant: '<Root>/Constant2'
1342 */
1343
1344 /*-- Update CMPA value for ePWM3 --*/
1345 {
1346 EPwm3Regs.CMPA.bit.CMPA = (uint16_T)(rtb_Product17);
1347 }
1348
1349 /*-- Update CMPB value for ePWM3 --*/
1350 {
1351 EPwm3Regs.CMPB.bit.CMPB = (uint16_T)(rtb_Product17);
1352 }
1353
1354 EPwm3Regs.DBRED.bit.DBRED = Inverter_001_P.Constant2_Value_p;
1355 EPwm3Regs.DBFED.bit.DBFED = Inverter_001_P.Constant2_Value_p;
1356
1357 /* S-Function (c2802xpwm): '<S4>/ePWM2' incorporates:
1358 * Constant: '<Root>/Constant2'
1359 */
1360
1361 /*-- Update CMPA value for ePWM6 --*/
1362 {
1363 EPwm6Regs.CMPA.bit.CMPA = (uint16_T)(rtb_Product15);
1364 }
1365
1366 /*-- Update CMPB value for ePWM6 --*/
1367 {
1368 EPwm6Regs.CMPB.bit.CMPB = (uint16_T)(rtb_Product15);
1369 }
1370
1371 EPwm6Regs.DBRED.bit.DBRED = Inverter_001_P.Constant2_Value_p;
1372 EPwm6Regs.DBFED.bit.DBFED = Inverter_001_P.Constant2_Value_p;
1373
1374 /* S-Function (c2802xpwm): '<S4>/ePWM3' incorporates:
1375 * Constant: '<Root>/Constant2'
1376 */
1377
1378 /*-- Update CMPA value for ePWM4 --*/
1379 {
1380 EPwm4Regs.CMPA.bit.CMPA = (uint16_T)(rtb_Product19);
1381 }
1382
1383 /*-- Update CMPB value for ePWM4 --*/
1384 {
1385 EPwm4Regs.CMPB.bit.CMPB = (uint16_T)(rtb_Product19);
1386 }
1387
1388 EPwm4Regs.DBRED.bit.DBRED = Inverter_001_P.Constant2_Value_p;
1389 EPwm4Regs.DBFED.bit.DBFED = Inverter_001_P.Constant2_Value_p;
1390
1391 /* S-Function (scheckfractionlength): '<S18>/ ' */
1392 rtb_u_p = Inverter_001_B.RateTransition20[0];
1393
1394 /* S-Function (scheckfractionlength): '<S18>/ 2' */
1395 rtb_sinIQN1_j = Inverter_001_B.RateTransition61;
1396
1397 /* S-Function (stiiqmath_iqtrig): '<S18>/cos IQN' */
1398
1399 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S18>/cos IQN' */
1400 {
1401 rtb_cosIQN_p = _IQ10cos(rtb_sinIQN1_j);
1402 }
1403
1404 /* S-Function (scheckfractionlength): '<S18>/ 1' */
1405 rtb_u_ad = Inverter_001_B.RateTransition20[1];
1406
1407 /* S-Function (stiiqmath_iq): '<S18>/Float to IQN' incorporates:
1408 * Constant: '<S18>/Constant'
1409 */
1410
1411 /* C28x IQmath Library (stiiqmath_iq) - '<S18>/Float to IQN' */
1412 {
1413 rtb_Product6_n = _IQ10 (Inverter_001_P.Constant_Value_h);
1414 }
1415
1416 /* Sum: '<S18>/Sum' */
1417 rtb_Sum_e = rtb_sinIQN1_j + rtb_Product6_n;
1418
1419 /* Sum: '<S18>/Sum3' */
1420 rtb_Product7 = rtb_sinIQN1_j - rtb_Product6_n;
1421
1422 /* S-Function (stiiqmath_iqtrig): '<S18>/cos IQN1' */
1423
1424 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S18>/cos IQN1' */
1425 {
1426 rtb_Product6_n = _IQ10cos(rtb_Product7);
1427 }
1428
1429 /* S-Function (scheckfractionlength): '<S18>/ 3' */
1430 rtb_u_j0 = Inverter_001_B.RateTransition20[2];
1431
1432 /* S-Function (stiiqmath_iqtrig): '<S18>/cos IQN2' */
1433
1434 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S18>/cos IQN2' */
1435 {
1436 rtb_Product5_p = _IQ10cos(rtb_Sum_e);
1437 }
1438
1439 /* S-Function (stiiqmath_iqtrig): '<S18>/sin IQN' */
1440
1441 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S18>/sin IQN' */
1442 {
1443 rtb_Sum1_d = _IQ10sin(rtb_sinIQN1_j);
1444 }
1445
1446 /* S-Function (stiiqmath_iqtrig): '<S18>/sin IQN1' */
1447
1448 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S18>/sin IQN1' */
1449 {
1450 rtb_sinIQN1_j = _IQ10sin(rtb_Product7);
1451 }
1452
1453 /* S-Function (stiiqmath_iqtrig): '<S18>/sin IQN2' */
1454
1455 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S18>/sin IQN2' */
1456 {
1457 rtb_Product7 = _IQ10sin(rtb_Sum_e);
1458 }
1459
1460 /* S-Function (scheckfractionlength): '<S19>/ ' */
1461 rtb_Sum_e = Inverter_001_B.RateTransition21[0];
1462
1463 /* S-Function (scheckfractionlength): '<S19>/ 2' */
1464 rtb_Sum1 = Inverter_001_B.RateTransition61;
1465
1466 /* S-Function (stiiqmath_iqtrig): '<S19>/cos IQN' */
1467
1468 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S19>/cos IQN' */
1469 {
1470 rtb_Gain6 = _IQ10cos(rtb_Sum1);
1471 }
1472
1473 /* Product: '<S19>/Product2' */
1474 rtb_IQN1xIQN2 = __IQmpy(rtb_Sum_e, rtb_Gain6, 10);
1475
1476 /* S-Function (scheckfractionlength): '<S19>/ 1' */
1477 rtb_Gain6 = Inverter_001_B.RateTransition21[1];
1478
1479 /* S-Function (stiiqmath_iq): '<S19>/Float to IQN' incorporates:
1480 * Constant: '<S19>/Constant'
1481 */
1482
1483 /* C28x IQmath Library (stiiqmath_iq) - '<S19>/Float to IQN' */
1484 {
1485 rtb_IQN1xIQN1 = _IQ10 (Inverter_001_P.Constant_Value_b);
1486 }
1487
1488 /* Sum: '<S19>/Sum3' */
1489 rtb_Sum9 = rtb_Sum1 - rtb_IQN1xIQN1;
1490
1491 /* S-Function (stiiqmath_iqtrig): '<S19>/cos IQN1' */
1492
1493 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S19>/cos IQN1' */
1494 {
1495 rtb_Sum3_kh = _IQ10cos(rtb_Sum9);
1496 }
1497
1498 /* Product: '<S19>/Product4' */
1499 rtb_Sum_o = __IQmpy(rtb_Gain6, rtb_Sum3_kh, 10);
1500
1501 /* S-Function (scheckfractionlength): '<S19>/ 3' */
1502 rtb_Sum3_kh = Inverter_001_B.RateTransition21[2];
1503
1504 /* Sum: '<S19>/Sum' */
1505 rtb_FloattoIQN_n = rtb_Sum1 + rtb_IQN1xIQN1;
1506
1507 /* S-Function (stiiqmath_iqtrig): '<S19>/cos IQN2' */
1508
1509 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S19>/cos IQN2' */
1510 {
1511 rtb_IQN1xIQN1 = _IQ10cos(rtb_FloattoIQN_n);
1512 }
1513
1514 /* Product: '<S19>/Product6' */
1515 rtb_IQN1xIQN7 = __IQmpy(rtb_Sum3_kh, rtb_IQN1xIQN1, 10);
1516
1517 /* Sum: '<S19>/Sum1' */
1518 rtb_IQN1xIQN1 = (rtb_IQN1xIQN2 + rtb_Sum_o) + rtb_IQN1xIQN7;
1519
1520 /* S-Function (stiiqmath_iqtrig): '<S19>/sin IQN' */
1521
1522 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S19>/sin IQN' */
1523 {
1524 rtb_IQN1xIQN7 = _IQ10sin(rtb_Sum1);
1525 }
1526
1527 /* Product: '<S19>/Product3' */
1528 rtb_Sum_o = __IQmpy(rtb_Sum_e, rtb_IQN1xIQN7, 10);
1529
1530 /* S-Function (stiiqmath_iqtrig): '<S19>/sin IQN1' */
1531
1532 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S19>/sin IQN1' */
1533 {
1534 rtb_IQN1xIQN7 = _IQ10sin(rtb_Sum9);
1535 }
1536
1537 /* Product: '<S19>/Product5' */
1538 rtb_Sum9 = __IQmpy(rtb_Gain6, rtb_IQN1xIQN7, 10);
1539
1540 /* S-Function (stiiqmath_iqtrig): '<S19>/sin IQN2' */
1541
1542 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S19>/sin IQN2' */
1543 {
1544 rtb_IQN1xIQN7 = _IQ10sin(rtb_FloattoIQN_n);
1545 }
1546
1547 /* Product: '<S19>/Product7' */
1548 rtb_FloattoIQN_n = __IQmpy(rtb_Sum3_kh, rtb_IQN1xIQN7, 10);
1549
1550 /* SignalConversion: '<S19>/TmpSignal ConversionAtGain1Inport1' incorporates:
1551 * Sum: '<S19>/Sum4'
1552 */
1553 rtb_TmpSignalConversionAtGain1I[1] = (-rtb_Sum_o - rtb_Sum9) -
1554 rtb_FloattoIQN_n;
1555
1556 /* Sum: '<S19>/Sum5' */
1557 rtb_FloattoIQN_n = (rtb_Sum_e + rtb_Gain6) + rtb_Sum3_kh;
1558
1559 /* SignalConversion: '<S19>/TmpSignal ConversionAtGain1Inport1' incorporates:
1560 * Gain: '<S19>/Gain'
1561 */
1562 rtb_TmpSignalConversionAtGain1I[2] = __IQxmpy(Inverter_001_P.Gain_Gain_g,
1563 rtb_FloattoIQN_n, 1);
1564 rtb_TmpSignalConversionAtGain1I[0] = rtb_IQN1xIQN1;
1565
1566 /* Gain: '<S19>/Gain1' */
1567 rtb_Gain1_idx_0 = __IQxmpy(Inverter_001_P.Gain1_Gain,
1568 rtb_TmpSignalConversionAtGain1I[0], 1);
1569 rtb_Gain1_idx_1 = __IQxmpy(Inverter_001_P.Gain1_Gain,
1570 rtb_TmpSignalConversionAtGain1I[1], 1);
1571
1572 /* Sum: '<S30>/Sum' incorporates:
1573 * Gain: '<S19>/Gain1'
1574 */
1575 rtb_IQN1xIQN7 = Inverter_001_B.RateTransition62[2] - __IQxmpy
1576 (Inverter_001_P.Gain1_Gain, rtb_TmpSignalConversionAtGain1I[2], 1);
1577
1578 /* Sum: '<S30>/Sum11' incorporates:
1579 * UnitDelay: '<S30>/Unit Delay3'
1580 */
1581 rtb_FloattoIQN_n = rtb_IQN1xIQN7 - Inverter_001_DW.UnitDelay3_DSTATE;
1582
1583 /* Gain: '<S30>/Gain' incorporates:
1584 * Gain: '<S24>/Gain'
1585 * Gain: '<S24>/Gain1'
1586 * Gain: '<S25>/Gain'
1587 * Gain: '<S25>/Gain1'
1588 * Gain: '<S26>/Gain'
1589 * Gain: '<S26>/Gain1'
1590 * Gain: '<S28>/Gain'
1591 * Gain: '<S28>/Gain1'
1592 * Gain: '<S29>/Gain'
1593 * Gain: '<S29>/Gain1'
1594 * Gain: '<S30>/Gain1'
1595 */
1596 u_tmp = Inverter_001_P.Control.Ts * 4.398046511104E+12;
1597 v = fabs(u_tmp);
1598 if (v < 4.503599627370496E+15) {
1599 if (v >= 0.5) {
1600 v = floor(u_tmp + 0.5);
1601 } else {
1602 v = u_tmp * 0.0;
1603 }
1604 } else {
1605 v = u_tmp;
1606 }
1607
1608 if (v < 2.147483648E+9) {
1609 if (v >= -2.147483648E+9) {
1610 rtb_Sum_e = (int32_T)v;
1611 } else {
1612 rtb_Sum_e = MIN_int32_T;
1613 }
1614 } else {
1615 rtb_Sum_e = MAX_int32_T;
1616 }
1617
1618 rtb_Sum_o = __IQxmpy(rtb_Sum_e, rtb_FloattoIQN_n, -10);
1619
1620 /* End of Gain: '<S30>/Gain' */
1621
1622 /* Sum: '<S30>/Sum5' incorporates:
1623 * UnitDelay: '<S30>/Unit Delay2'
1624 */
1625 Inverter_001_DW.UnitDelay2_DSTATE += rtb_Sum_o;
1626
1627 /* Gain: '<S30>/Gain1' */
1628 v = fabs(u_tmp);
1629 if (v < 4.503599627370496E+15) {
1630 if (v >= 0.5) {
1631 v = floor(u_tmp + 0.5);
1632 } else {
1633 v = u_tmp * 0.0;
1634 }
1635 } else {
1636 v = u_tmp;
1637 }
1638
1639 if (v < 2.147483648E+9) {
1640 if (v >= -2.147483648E+9) {
1641 rtb_Sum_e = (int32_T)v;
1642 } else {
1643 rtb_Sum_e = MIN_int32_T;
1644 }
1645 } else {
1646 rtb_Sum_e = MAX_int32_T;
1647 }
1648
1649 rtb_FloattoIQN_n = __IQxmpy(rtb_Sum_e, Inverter_001_DW.UnitDelay2_DSTATE, -10);
1650
1651 /* Sum: '<S30>/Sum4' incorporates:
1652 * UnitDelay: '<S30>/Unit Delay1'
1653 */
1654 Inverter_001_DW.UnitDelay1_DSTATE_b += rtb_FloattoIQN_n;
1655
1656 /* Sum: '<S29>/Sum' */
1657 rtb_FloattoIQN_n = Inverter_001_B.RateTransition62[0] - rtb_Gain1_idx_0;
1658
1659 /* Sum: '<S29>/Sum11' incorporates:
1660 * UnitDelay: '<S29>/Unit Delay3'
1661 */
1662 rtb_Sum_o = rtb_FloattoIQN_n - Inverter_001_DW.UnitDelay3_DSTATE_c;
1663
1664 /* Gain: '<S29>/Gain' */
1665 v = fabs(u_tmp);
1666 if (v < 4.503599627370496E+15) {
1667 if (v >= 0.5) {
1668 v = floor(u_tmp + 0.5);
1669 } else {
1670 v = u_tmp * 0.0;
1671 }
1672 } else {
1673 v = u_tmp;
1674 }
1675
1676 if (v < 2.147483648E+9) {
1677 if (v >= -2.147483648E+9) {
1678 rtb_Sum_e = (int32_T)v;
1679 } else {
1680 rtb_Sum_e = MIN_int32_T;
1681 }
1682 } else {
1683 rtb_Sum_e = MAX_int32_T;
1684 }
1685
1686 rtb_Sum3_kh = __IQxmpy(rtb_Sum_e, rtb_Sum_o, -10);
1687
1688 /* Sum: '<S29>/Sum5' incorporates:
1689 * UnitDelay: '<S29>/Unit Delay2'
1690 */
1691 Inverter_001_DW.UnitDelay2_DSTATE_h += rtb_Sum3_kh;
1692
1693 /* Gain: '<S29>/Gain1' */
1694 v = fabs(u_tmp);
1695 if (v < 4.503599627370496E+15) {
1696 if (v >= 0.5) {
1697 v = floor(u_tmp + 0.5);
1698 } else {
1699 v = u_tmp * 0.0;
1700 }
1701 } else {
1702 v = u_tmp;
1703 }
1704
1705 if (v < 2.147483648E+9) {
1706 if (v >= -2.147483648E+9) {
1707 rtb_Sum_e = (int32_T)v;
1708 } else {
1709 rtb_Sum_e = MIN_int32_T;
1710 }
1711 } else {
1712 rtb_Sum_e = MAX_int32_T;
1713 }
1714
1715 rtb_Sum_o = __IQxmpy(rtb_Sum_e, Inverter_001_DW.UnitDelay2_DSTATE_h, -10);
1716
1717 /* Sum: '<S29>/Sum4' incorporates:
1718 * UnitDelay: '<S29>/Unit Delay1'
1719 */
1720 Inverter_001_DW.UnitDelay1_DSTATE_d += rtb_Sum_o;
1721
1722 /* Sum: '<S28>/Sum' */
1723 rtb_Sum_o = Inverter_001_B.RateTransition62[1] - rtb_Gain1_idx_1;
1724
1725 /* Sum: '<S28>/Sum11' incorporates:
1726 * UnitDelay: '<S28>/Unit Delay3'
1727 */
1728 rtb_Sum3_kh = rtb_Sum_o - Inverter_001_DW.UnitDelay3_DSTATE_m;
1729
1730 /* Gain: '<S28>/Gain' */
1731 v = fabs(u_tmp);
1732 if (v < 4.503599627370496E+15) {
1733 if (v >= 0.5) {
1734 v = floor(u_tmp + 0.5);
1735 } else {
1736 v = u_tmp * 0.0;
1737 }
1738 } else {
1739 v = u_tmp;
1740 }
1741
1742 if (v < 2.147483648E+9) {
1743 if (v >= -2.147483648E+9) {
1744 rtb_Sum_e = (int32_T)v;
1745 } else {
1746 rtb_Sum_e = MIN_int32_T;
1747 }
1748 } else {
1749 rtb_Sum_e = MAX_int32_T;
1750 }
1751
1752 rtb_Sum9 = __IQxmpy(rtb_Sum_e, rtb_Sum3_kh, -10);
1753
1754 /* Sum: '<S28>/Sum5' incorporates:
1755 * UnitDelay: '<S28>/Unit Delay2'
1756 */
1757 Inverter_001_DW.UnitDelay2_DSTATE_g += rtb_Sum9;
1758
1759 /* Gain: '<S28>/Gain1' */
1760 v = fabs(u_tmp);
1761 if (v < 4.503599627370496E+15) {
1762 if (v >= 0.5) {
1763 v = floor(u_tmp + 0.5);
1764 } else {
1765 v = u_tmp * 0.0;
1766 }
1767 } else {
1768 v = u_tmp;
1769 }
1770
1771 if (v < 2.147483648E+9) {
1772 if (v >= -2.147483648E+9) {
1773 rtb_Sum_e = (int32_T)v;
1774 } else {
1775 rtb_Sum_e = MIN_int32_T;
1776 }
1777 } else {
1778 rtb_Sum_e = MAX_int32_T;
1779 }
1780
1781 rtb_Sum3_kh = __IQxmpy(rtb_Sum_e, Inverter_001_DW.UnitDelay2_DSTATE_g, -10);
1782
1783 /* Sum: '<S28>/Sum4' incorporates:
1784 * UnitDelay: '<S28>/Unit Delay1'
1785 */
1786 Inverter_001_DW.UnitDelay1_DSTATE_hyo += rtb_Sum3_kh;
1787
1788 /* Product: '<S18>/Product2' */
1789 rtb_Sum3_kh = __IQmpy(rtb_u_p, rtb_cosIQN_p, 10);
1790
1791 /* Product: '<S18>/Product4' */
1792 rtb_Sum9 = __IQmpy(rtb_u_ad, rtb_Product6_n, 10);
1793
1794 /* Product: '<S18>/Product6' */
1795 rtb_IQN1xIQN1 = __IQmpy(rtb_u_j0, rtb_Product5_p, 10);
1796
1797 /* SignalConversion: '<S18>/TmpSignal ConversionAtGain1Inport1' incorporates:
1798 * Sum: '<S18>/Sum1'
1799 */
1800 rtb_TmpSignalConversionAtGain1I[0] = (rtb_Sum3_kh + rtb_Sum9) + rtb_IQN1xIQN1;
1801
1802 /* Product: '<S18>/Product3' */
1803 rtb_Sum3_kh = __IQmpy(rtb_u_p, rtb_Sum1_d, 10);
1804
1805 /* Product: '<S18>/Product5' */
1806 rtb_Sum9 = __IQmpy(rtb_u_ad, rtb_sinIQN1_j, 10);
1807
1808 /* Product: '<S18>/Product7' */
1809 rtb_IQN1xIQN1 = __IQmpy(rtb_u_j0, rtb_Product7, 10);
1810
1811 /* Sum: '<S18>/Sum4' */
1812 rtb_Gain6 = (-rtb_Sum3_kh - rtb_Sum9) - rtb_IQN1xIQN1;
1813
1814 /* Sum: '<S18>/Sum5' */
1815 rtb_Sum3_kh = (rtb_u_p + rtb_u_ad) + rtb_u_j0;
1816
1817 /* Gain: '<S18>/Gain' */
1818 rtb_Sum9 = __IQxmpy(Inverter_001_P.Gain_Gain_b, rtb_Sum3_kh, 1);
1819
1820 /* SignalConversion: '<S18>/TmpSignal ConversionAtGain1Inport1' */
1821 rtb_TmpSignalConversionAtGain1I[1] = rtb_Gain6;
1822 rtb_TmpSignalConversionAtGain1I[2] = rtb_Sum9;
1823
1824 /* Gain: '<S18>/Gain1' */
1825 rtb_u_ad = __IQxmpy(Inverter_001_P.Gain1_Gain_g,
1826 rtb_TmpSignalConversionAtGain1I[0], 1);
1827 rtb_Gain1_d_idx_1 = __IQxmpy(Inverter_001_P.Gain1_Gain_g,
1828 rtb_TmpSignalConversionAtGain1I[1], 1);
1829 rtb_u_p = __IQxmpy(Inverter_001_P.Gain1_Gain_g,
1830 rtb_TmpSignalConversionAtGain1I[2], 1);
1831
1832 /* S-Function (stiiqmath_iqmpyiqx): '<S28>/IQN1 x IQN1' incorporates:
1833 * Constant: '<S23>/Kr3'
1834 */
1835
1836 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S28>/IQN1 x IQN1' */
1837 {
1838 rtb_Sum3_kh = _IQ10mpyIQX (Inverter_001_DW.UnitDelay2_DSTATE_g, 10,
1839 Inverter_001_P.VC_Tcr, 10);
1840 }
1841
1842 /* S-Function (stiiqmath_iqmpyiqx): '<S28>/IQN1 x IQN2' incorporates:
1843 * Constant: '<S23>/Kp4'
1844 */
1845
1846 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S28>/IQN1 x IQN2' */
1847 {
1848 rtb_Sum9 = _IQ10mpyIQX (rtb_Sum_o, 10, Inverter_001_P.Kvp, 10);
1849 }
1850
1851 /* Sum: '<S28>/Sum3' incorporates:
1852 * UnitDelay: '<S28>/Unit Delay'
1853 */
1854 Inverter_001_DW.UnitDelay_DSTATE_lt += rtb_Sum_o;
1855
1856 /* S-Function (stiiqmath_iqmpyiqx): '<S28>/IQN1 x IQN3' incorporates:
1857 * Constant: '<S23>/Ki3'
1858 */
1859
1860 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S28>/IQN1 x IQN3' */
1861 {
1862 rtb_Sum_o = _IQ10mpyIQX (Inverter_001_DW.UnitDelay_DSTATE_lt, 10,
1863 Inverter_001_P.VC_Tci, 10);
1864 }
1865
1866 /* S-Function (scheckfractionlength): '<S20>/ ' */
1867 rtb_IQN1xIQN1 = Inverter_001_B.RateTransition19[0];
1868
1869 /* S-Function (scheckfractionlength): '<S20>/ 2' */
1870 rtb_IQN1xIQN2 = Inverter_001_B.RateTransition61;
1871
1872 /* S-Function (stiiqmath_iqtrig): '<S20>/cos IQN' */
1873
1874 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S20>/cos IQN' */
1875 {
1876 rtb_Gain6 = _IQ10cos(rtb_IQN1xIQN2);
1877 }
1878
1879 /* Product: '<S20>/Product2' */
1880 rtb_Sum1 = __IQmpy(rtb_IQN1xIQN1, rtb_Gain6, 10);
1881
1882 /* S-Function (scheckfractionlength): '<S20>/ 1' */
1883 rtb_Gain6 = Inverter_001_B.RateTransition19[1];
1884
1885 /* S-Function (stiiqmath_iq): '<S20>/Float to IQN' incorporates:
1886 * Constant: '<S20>/Constant'
1887 */
1888
1889 /* C28x IQmath Library (stiiqmath_iq) - '<S20>/Float to IQN' */
1890 {
1891 rtb_Sum1_d = _IQ10 (Inverter_001_P.Constant_Value_m);
1892 }
1893
1894 /* Sum: '<S20>/Sum3' */
1895 rtb_Product5_p = rtb_IQN1xIQN2 - rtb_Sum1_d;
1896
1897 /* S-Function (stiiqmath_iqtrig): '<S20>/cos IQN1' */
1898
1899 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S20>/cos IQN1' */
1900 {
1901 rtb_u_j0 = _IQ10cos(rtb_Product5_p);
1902 }
1903
1904 /* Product: '<S20>/Product4' */
1905 rtb_Product7 = __IQmpy(rtb_Gain6, rtb_u_j0, 10);
1906
1907 /* S-Function (scheckfractionlength): '<S20>/ 3' */
1908 rtb_u_j0 = Inverter_001_B.RateTransition19[2];
1909
1910 /* Sum: '<S20>/Sum' */
1911 rtb_Sum_e = rtb_IQN1xIQN2 + rtb_Sum1_d;
1912
1913 /* S-Function (stiiqmath_iqtrig): '<S20>/cos IQN2' */
1914
1915 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S20>/cos IQN2' */
1916 {
1917 rtb_Sum1_d = _IQ10cos(rtb_Sum_e);
1918 }
1919
1920 /* Product: '<S20>/Product6' */
1921 rtb_Product6_n = __IQmpy(rtb_u_j0, rtb_Sum1_d, 10);
1922
1923 /* SignalConversion: '<S20>/TmpSignal ConversionAtGain1Inport1' incorporates:
1924 * Sum: '<S20>/Sum1'
1925 */
1926 rtb_TmpSignalConversionAtGain1I[0] = (rtb_Sum1 + rtb_Product7) +
1927 rtb_Product6_n;
1928
1929 /* S-Function (stiiqmath_iqtrig): '<S20>/sin IQN' */
1930
1931 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S20>/sin IQN' */
1932 {
1933 rtb_Sum1 = _IQ10sin(rtb_IQN1xIQN2);
1934 }
1935
1936 /* Product: '<S20>/Product3' */
1937 rtb_IQN1xIQN2 = __IQmpy(rtb_IQN1xIQN1, rtb_Sum1, 10);
1938
1939 /* S-Function (stiiqmath_iqtrig): '<S20>/sin IQN1' */
1940
1941 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S20>/sin IQN1' */
1942 {
1943 rtb_Sum1 = _IQ10sin(rtb_Product5_p);
1944 }
1945
1946 /* Product: '<S20>/Product5' */
1947 rtb_Product5_p = __IQmpy(rtb_Gain6, rtb_Sum1, 10);
1948
1949 /* S-Function (stiiqmath_iqtrig): '<S20>/sin IQN2' */
1950
1951 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S20>/sin IQN2' */
1952 {
1953 rtb_Sum1 = _IQ10sin(rtb_Sum_e);
1954 }
1955
1956 /* Product: '<S20>/Product7' */
1957 rtb_Product7 = __IQmpy(rtb_u_j0, rtb_Sum1, 10);
1958
1959 /* Sum: '<S20>/Sum4' */
1960 rtb_Sum1 = (-rtb_IQN1xIQN2 - rtb_Product5_p) - rtb_Product7;
1961
1962 /* Sum: '<S20>/Sum5' */
1963 rtb_IQN1xIQN2 = (rtb_IQN1xIQN1 + rtb_Gain6) + rtb_u_j0;
1964
1965 /* Gain: '<S20>/Gain' */
1966 rtb_IQN1xIQN1 = __IQxmpy(Inverter_001_P.Gain_Gain_n, rtb_IQN1xIQN2, 1);
1967
1968 /* SignalConversion: '<S20>/TmpSignal ConversionAtGain1Inport1' */
1969 rtb_TmpSignalConversionAtGain1I[1] = rtb_Sum1;
1970 rtb_TmpSignalConversionAtGain1I[2] = rtb_IQN1xIQN1;
1971
1972 /* Gain: '<S20>/Gain1' */
1973 rtb_TmpSignalConversionAtGain1I[0] = __IQxmpy(Inverter_001_P.Gain1_Gain_f,
1974 rtb_TmpSignalConversionAtGain1I[0], 1);
1975 rtb_TmpSignalConversionAtGain1I[1] = __IQxmpy(Inverter_001_P.Gain1_Gain_f,
1976 rtb_TmpSignalConversionAtGain1I[1], 1);
1977 rtb_TmpSignalConversionAtGain1I[2] = __IQxmpy(Inverter_001_P.Gain1_Gain_f,
1978 rtb_TmpSignalConversionAtGain1I[2], 1);
1979
1980 /* Sum: '<S28>/Sum1' */
1981 rtb_IQN1xIQN1 = (rtb_Sum3_kh + rtb_Sum9) + rtb_Sum_o;
1982
1983 /* Sum: '<S23>/Sum13' */
1984 rtb_Sum_o = rtb_IQN1xIQN1 + rtb_TmpSignalConversionAtGain1I[1];
1985
1986 /* Gain: '<S23>/Gain12' */
1987 rtb_Sum3_kh = __IQxmpy(Inverter_001_P.Gain12_Gain, rtb_Gain1_idx_0, -10);
1988
1989 /* Sum: '<S23>/Sum4' */
1990 rtb_Sum9 = rtb_Sum_o + rtb_Sum3_kh;
1991
1992 /* Sum: '<S24>/Sum' */
1993 rtb_Sum_o = rtb_Sum9 - rtb_Gain1_d_idx_1;
1994
1995 /* Sum: '<S24>/Sum11' incorporates:
1996 * UnitDelay: '<S24>/Unit Delay3'
1997 */
1998 rtb_Sum3_kh = rtb_Sum_o - Inverter_001_DW.UnitDelay3_DSTATE_o;
1999
2000 /* Gain: '<S24>/Gain' */
2001 v = fabs(u_tmp);
2002 if (v < 4.503599627370496E+15) {
2003 if (v >= 0.5) {
2004 v = floor(u_tmp + 0.5);
2005 } else {
2006 v = u_tmp * 0.0;
2007 }
2008 } else {
2009 v = u_tmp;
2010 }
2011
2012 if (v < 2.147483648E+9) {
2013 if (v >= -2.147483648E+9) {
2014 rtb_Sum_e = (int32_T)v;
2015 } else {
2016 rtb_Sum_e = MIN_int32_T;
2017 }
2018 } else {
2019 rtb_Sum_e = MAX_int32_T;
2020 }
2021
2022 rtb_Sum9 = __IQxmpy(rtb_Sum_e, rtb_Sum3_kh, -10);
2023
2024 /* Sum: '<S24>/Sum5' incorporates:
2025 * UnitDelay: '<S24>/Unit Delay2'
2026 */
2027 Inverter_001_DW.UnitDelay2_DSTATE_gq += rtb_Sum9;
2028
2029 /* Gain: '<S24>/Gain1' */
2030 v = fabs(u_tmp);
2031 if (v < 4.503599627370496E+15) {
2032 if (v >= 0.5) {
2033 v = floor(u_tmp + 0.5);
2034 } else {
2035 v = u_tmp * 0.0;
2036 }
2037 } else {
2038 v = u_tmp;
2039 }
2040
2041 if (v < 2.147483648E+9) {
2042 if (v >= -2.147483648E+9) {
2043 rtb_Sum_e = (int32_T)v;
2044 } else {
2045 rtb_Sum_e = MIN_int32_T;
2046 }
2047 } else {
2048 rtb_Sum_e = MAX_int32_T;
2049 }
2050
2051 rtb_Sum3_kh = __IQxmpy(rtb_Sum_e, Inverter_001_DW.UnitDelay2_DSTATE_gq, -10);
2052
2053 /* Sum: '<S24>/Sum4' incorporates:
2054 * UnitDelay: '<S24>/Unit Delay1'
2055 */
2056 Inverter_001_DW.UnitDelay1_DSTATE_c += rtb_Sum3_kh;
2057
2058 /* S-Function (stiiqmath_iqmpyiqx): '<S24>/IQN1 x IQN1' incorporates:
2059 * Constant: '<S16>/Kr2'
2060 */
2061
2062 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S24>/IQN1 x IQN1' */
2063 {
2064 rtb_Sum3_kh = _IQ10mpyIQX (Inverter_001_DW.UnitDelay2_DSTATE_gq, 10,
2065 Inverter_001_P.CC_Tcr, 10);
2066 }
2067
2068 /* S-Function (stiiqmath_iqmpyiqx): '<S24>/IQN1 x IQN2' incorporates:
2069 * Constant: '<S16>/Kp2'
2070 */
2071
2072 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S24>/IQN1 x IQN2' */
2073 {
2074 rtb_Sum9 = _IQ10mpyIQX (rtb_Sum_o, 10, Inverter_001_P.Kcp, 10);
2075 }
2076
2077 /* Sum: '<S24>/Sum3' incorporates:
2078 * UnitDelay: '<S24>/Unit Delay'
2079 */
2080 Inverter_001_DW.UnitDelay_DSTATE_a += rtb_Sum_o;
2081
2082 /* S-Function (stiiqmath_iqmpyiqx): '<S24>/IQN1 x IQN3' incorporates:
2083 * Constant: '<S16>/Ki2'
2084 */
2085
2086 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S24>/IQN1 x IQN3' */
2087 {
2088 rtb_Sum_o = _IQ10mpyIQX (Inverter_001_DW.UnitDelay_DSTATE_a, 10,
2089 Inverter_001_P.CC_Tci, 10);
2090 }
2091
2092 /* S-Function (stiiqmath_iqmpyiqx): '<S24>/IQN1 x IQN7' incorporates:
2093 * Constant: '<S16>/w2'
2094 */
2095
2096 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S24>/IQN1 x IQN7' */
2097 {
2098 rtb_IQN1xIQN1 = _IQ10mpyIQX (Inverter_001_P.w2_Value, 10,
2099 Inverter_001_P.w2_Value, 10);
2100 }
2101
2102 /* S-Function (stiiqmath_iqmpyiqx): '<S24>/IQN1 x IQN6' */
2103
2104 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S24>/IQN1 x IQN6' */
2105 {
2106 rtb_IQN1xIQN6 = _IQ10mpyIQX (Inverter_001_DW.UnitDelay1_DSTATE_c, 10,
2107 rtb_IQN1xIQN1, 10);
2108 }
2109
2110 /* S-Function (stiiqmath_iqmpyiqx): '<S29>/IQN1 x IQN1' incorporates:
2111 * Constant: '<S23>/Kr3'
2112 */
2113
2114 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S29>/IQN1 x IQN1' */
2115 {
2116 rtb_IQN1xIQN1 = _IQ10mpyIQX (Inverter_001_DW.UnitDelay2_DSTATE_h, 10,
2117 Inverter_001_P.VC_Tcr, 10);
2118 }
2119
2120 /* S-Function (stiiqmath_iqmpyiqx): '<S29>/IQN1 x IQN2' incorporates:
2121 * Constant: '<S23>/Kp4'
2122 */
2123
2124 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S29>/IQN1 x IQN2' */
2125 {
2126 rtb_IQN1xIQN2 = _IQ10mpyIQX (rtb_FloattoIQN_n, 10, Inverter_001_P.Kvp, 10);
2127 }
2128
2129 /* Sum: '<S29>/Sum3' incorporates:
2130 * UnitDelay: '<S29>/Unit Delay'
2131 */
2132 Inverter_001_DW.UnitDelay_DSTATE_o += rtb_FloattoIQN_n;
2133
2134 /* S-Function (stiiqmath_iqmpyiqx): '<S29>/IQN1 x IQN3' incorporates:
2135 * Constant: '<S23>/Ki3'
2136 */
2137
2138 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S29>/IQN1 x IQN3' */
2139 {
2140 rtb_FloattoIQN_n = _IQ10mpyIQX (Inverter_001_DW.UnitDelay_DSTATE_o, 10,
2141 Inverter_001_P.VC_Tci, 10);
2142 }
2143
2144 /* Sum: '<S29>/Sum1' */
2145 rtb_Gain6 = (rtb_IQN1xIQN1 + rtb_IQN1xIQN2) + rtb_FloattoIQN_n;
2146
2147 /* Sum: '<S23>/Sum12' */
2148 rtb_FloattoIQN_n = rtb_Gain6 + rtb_TmpSignalConversionAtGain1I[0];
2149
2150 /* Gain: '<S23>/Gain13' */
2151 rtb_IQN1xIQN1 = __IQxmpy(Inverter_001_P.Gain13_Gain, rtb_Gain1_idx_1, -10);
2152
2153 /* Sum: '<S23>/Sum15' */
2154 rtb_IQN1xIQN2 = rtb_FloattoIQN_n - rtb_IQN1xIQN1;
2155
2156 /* Sum: '<S25>/Sum' */
2157 rtb_FloattoIQN_n = rtb_IQN1xIQN2 - rtb_u_ad;
2158
2159 /* Sum: '<S25>/Sum11' incorporates:
2160 * UnitDelay: '<S25>/Unit Delay3'
2161 */
2162 rtb_IQN1xIQN1 = rtb_FloattoIQN_n - Inverter_001_DW.UnitDelay3_DSTATE_g;
2163
2164 /* Gain: '<S25>/Gain' */
2165 v = fabs(u_tmp);
2166 if (v < 4.503599627370496E+15) {
2167 if (v >= 0.5) {
2168 v = floor(u_tmp + 0.5);
2169 } else {
2170 v = u_tmp * 0.0;
2171 }
2172 } else {
2173 v = u_tmp;
2174 }
2175
2176 if (v < 2.147483648E+9) {
2177 if (v >= -2.147483648E+9) {
2178 rtb_Sum_e = (int32_T)v;
2179 } else {
2180 rtb_Sum_e = MIN_int32_T;
2181 }
2182 } else {
2183 rtb_Sum_e = MAX_int32_T;
2184 }
2185
2186 rtb_IQN1xIQN2 = __IQxmpy(rtb_Sum_e, rtb_IQN1xIQN1, -10);
2187
2188 /* Sum: '<S25>/Sum5' incorporates:
2189 * UnitDelay: '<S25>/Unit Delay2'
2190 */
2191 Inverter_001_DW.UnitDelay2_DSTATE_m += rtb_IQN1xIQN2;
2192
2193 /* Gain: '<S25>/Gain1' */
2194 v = fabs(u_tmp);
2195 if (v < 4.503599627370496E+15) {
2196 if (v >= 0.5) {
2197 v = floor(u_tmp + 0.5);
2198 } else {
2199 v = u_tmp * 0.0;
2200 }
2201 } else {
2202 v = u_tmp;
2203 }
2204
2205 if (v < 2.147483648E+9) {
2206 if (v >= -2.147483648E+9) {
2207 rtb_Sum_e = (int32_T)v;
2208 } else {
2209 rtb_Sum_e = MIN_int32_T;
2210 }
2211 } else {
2212 rtb_Sum_e = MAX_int32_T;
2213 }
2214
2215 rtb_IQN1xIQN1 = __IQxmpy(rtb_Sum_e, Inverter_001_DW.UnitDelay2_DSTATE_m, -10);
2216
2217 /* Sum: '<S25>/Sum4' incorporates:
2218 * UnitDelay: '<S25>/Unit Delay1'
2219 */
2220 Inverter_001_DW.UnitDelay1_DSTATE_m += rtb_IQN1xIQN1;
2221
2222 /* S-Function (stiiqmath_iqmpyiqx): '<S25>/IQN1 x IQN1' incorporates:
2223 * Constant: '<S16>/Kr2'
2224 */
2225
2226 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S25>/IQN1 x IQN1' */
2227 {
2228 rtb_IQN1xIQN1 = _IQ10mpyIQX (Inverter_001_DW.UnitDelay2_DSTATE_m, 10,
2229 Inverter_001_P.CC_Tcr, 10);
2230 }
2231
2232 /* S-Function (stiiqmath_iqmpyiqx): '<S25>/IQN1 x IQN2' incorporates:
2233 * Constant: '<S16>/Kp2'
2234 */
2235
2236 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S25>/IQN1 x IQN2' */
2237 {
2238 rtb_IQN1xIQN2 = _IQ10mpyIQX (rtb_FloattoIQN_n, 10, Inverter_001_P.Kcp, 10);
2239 }
2240
2241 /* Sum: '<S25>/Sum3' incorporates:
2242 * UnitDelay: '<S25>/Unit Delay'
2243 */
2244 Inverter_001_DW.UnitDelay_DSTATE_m += rtb_FloattoIQN_n;
2245
2246 /* S-Function (stiiqmath_iqmpyiqx): '<S25>/IQN1 x IQN3' incorporates:
2247 * Constant: '<S16>/Ki2'
2248 */
2249
2250 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S25>/IQN1 x IQN3' */
2251 {
2252 rtb_FloattoIQN_n = _IQ10mpyIQX (Inverter_001_DW.UnitDelay_DSTATE_m, 10,
2253 Inverter_001_P.CC_Tci, 10);
2254 }
2255
2256 /* S-Function (stiiqmath_iqmpyiqx): '<S25>/IQN1 x IQN7' incorporates:
2257 * Constant: '<S16>/w2'
2258 */
2259
2260 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S25>/IQN1 x IQN7' */
2261 {
2262 rtb_Gain6 = _IQ10mpyIQX (Inverter_001_P.w2_Value, 10,
2263 Inverter_001_P.w2_Value, 10);
2264 }
2265
2266 /* S-Function (stiiqmath_iqmpyiqx): '<S25>/IQN1 x IQN6' */
2267
2268 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S25>/IQN1 x IQN6' */
2269 {
2270 rtb_IQN1xIQN6_j = _IQ10mpyIQX (Inverter_001_DW.UnitDelay1_DSTATE_m, 10,
2271 rtb_Gain6, 10);
2272 }
2273
2274 /* S-Function (stiiqmath_iqmpyiqx): '<S30>/IQN1 x IQN1' incorporates:
2275 * Constant: '<S23>/Kr2'
2276 */
2277
2278 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S30>/IQN1 x IQN1' */
2279 {
2280 rtb_Gain6 = _IQ10mpyIQX (Inverter_001_DW.UnitDelay2_DSTATE, 10,
2281 Inverter_001_P.VC_Tcr, 10);
2282 }
2283
2284 /* S-Function (stiiqmath_iqmpyiqx): '<S30>/IQN1 x IQN2' incorporates:
2285 * Constant: '<S23>/Kp2'
2286 */
2287
2288 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S30>/IQN1 x IQN2' */
2289 {
2290 rtb_Sum1 = _IQ10mpyIQX (rtb_IQN1xIQN7, 10, Inverter_001_P.Kvp0, 10);
2291 }
2292
2293 /* Sum: '<S30>/Sum3' incorporates:
2294 * UnitDelay: '<S30>/Unit Delay'
2295 */
2296 Inverter_001_DW.UnitDelay_DSTATE_i += rtb_IQN1xIQN7;
2297
2298 /* S-Function (stiiqmath_iqmpyiqx): '<S30>/IQN1 x IQN3' incorporates:
2299 * Constant: '<S23>/Ki2'
2300 */
2301
2302 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S30>/IQN1 x IQN3' */
2303 {
2304 rtb_IQN1xIQN7 = _IQ10mpyIQX (Inverter_001_DW.UnitDelay_DSTATE_i, 10,
2305 Inverter_001_P.VC_Tci0, 10);
2306 }
2307
2308 /* Sum: '<S30>/Sum1' */
2309 rtb_Sum1_d = (rtb_Gain6 + rtb_Sum1) + rtb_IQN1xIQN7;
2310
2311 /* Sum: '<S23>/Sum14' */
2312 rtb_IQN1xIQN7 = rtb_Sum1_d + rtb_TmpSignalConversionAtGain1I[2];
2313
2314 /* Sum: '<S26>/Sum' */
2315 rtb_Gain6 = rtb_IQN1xIQN7 - rtb_u_p;
2316
2317 /* Sum: '<S26>/Sum11' incorporates:
2318 * UnitDelay: '<S26>/Unit Delay3'
2319 */
2320 rtb_IQN1xIQN7 = rtb_Gain6 - Inverter_001_DW.UnitDelay3_DSTATE_h;
2321
2322 /* Gain: '<S26>/Gain' */
2323 v = fabs(u_tmp);
2324 if (v < 4.503599627370496E+15) {
2325 if (v >= 0.5) {
2326 v = floor(u_tmp + 0.5);
2327 } else {
2328 v = u_tmp * 0.0;
2329 }
2330 } else {
2331 v = u_tmp;
2332 }
2333
2334 if (v < 2.147483648E+9) {
2335 if (v >= -2.147483648E+9) {
2336 rtb_Sum_e = (int32_T)v;
2337 } else {
2338 rtb_Sum_e = MIN_int32_T;
2339 }
2340 } else {
2341 rtb_Sum_e = MAX_int32_T;
2342 }
2343
2344 rtb_Sum1 = __IQxmpy(rtb_Sum_e, rtb_IQN1xIQN7, -10);
2345
2346 /* Sum: '<S26>/Sum5' incorporates:
2347 * UnitDelay: '<S26>/Unit Delay2'
2348 */
2349 Inverter_001_DW.UnitDelay2_DSTATE_gh += rtb_Sum1;
2350
2351 /* S-Function (stiiqmath_iqmpyiqx): '<S26>/IQN1 x IQN1' incorporates:
2352 * Constant: '<S16>/Kr1'
2353 */
2354
2355 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S26>/IQN1 x IQN1' */
2356 {
2357 rtb_IQN1xIQN7 = _IQ10mpyIQX (Inverter_001_DW.UnitDelay2_DSTATE_gh, 10,
2358 Inverter_001_P.CC_Tcr, 10);
2359 }
2360
2361 /* S-Function (stiiqmath_iqmpyiqx): '<S26>/IQN1 x IQN2' incorporates:
2362 * Constant: '<S16>/Kp1'
2363 */
2364
2365 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S26>/IQN1 x IQN2' */
2366 {
2367 rtb_Sum1 = _IQ10mpyIQX (rtb_Gain6, 10, Inverter_001_P.Kcp0, 10);
2368 }
2369
2370 /* Sum: '<S26>/Sum3' incorporates:
2371 * UnitDelay: '<S26>/Unit Delay'
2372 */
2373 Inverter_001_DW.UnitDelay_DSTATE_ci += rtb_Gain6;
2374
2375 /* S-Function (stiiqmath_iqmpyiqx): '<S26>/IQN1 x IQN3' incorporates:
2376 * Constant: '<S16>/Ki1'
2377 */
2378
2379 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S26>/IQN1 x IQN3' */
2380 {
2381 rtb_Gain6 = _IQ10mpyIQX (Inverter_001_DW.UnitDelay_DSTATE_ci, 10,
2382 Inverter_001_P.CC_Tci0, 10);
2383 }
2384
2385 /* Gain: '<S16>/Gain6' */
2386 rtb_Gain6 = __IQmpy(Inverter_001_P.Gain6_Gain, rtb_u_ad, 29);
2387
2388 /* Sum: '<S24>/Sum1' */
2389 rtb_Sum1 = (rtb_Sum3_kh + rtb_Sum9) + rtb_Sum_o;
2390
2391 /* Sum: '<S16>/Sum7' */
2392 rtb_Sum_o = rtb_Sum1 + rtb_Gain1_idx_1;
2393
2394 /* Sum: '<S16>/Sum10' */
2395 rtb_Sum3_kh = rtb_Sum_o + rtb_Gain6;
2396
2397 /* Gain: '<S26>/Gain1' */
2398 v = fabs(u_tmp);
2399 if (v < 4.503599627370496E+15) {
2400 if (v >= 0.5) {
2401 u_tmp = floor(u_tmp + 0.5);
2402 } else {
2403 u_tmp *= 0.0;
2404 }
2405 }
2406
2407 if (u_tmp < 2.147483648E+9) {
2408 if (u_tmp >= -2.147483648E+9) {
2409 rtb_Sum_e = (int32_T)u_tmp;
2410 } else {
2411 rtb_Sum_e = MIN_int32_T;
2412 }
2413 } else {
2414 rtb_Sum_e = MAX_int32_T;
2415 }
2416
2417 rtb_Sum_o = __IQxmpy(rtb_Sum_e, Inverter_001_DW.UnitDelay2_DSTATE_gh, -10);
2418
2419 /* Sum: '<S26>/Sum4' incorporates:
2420 * UnitDelay: '<S26>/Unit Delay1'
2421 */
2422 Inverter_001_DW.UnitDelay1_DSTATE_g += rtb_Sum_o;
2423
2424 /* S-Function (stiiqmath_iqmpyiqx): '<S26>/IQN1 x IQN7' incorporates:
2425 * Constant: '<S16>/w1'
2426 */
2427
2428 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S26>/IQN1 x IQN7' */
2429 {
2430 rtb_Sum_o = _IQ10mpyIQX (Inverter_001_P.w1_Value, 10,
2431 Inverter_001_P.w1_Value, 10);
2432 }
2433
2434 /* S-Function (stiiqmath_iqmpyiqx): '<S26>/IQN1 x IQN6' */
2435
2436 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S26>/IQN1 x IQN6' */
2437 {
2438 rtb_IQN1xIQN6_n = _IQ10mpyIQX (Inverter_001_DW.UnitDelay1_DSTATE_g, 10,
2439 rtb_Sum_o, 10);
2440 }
2441
2442 /* Sum: '<S25>/Sum1' */
2443 rtb_Sum9 = (rtb_IQN1xIQN1 + rtb_IQN1xIQN2) + rtb_FloattoIQN_n;
2444
2445 /* Sum: '<S16>/Sum6' */
2446 rtb_FloattoIQN_n = rtb_Sum9 + rtb_Gain1_idx_0;
2447
2448 /* S-Function (scheckfractionlength): '<S17>/ 2' */
2449 rtb_IQN1xIQN7 = Inverter_001_B.RateTransition61;
2450
2451 /* S-Function (stiiqmath_iq): '<S17>/Float to IQN' incorporates:
2452 * Constant: '<S17>/Constant'
2453 */
2454
2455 /* C28x IQmath Library (stiiqmath_iq) - '<S17>/Float to IQN' */
2456 {
2457 rtb_FloattoIQN_n = _IQ10 (Inverter_001_P.Constant_Value_br);
2458 }
2459
2460 /* Sum: '<S17>/Sum' */
2461 rtb_Sum_o = rtb_IQN1xIQN7 + rtb_FloattoIQN_n;
2462
2463 /* Sum: '<S17>/Sum3' */
2464 rtb_Sum3_kh = rtb_IQN1xIQN7 - rtb_FloattoIQN_n;
2465
2466 /* S-Function (stiiqmath_iqtrig): '<S17>/cos IQN' */
2467
2468 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S17>/cos IQN' */
2469 {
2470 rtb_cosIQN = _IQ10cos(rtb_IQN1xIQN7);
2471 }
2472
2473 /* S-Function (stiiqmath_iqtrig): '<S17>/cos IQN1' */
2474
2475 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S17>/cos IQN1' */
2476 {
2477 rtb_cosIQN1 = _IQ10cos(rtb_Sum3_kh);
2478 }
2479
2480 /* S-Function (stiiqmath_iqtrig): '<S17>/cos IQN2' */
2481
2482 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S17>/cos IQN2' */
2483 {
2484 rtb_cosIQN2 = _IQ10cos(rtb_Sum_o);
2485 }
2486
2487 /* S-Function (stiiqmath_iqtrig): '<S17>/sin IQN' */
2488
2489 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S17>/sin IQN' */
2490 {
2491 rtb_sinIQN = _IQ10sin(rtb_IQN1xIQN7);
2492 }
2493
2494 /* S-Function (stiiqmath_iqtrig): '<S17>/sin IQN1' */
2495
2496 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S17>/sin IQN1' */
2497 {
2498 rtb_sinIQN1 = _IQ10sin(rtb_Sum3_kh);
2499 }
2500
2501 /* S-Function (stiiqmath_iqtrig): '<S17>/sin IQN2' */
2502
2503 /* C28x IQmath Library (stiiqmath_iqtrig) - '<S17>/sin IQN2' */
2504 {
2505 rtb_sinIQN2 = _IQ10sin(rtb_Sum_o);
2506 }
2507
2508 /* S-Function (stiiqmath_iqmpyiqx): '<S28>/IQN1 x IQN7' incorporates:
2509 * Constant: '<S23>/w5'
2510 */
2511
2512 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S28>/IQN1 x IQN7' */
2513 {
2514 rtb_IQN1xIQN7 = _IQ10mpyIQX (Inverter_001_P.w5_Value, 10,
2515 Inverter_001_P.w5_Value, 10);
2516 }
2517
2518 /* S-Function (stiiqmath_iqmpyiqx): '<S28>/IQN1 x IQN6' */
2519
2520 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S28>/IQN1 x IQN6' */
2521 {
2522 rtb_IQN1xIQN6_m = _IQ10mpyIQX (Inverter_001_DW.UnitDelay1_DSTATE_hyo, 10,
2523 rtb_IQN1xIQN7, 10);
2524 }
2525
2526 /* S-Function (stiiqmath_iqmpyiqx): '<S29>/IQN1 x IQN7' incorporates:
2527 * Constant: '<S23>/w5'
2528 */
2529
2530 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S29>/IQN1 x IQN7' */
2531 {
2532 rtb_IQN1xIQN7 = _IQ10mpyIQX (Inverter_001_P.w5_Value, 10,
2533 Inverter_001_P.w5_Value, 10);
2534 }
2535
2536 /* S-Function (stiiqmath_iqmpyiqx): '<S29>/IQN1 x IQN6' */
2537
2538 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S29>/IQN1 x IQN6' */
2539 {
2540 rtb_IQN1xIQN6_i = _IQ10mpyIQX (Inverter_001_DW.UnitDelay1_DSTATE_d, 10,
2541 rtb_IQN1xIQN7, 10);
2542 }
2543
2544 /* S-Function (stiiqmath_iqmpyiqx): '<S30>/IQN1 x IQN7' incorporates:
2545 * Constant: '<S23>/w2'
2546 */
2547
2548 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S30>/IQN1 x IQN7' */
2549 {
2550 rtb_IQN1xIQN7 = _IQ10mpyIQX (Inverter_001_P.w2_Value_n, 10,
2551 Inverter_001_P.w2_Value_n, 10);
2552 }
2553
2554 /* S-Function (stiiqmath_iqmpyiqx): '<S30>/IQN1 x IQN6' */
2555
2556 /* C28x IQmath Library (stiiqmath_iqmpyiqx) - '<S30>/IQN1 x IQN6' */
2557 {
2558 rtb_IQN1xIQN6_c = _IQ10mpyIQX (Inverter_001_DW.UnitDelay1_DSTATE_b, 10,
2559 rtb_IQN1xIQN7, 10);
2560 }
2561
2562 /* S-Function (c2837xdipc_rx): '<Root>/IPC Receive' */
2563 MW_IPC_Receive(CHANNEL0, (uint32_t *)&Inverter_001_B.IPCReceive_o1,
2564 &Inverter_001_B.IPCReceive_o2, 1, 8, 0);
2565
2566 /* MATLABSystem: '<Root>/DAC' incorporates:
2567 * Bias: '<Root>/Bias1'
2568 */
2569 tmp = rt_roundf_snf(Inverter_001_B.RateTransition5[1] +
2570 Inverter_001_P.Bias1_Bias);
2571 if (tmp < 65536.0F) {
2572 if (tmp >= 0.0F) {
2573 tmp_0 = (uint16_T)tmp;
2574 } else {
2575 tmp_0 = 0U;
2576 }
2577 } else {
2578 tmp_0 = MAX_uint16_T;
2579 }
2580
2581 MW_C2000DAC(0U, tmp_0);
2582
2583 /* End of MATLABSystem: '<Root>/DAC' */
2584
2585 /* MATLABSystem: '<Root>/DAC1' incorporates:
2586 * Bias: '<Root>/Bias2'
2587 * DataTypeConversion: '<Root>/Data Type Conversion3'
2588 * Gain: '<Root>/Gain2'
2589 */
2590 tmp = rt_roundf_snf((real32_T)rtb_PhaseB * 2.27373675E-13F *
2591 Inverter_001_P.Gain2_Gain_f + Inverter_001_P.Bias2_Bias);
2592 if (tmp < 65536.0F) {
2593 if (tmp >= 0.0F) {
2594 tmp_0 = (uint16_T)tmp;
2595 } else {
2596 tmp_0 = 0U;
2597 }
2598 } else {
2599 tmp_0 = MAX_uint16_T;
2600 }
2601
2602 MW_C2000DAC(1U, tmp_0);
2603
2604 /* End of MATLABSystem: '<Root>/DAC1' */
2605
2606 /* Update for RateTransition: '<Root>/Rate Transition1' incorporates:
2607 * Constant: '<Root>/Constant14'
2608 */
2609 Inverter_001_DW.RateTransition1_Buffer0 = Inverter_001_P.Constant14_Value_m;
2610
2611 /* Update for UnitDelay: '<S30>/Unit Delay3' */
2612 Inverter_001_DW.UnitDelay3_DSTATE = rtb_IQN1xIQN6_c;
2613
2614 /* Update for UnitDelay: '<S29>/Unit Delay3' */
2615 Inverter_001_DW.UnitDelay3_DSTATE_c = rtb_IQN1xIQN6_i;
2616
2617 /* Update for UnitDelay: '<S28>/Unit Delay3' */
2618 Inverter_001_DW.UnitDelay3_DSTATE_m = rtb_IQN1xIQN6_m;
2619
2620 /* Update for UnitDelay: '<S24>/Unit Delay3' */
2621 Inverter_001_DW.UnitDelay3_DSTATE_o = rtb_IQN1xIQN6;
2622
2623 /* Update for UnitDelay: '<S25>/Unit Delay3' */
2624 Inverter_001_DW.UnitDelay3_DSTATE_g = rtb_IQN1xIQN6_j;
2625
2626 /* Update for UnitDelay: '<S26>/Unit Delay3' */
2627 Inverter_001_DW.UnitDelay3_DSTATE_h = rtb_IQN1xIQN6_n;
2628}
2629
2630/* Model step function for TID2 */
2631void Inverter_001_step2(void) /* Sample time: [0.0002s, 0.0s] */
2632{
2633 /* (no output/update code required) */
2634}
2635
2636/* Model step function for TID3 */
2637void Inverter_001_step3(void) /* Sample time: [0.1s, 0.0s] */
2638{
2639 /* Update for RateTransition: '<Root>/TmpRTBAtConstant62Outport1' incorporates:
2640 * Constant: '<Root>/Constant62'
2641 */
2642 Inverter_001_DW.TmpRTBAtConstant62Outport1_Buff =
2643 Inverter_001_P.Constant62_Value;
2644
2645 /* Update for RateTransition: '<S2>/TmpRTBAtAdd11Inport2' incorporates:
2646 * Constant: '<Root>/Constant61'
2647 */
2648 Inverter_001_DW.TmpRTBAtAdd11Inport2_Buffer0 = Inverter_001_P.Constant61_Value;
2649
2650 /* Update for RateTransition: '<S2>/TmpRTBAtAdd10Inport2' incorporates:
2651 * Constant: '<Root>/Constant63'
2652 */
2653 Inverter_001_DW.TmpRTBAtAdd10Inport2_Buffer0 = Inverter_001_P.Constant63_Value;
2654
2655 /* Update for RateTransition: '<S2>/TmpRTBAtAdd9Inport2' incorporates:
2656 * Constant: '<Root>/Constant58'
2657 */
2658 Inverter_001_DW.TmpRTBAtAdd9Inport2_Buffer0 = Inverter_001_P.Constant58_Value;
2659
2660 /* Update for RateTransition: '<Root>/TmpRTBAtConstant12Outport1' incorporates:
2661 * Constant: '<Root>/Constant12'
2662 */
2663 Inverter_001_DW.TmpRTBAtConstant12Outport1_Buff =
2664 Inverter_001_P.Constant12_Value;
2665
2666 /* Update for RateTransition: '<S2>/TmpRTBAtAdd16Inport2' incorporates:
2667 * Constant: '<Root>/Constant55'
2668 */
2669 Inverter_001_DW.TmpRTBAtAdd16Inport2_Buffer0 = Inverter_001_P.Constant55_Value;
2670
2671 /* Update for RateTransition: '<S2>/TmpRTBAtAdd5Inport2' incorporates:
2672 * Constant: '<Root>/Constant65'
2673 */
2674 Inverter_001_DW.TmpRTBAtAdd5Inport2_Buffer0 = Inverter_001_P.Constant65_Value;
2675
2676 /* Update for RateTransition: '<S2>/TmpRTBAtAdd4Inport2' incorporates:
2677 * Constant: '<Root>/Constant68'
2678 */
2679 Inverter_001_DW.TmpRTBAtAdd4Inport2_Buffer0 = Inverter_001_P.Constant68_Value;
2680
2681 /* Update for RateTransition: '<S2>/TmpRTBAtAdd3Inport2' incorporates:
2682 * Constant: '<Root>/Constant57'
2683 */
2684 Inverter_001_DW.TmpRTBAtAdd3Inport2_Buffer0 = Inverter_001_P.Constant57_Value;
2685
2686 /* Update for RateTransition: '<S2>/TmpRTBAtAdd7Inport2' incorporates:
2687 * Constant: '<Root>/Constant89'
2688 */
2689 Inverter_001_DW.TmpRTBAtAdd7Inport2_Buffer0 = Inverter_001_P.Constant89_Value;
2690
2691 /* Update for RateTransition: '<S2>/TmpRTBAtAdd2Inport2' incorporates:
2692 * Constant: '<Root>/Constant72'
2693 */
2694 Inverter_001_DW.TmpRTBAtAdd2Inport2_Buffer0 = Inverter_001_P.Constant72_Value;
2695}
2696
2697/* Model initialize function */
2698void Inverter_001_initialize(void)
2699{
2700 /* Registration code */
2701
2702 /* initialize real-time model */
2703 (void) memset((void *)Inverter_001_M, 0,
2704 sizeof(RT_MODEL_Inverter_001_T));
2705
2706 /* block I/O */
2707 (void) memset(((void *) &Inverter_001_B), 0,
2708 sizeof(B_Inverter_001_T));
2709
2710 /* states (dwork) */
2711 (void) memset((void *)&Inverter_001_DW, 0,
2712 sizeof(DW_Inverter_001_T));
2713
2714 /* Start for RateTransition: '<Root>/TmpRTBAtConstant62Outport1' */
2715 Inverter_001_B.TmpRTBAtConstant62Outport1 =
2716 Inverter_001_P.TmpRTBAtConstant62Outport1_Init;
2717
2718 /* Start for RateTransition: '<S2>/TmpRTBAtAdd11Inport2' */
2719 Inverter_001_B.TmpRTBAtAdd11Inport2 =
2720 Inverter_001_P.TmpRTBAtAdd11Inport2_InitialCon;
2721
2722 /* Start for RateTransition: '<Root>/Rate Transition1' */
2723 Inverter_001_B.RateTransition1 =
2724 Inverter_001_P.RateTransition1_InitialConditio;
2725
2726 /* Start for S-Function (c280xgpio_do): '<Root>/Digital Output' */
2727 EALLOW;
2728 GpioCtrlRegs.GPBMUX2.all &= 0xF3FFFFFF;
2729 GpioCtrlRegs.GPBDIR.all |= 0x20000000;
2730 EDIS;
2731
2732 /* Start for S-Function (c280xgpio_do): '<Root>/Digital Output1' */
2733 EALLOW;
2734 GpioCtrlRegs.GPBMUX2.all &= 0x3FFFFFFF;
2735 GpioCtrlRegs.GPBDIR.all |= 0x80000000;
2736 EDIS;
2737
2738 /* Start for S-Function (c280xgpio_do): '<Root>/Digital Output2' */
2739 EALLOW;
2740 GpioCtrlRegs.GPCMUX1.all &= 0xFFFFFFCF;
2741 GpioCtrlRegs.GPCDIR.all |= 0x4;
2742 EDIS;
2743
2744 /* Start for S-Function (c2802xpwm): '<S4>/ePWM' incorporates:
2745 * Constant: '<Root>/Constant2'
2746 */
2747 EALLOW;
2748 CpuSysRegs.PCLKCR2.bit.EPWM5 = 1;
2749 CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
2750 EDIS;
2751
2752 /*** Initialize ePWM5 modules ***/
2753 {
2754 /* // Time Base Control Register
2755 EPwm5Regs.TBCTL.bit.CTRMODE = 2; // Counter Mode
2756 EPwm5Regs.TBCTL.bit.SYNCOSEL = 3; // Sync Output Select
2757 EPwm5Regs.TBCTL.bit.PRDLD = 0; // Shadow select
2758 EPwm5Regs.TBCTL.bit.PHSEN = 0; // Phase Load Enable
2759 EPwm5Regs.TBCTL.bit.PHSDIR = 0; // Phase Direction Bit
2760 EPwm5Regs.TBCTL.bit.HSPCLKDIV = 0; // High Speed TBCLK Pre-scaler
2761 EPwm5Regs.TBCTL.bit.CLKDIV = 0; // Time Base Clock Pre-scaler
2762 EPwm5Regs.TBCTL.bit.SWFSYNC = 0; // Software Force Sync Pulse
2763 */
2764 EPwm5Regs.TBCTL.all = (EPwm5Regs.TBCTL.all & ~0x3FFF) | 0x32;
2765
2766 /*-- Setup Time-Base (TB) Submodule --*/
2767 EPwm5Regs.TBPRD = 12500; // Time Base Period Register
2768
2769 /* // Time-Base Phase Register
2770 EPwm5Regs.TBPHS.bit.TBPHS = 0; // Phase offset register
2771 */
2772 EPwm5Regs.TBPHS.all = (EPwm5Regs.TBPHS.all & ~0xFFFF0000) | 0x0;
2773
2774 // Time Base Counter Register
2775 EPwm5Regs.TBCTR = 0x0000; /* Clear counter*/
2776
2777 /*-- Setup Counter_Compare (CC) Submodule --*/
2778 /* // Counter Compare Control Register
2779 EPwm5Regs.CMPCTL.bit.SHDWAMODE = 0; // Compare A Register Block Operating Mode
2780 EPwm5Regs.CMPCTL.bit.SHDWBMODE = 0; // Compare B Register Block Operating Mode
2781 EPwm5Regs.CMPCTL.bit.LOADAMODE = 0; // Active Compare A Load
2782 EPwm5Regs.CMPCTL.bit.LOADBMODE = 0; // Active Compare B Load
2783 */
2784 EPwm5Regs.CMPCTL.all = (EPwm5Regs.CMPCTL.all & ~0x5F) | 0x0;
2785
2786 /* EPwm5Regs.CMPCTL2.bit.SHDWCMODE = 0; // Compare C Register Block Operating Mode
2787
2788 EPwm5Regs.CMPCTL2.bit.SHDWDMODE = 0; // Compare D Register Block Operating Mode
2789 */
2790 EPwm5Regs.CMPCTL2.all = (EPwm5Regs.CMPCTL2.all & ~0x50) | 0x0;
2791 EPwm5Regs.CMPA.bit.CMPA = 3750; // Counter Compare A Register
2792 EPwm5Regs.CMPB.bit.CMPB = 3750; // Counter Compare B Register
2793 EPwm5Regs.CMPC = 32000; // Counter Compare C Register
2794 EPwm5Regs.CMPD = 32000; // Counter Compare D Register
2795
2796 /*-- Setup Action-Qualifier (AQ) Submodule --*/
2797 EPwm5Regs.AQCTLA.all = 150; // Action Qualifier Control Register For Output A
2798 EPwm5Regs.AQCTLB.all = 1545; // Action Qualifier Control Register For Output B
2799
2800 /* // Action Qualifier Software Force Register
2801 EPwm5Regs.AQSFRC.bit.RLDCSF = 0; // Reload from Shadow Options
2802 */
2803 EPwm5Regs.AQSFRC.all = (EPwm5Regs.AQSFRC.all & ~0xC0) | 0x0;
2804
2805 /* // Action Qualifier Continuous S/W Force Register
2806 EPwm5Regs.AQCSFRC.bit.CSFA = 0; // Continuous Software Force on output A
2807 EPwm5Regs.AQCSFRC.bit.CSFB = 0; // Continuous Software Force on output B
2808 */
2809 EPwm5Regs.AQCSFRC.all = (EPwm5Regs.AQCSFRC.all & ~0xF) | 0x0;
2810
2811 /*-- Setup Dead-Band Generator (DB) Submodule --*/
2812 /* // Dead-Band Generator Control Register
2813 EPwm5Regs.DBCTL.bit.OUT_MODE = 3; // Dead Band Output Mode Control
2814 EPwm5Regs.DBCTL.bit.IN_MODE = 0; // Dead Band Input Select Mode Control
2815 EPwm5Regs.DBCTL.bit.POLSEL = 2; // Polarity Select Control
2816 EPwm5Regs.DBCTL.bit.HALFCYCLE = 0; // Half Cycle Clocking Enable
2817 */
2818 EPwm5Regs.DBCTL.all = (EPwm5Regs.DBCTL.all & ~0x803F) | 0xB;
2819 EPwm5Regs.DBRED.bit.DBRED = 0; // Dead-Band Generator Rising Edge Delay Count Register
2820 EPwm5Regs.DBFED.bit.DBFED = 0; // Dead-Band Generator Falling Edge Delay Count Register
2821
2822 /*-- Setup Event-Trigger (ET) Submodule --*/
2823 /* // Event Trigger Selection and Pre-Scale Register
2824 EPwm5Regs.ETSEL.bit.SOCAEN = 0; // Start of Conversion A Enable
2825 EPwm5Regs.ETSEL.bit.SOCASELCMP = 0;
2826 EPwm5Regs.ETSEL.bit.SOCASEL = 0 ; // Start of Conversion A Select
2827 EPwm5Regs.ETPS.bit.SOCAPRD = 1; // EPWM5SOCA Period Select
2828
2829 EPwm5Regs.ETSEL.bit.SOCBEN = 0; // Start of Conversion B Enable
2830
2831 EPwm5Regs.ETSEL.bit.SOCBSELCMP = 0;
2832 EPwm5Regs.ETSEL.bit.SOCBSEL = 1; // Start of Conversion A Select
2833 EPwm5Regs.ETPS.bit.SOCBPRD = 1; // EPWM5SOCB Period Select
2834 EPwm5Regs.ETSEL.bit.INTEN = 0; // EPWM5INTn Enable
2835 EPwm5Regs.ETSEL.bit.INTSELCMP = 0;
2836 EPwm5Regs.ETSEL.bit.INTSEL = 1; // Start of Conversion A Select
2837
2838 EPwm5Regs.ETPS.bit.INTPRD = 1; // EPWM5INTn Period Select
2839 */
2840 EPwm5Regs.ETSEL.all = (EPwm5Regs.ETSEL.all & ~0xFF7F) | 0x1001;
2841 EPwm5Regs.ETPS.all = (EPwm5Regs.ETPS.all & ~0x3303) | 0x1101;
2842
2843 /*-- Setup PWM-Chopper (PC) Submodule --*/
2844 /* // PWM Chopper Control Register
2845 EPwm5Regs.PCCTL.bit.CHPEN = 0; // PWM chopping enable
2846 EPwm5Regs.PCCTL.bit.CHPFREQ = 0; // Chopping clock frequency
2847 EPwm5Regs.PCCTL.bit.OSHTWTH = 0; // One-shot pulse width
2848 EPwm5Regs.PCCTL.bit.CHPDUTY = 0; // Chopping clock Duty cycle
2849 */
2850 EPwm5Regs.PCCTL.all = (EPwm5Regs.PCCTL.all & ~0x7FF) | 0x0;
2851
2852 /*-- Set up Trip-Zone (TZ) Submodule --*/
2853 EALLOW;
2854 EPwm5Regs.TZSEL.all = 0; // Trip Zone Select Register
2855
2856 /* // Trip Zone Control Register
2857 EPwm5Regs.TZCTL.bit.TZA = 3; // TZ1 to TZ6 Trip Action On EPWM5A
2858 EPwm5Regs.TZCTL.bit.TZB = 3; // TZ1 to TZ6 Trip Action On EPWM5B
2859 EPwm5Regs.TZCTL.bit.DCAEVT1 = 3; // EPWM5A action on DCAEVT1
2860 EPwm5Regs.TZCTL.bit.DCAEVT2 = 3; // EPWM5A action on DCAEVT2
2861 EPwm5Regs.TZCTL.bit.DCBEVT1 = 3; // EPWM5B action on DCBEVT1
2862 EPwm5Regs.TZCTL.bit.DCBEVT2 = 3; // EPWM5B action on DCBEVT2
2863 */
2864 EPwm5Regs.TZCTL.all = (EPwm5Regs.TZCTL.all & ~0xFFF) | 0xFFF;
2865
2866 /* // Trip Zone Enable Interrupt Register
2867 EPwm5Regs.TZEINT.bit.OST = 0; // Trip Zones One Shot Int Enable
2868 EPwm5Regs.TZEINT.bit.CBC = 0; // Trip Zones Cycle By Cycle Int Enable
2869 EPwm5Regs.TZEINT.bit.DCAEVT1 = 0; // Digital Compare A Event 1 Int Enable
2870 EPwm5Regs.TZEINT.bit.DCAEVT2 = 0; // Digital Compare A Event 2 Int Enable
2871 EPwm5Regs.TZEINT.bit.DCBEVT1 = 0; // Digital Compare B Event 1 Int Enable
2872 EPwm5Regs.TZEINT.bit.DCBEVT2 = 0; // Digital Compare B Event 2 Int Enable
2873 */
2874 EPwm5Regs.TZEINT.all = (EPwm5Regs.TZEINT.all & ~0x7E) | 0x0;
2875
2876 /* // Digital Compare A Control Register
2877 EPwm5Regs.DCACTL.bit.EVT1SYNCE = 0; // DCAEVT1 SYNC Enable
2878 EPwm5Regs.DCACTL.bit.EVT1SOCE = 1; // DCAEVT1 SOC Enable
2879 EPwm5Regs.DCACTL.bit.EVT1FRCSYNCSEL = 0; // DCAEVT1 Force Sync Signal
2880 EPwm5Regs.DCACTL.bit.EVT1SRCSEL = 0; // DCAEVT1 Source Signal
2881 EPwm5Regs.DCACTL.bit.EVT2FRCSYNCSEL = 0; // DCAEVT2 Force Sync Signal
2882 EPwm5Regs.DCACTL.bit.EVT2SRCSEL = 0; // DCAEVT2 Source Signal
2883 */
2884 EPwm5Regs.DCACTL.all = (EPwm5Regs.DCACTL.all & ~0x30F) | 0x4;
2885
2886 /* // Digital Compare B Control Register
2887 EPwm5Regs.DCBCTL.bit.EVT1SYNCE = 0; // DCBEVT1 SYNC Enable
2888 EPwm5Regs.DCBCTL.bit.EVT1SOCE = 0; // DCBEVT1 SOC Enable
2889 EPwm5Regs.DCBCTL.bit.EVT1FRCSYNCSEL = 0; // DCBEVT1 Force Sync Signal
2890 EPwm5Regs.DCBCTL.bit.EVT1SRCSEL = 0; // DCBEVT1 Source Signal
2891 EPwm5Regs.DCBCTL.bit.EVT2FRCSYNCSEL = 0; // DCBEVT2 Force Sync Signal
2892 EPwm5Regs.DCBCTL.bit.EVT2SRCSEL = 0; // DCBEVT2 Source Signal
2893 */
2894 EPwm5Regs.DCBCTL.all = (EPwm5Regs.DCBCTL.all & ~0x30F) | 0x0;
2895
2896 /* // Digital Compare Trip Select Register
2897 EPwm5Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 0; // Digital Compare A High COMP Input Select
2898
2899 EPwm5Regs.DCTRIPSEL.bit.DCALCOMPSEL = 1; // Digital Compare A Low COMP Input Select
2900 EPwm5Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 0; // Digital Compare B High COMP Input Select
2901 EPwm5Regs.DCTRIPSEL.bit.DCBLCOMPSEL = 1; // Digital Compare B Low COMP Input Select
2902
2903
2904
2905
2906
2907 */
2908 EPwm5Regs.DCTRIPSEL.all = (EPwm5Regs.DCTRIPSEL.all & ~ 0xFFFF) | 0x1010;
2909
2910 /* // Trip Zone Digital Comparator Select Register
2911 EPwm5Regs.TZDCSEL.bit.DCAEVT1 = 0; // Digital Compare Output A Event 1
2912 EPwm5Regs.TZDCSEL.bit.DCAEVT2 = 0; // Digital Compare Output A Event 2
2913 EPwm5Regs.TZDCSEL.bit.DCBEVT1 = 0; // Digital Compare Output B Event 1
2914 EPwm5Regs.TZDCSEL.bit.DCBEVT2 = 0; // Digital Compare Output B Event 2
2915 */
2916 EPwm5Regs.TZDCSEL.all = (EPwm5Regs.TZDCSEL.all & ~0xFFF) | 0x0;
2917
2918 /* // Digital Compare Filter Control Register
2919 EPwm5Regs.DCFCTL.bit.BLANKE = 0; // Blanking Enable/Disable
2920 EPwm5Regs.DCFCTL.bit.PULSESEL = 1; // Pulse Select for Blanking & Capture Alignment
2921 EPwm5Regs.DCFCTL.bit.BLANKINV = 0; // Blanking Window Inversion
2922 EPwm5Regs.DCFCTL.bit.SRCSEL = 0; // Filter Block Signal Source Select
2923 */
2924 EPwm5Regs.DCFCTL.all = (EPwm5Regs.DCFCTL.all & ~0x3F) | 0x10;
2925 EPwm5Regs.DCFOFFSET = 0; // Digital Compare Filter Offset Register
2926 EPwm5Regs.DCFWINDOW = 0; // Digital Compare Filter Window Register
2927
2928 /* // Digital Compare Capture Control Register
2929 EPwm5Regs.DCCAPCTL.bit.CAPE = 0; // Counter Capture Enable
2930 */
2931 EPwm5Regs.DCCAPCTL.all = (EPwm5Regs.DCCAPCTL.all & ~0x1) | 0x0;
2932
2933 /* // HRPWM Configuration Register
2934 EPwm5Regs.HRCNFG.bit.SWAPAB = 0; // Swap EPWMA and EPWMB Outputs Bit
2935 EPwm5Regs.HRCNFG.bit.SELOUTB = 0; // EPWMB Output Selection Bit
2936 */
2937 EPwm5Regs.HRCNFG.all = (EPwm5Regs.HRCNFG.all & ~0xA0) | 0x0;
2938
2939 /* Update the Link Registers with the link value for all the Compare values and TBPRD */
2940 /* No error is thrown if the ePWM register exists in the model or not */
2941 EPwm5Regs.EPWMXLINK.bit.TBPRDLINK = 4;
2942 EPwm5Regs.EPWMXLINK.bit.CMPALINK = 4;
2943 EPwm5Regs.EPWMXLINK.bit.CMPBLINK = 4;
2944 EPwm5Regs.EPWMXLINK.bit.CMPCLINK = 4;
2945 EPwm5Regs.EPWMXLINK.bit.CMPDLINK = 4;
2946 EDIS;
2947 EALLOW;
2948 CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
2949 EDIS;
2950 }
2951
2952 /* Start for S-Function (c2802xpwm): '<S4>/ePWM1' incorporates:
2953 * Constant: '<Root>/Constant2'
2954 */
2955 EALLOW;
2956 CpuSysRegs.PCLKCR2.bit.EPWM3 = 1;
2957 CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
2958 EDIS;
2959
2960 /*** Initialize ePWM3 modules ***/
2961 {
2962 /* // Time Base Control Register
2963 EPwm3Regs.TBCTL.bit.CTRMODE = 2; // Counter Mode
2964 EPwm3Regs.TBCTL.bit.SYNCOSEL = 3; // Sync Output Select
2965 EPwm3Regs.TBCTL.bit.PRDLD = 0; // Shadow select
2966 EPwm3Regs.TBCTL.bit.PHSEN = 0; // Phase Load Enable
2967 EPwm3Regs.TBCTL.bit.PHSDIR = 0; // Phase Direction Bit
2968 EPwm3Regs.TBCTL.bit.HSPCLKDIV = 0; // High Speed TBCLK Pre-scaler
2969 EPwm3Regs.TBCTL.bit.CLKDIV = 0; // Time Base Clock Pre-scaler
2970 EPwm3Regs.TBCTL.bit.SWFSYNC = 0; // Software Force Sync Pulse
2971 */
2972 EPwm3Regs.TBCTL.all = (EPwm3Regs.TBCTL.all & ~0x3FFF) | 0x32;
2973
2974 /*-- Setup Time-Base (TB) Submodule --*/
2975 EPwm3Regs.TBPRD = 12500; // Time Base Period Register
2976
2977 /* // Time-Base Phase Register
2978 EPwm3Regs.TBPHS.bit.TBPHS = 0; // Phase offset register
2979 */
2980 EPwm3Regs.TBPHS.all = (EPwm3Regs.TBPHS.all & ~0xFFFF0000) | 0x0;
2981
2982 // Time Base Counter Register
2983 EPwm3Regs.TBCTR = 0x0000; /* Clear counter*/
2984
2985 /*-- Setup Counter_Compare (CC) Submodule --*/
2986 /* // Counter Compare Control Register
2987 EPwm3Regs.CMPCTL.bit.SHDWAMODE = 0; // Compare A Register Block Operating Mode
2988 EPwm3Regs.CMPCTL.bit.SHDWBMODE = 0; // Compare B Register Block Operating Mode
2989 EPwm3Regs.CMPCTL.bit.LOADAMODE = 0; // Active Compare A Load
2990 EPwm3Regs.CMPCTL.bit.LOADBMODE = 0; // Active Compare B Load
2991 */
2992 EPwm3Regs.CMPCTL.all = (EPwm3Regs.CMPCTL.all & ~0x5F) | 0x0;
2993
2994 /* EPwm3Regs.CMPCTL2.bit.SHDWCMODE = 0; // Compare C Register Block Operating Mode
2995
2996 EPwm3Regs.CMPCTL2.bit.SHDWDMODE = 0; // Compare D Register Block Operating Mode
2997 */
2998 EPwm3Regs.CMPCTL2.all = (EPwm3Regs.CMPCTL2.all & ~0x50) | 0x0;
2999 EPwm3Regs.CMPA.bit.CMPA = 3750; // Counter Compare A Register
3000 EPwm3Regs.CMPB.bit.CMPB = 3750; // Counter Compare B Register
3001 EPwm3Regs.CMPC = 32000; // Counter Compare C Register
3002 EPwm3Regs.CMPD = 32000; // Counter Compare D Register
3003
3004 /*-- Setup Action-Qualifier (AQ) Submodule --*/
3005 EPwm3Regs.AQCTLA.all = 150; // Action Qualifier Control Register For Output A
3006 EPwm3Regs.AQCTLB.all = 1545; // Action Qualifier Control Register For Output B
3007
3008 /* // Action Qualifier Software Force Register
3009 EPwm3Regs.AQSFRC.bit.RLDCSF = 0; // Reload from Shadow Options
3010 */
3011 EPwm3Regs.AQSFRC.all = (EPwm3Regs.AQSFRC.all & ~0xC0) | 0x0;
3012
3013 /* // Action Qualifier Continuous S/W Force Register
3014 EPwm3Regs.AQCSFRC.bit.CSFA = 0; // Continuous Software Force on output A
3015 EPwm3Regs.AQCSFRC.bit.CSFB = 0; // Continuous Software Force on output B
3016 */
3017 EPwm3Regs.AQCSFRC.all = (EPwm3Regs.AQCSFRC.all & ~0xF) | 0x0;
3018
3019 /*-- Setup Dead-Band Generator (DB) Submodule --*/
3020 /* // Dead-Band Generator Control Register
3021 EPwm3Regs.DBCTL.bit.OUT_MODE = 3; // Dead Band Output Mode Control
3022 EPwm3Regs.DBCTL.bit.IN_MODE = 0; // Dead Band Input Select Mode Control
3023 EPwm3Regs.DBCTL.bit.POLSEL = 2; // Polarity Select Control
3024 EPwm3Regs.DBCTL.bit.HALFCYCLE = 0; // Half Cycle Clocking Enable
3025 */
3026 EPwm3Regs.DBCTL.all = (EPwm3Regs.DBCTL.all & ~0x803F) | 0xB;
3027 EPwm3Regs.DBRED.bit.DBRED = 0; // Dead-Band Generator Rising Edge Delay Count Register
3028 EPwm3Regs.DBFED.bit.DBFED = 0; // Dead-Band Generator Falling Edge Delay Count Register
3029
3030 /*-- Setup Event-Trigger (ET) Submodule --*/
3031 /* // Event Trigger Selection and Pre-Scale Register
3032 EPwm3Regs.ETSEL.bit.SOCAEN = 0; // Start of Conversion A Enable
3033 EPwm3Regs.ETSEL.bit.SOCASELCMP = 0;
3034 EPwm3Regs.ETSEL.bit.SOCASEL = 0 ; // Start of Conversion A Select
3035 EPwm3Regs.ETPS.bit.SOCAPRD = 1; // EPWM3SOCA Period Select
3036
3037 EPwm3Regs.ETSEL.bit.SOCBEN = 0; // Start of Conversion B Enable
3038
3039 EPwm3Regs.ETSEL.bit.SOCBSELCMP = 0;
3040 EPwm3Regs.ETSEL.bit.SOCBSEL = 1; // Start of Conversion A Select
3041 EPwm3Regs.ETPS.bit.SOCBPRD = 1; // EPWM3SOCB Period Select
3042 EPwm3Regs.ETSEL.bit.INTEN = 0; // EPWM3INTn Enable
3043 EPwm3Regs.ETSEL.bit.INTSELCMP = 0;
3044 EPwm3Regs.ETSEL.bit.INTSEL = 1; // Start of Conversion A Select
3045
3046 EPwm3Regs.ETPS.bit.INTPRD = 1; // EPWM3INTn Period Select
3047 */
3048 EPwm3Regs.ETSEL.all = (EPwm3Regs.ETSEL.all & ~0xFF7F) | 0x1001;
3049 EPwm3Regs.ETPS.all = (EPwm3Regs.ETPS.all & ~0x3303) | 0x1101;
3050
3051 /*-- Setup PWM-Chopper (PC) Submodule --*/
3052 /* // PWM Chopper Control Register
3053 EPwm3Regs.PCCTL.bit.CHPEN = 0; // PWM chopping enable
3054 EPwm3Regs.PCCTL.bit.CHPFREQ = 0; // Chopping clock frequency
3055 EPwm3Regs.PCCTL.bit.OSHTWTH = 0; // One-shot pulse width
3056 EPwm3Regs.PCCTL.bit.CHPDUTY = 0; // Chopping clock Duty cycle
3057 */
3058 EPwm3Regs.PCCTL.all = (EPwm3Regs.PCCTL.all & ~0x7FF) | 0x0;
3059
3060 /*-- Set up Trip-Zone (TZ) Submodule --*/
3061 EALLOW;
3062 EPwm3Regs.TZSEL.all = 0; // Trip Zone Select Register
3063
3064 /* // Trip Zone Control Register
3065 EPwm3Regs.TZCTL.bit.TZA = 3; // TZ1 to TZ6 Trip Action On EPWM3A
3066 EPwm3Regs.TZCTL.bit.TZB = 3; // TZ1 to TZ6 Trip Action On EPWM3B
3067 EPwm3Regs.TZCTL.bit.DCAEVT1 = 3; // EPWM3A action on DCAEVT1
3068 EPwm3Regs.TZCTL.bit.DCAEVT2 = 3; // EPWM3A action on DCAEVT2
3069 EPwm3Regs.TZCTL.bit.DCBEVT1 = 3; // EPWM3B action on DCBEVT1
3070 EPwm3Regs.TZCTL.bit.DCBEVT2 = 3; // EPWM3B action on DCBEVT2
3071 */
3072 EPwm3Regs.TZCTL.all = (EPwm3Regs.TZCTL.all & ~0xFFF) | 0xFFF;
3073
3074 /* // Trip Zone Enable Interrupt Register
3075 EPwm3Regs.TZEINT.bit.OST = 0; // Trip Zones One Shot Int Enable
3076 EPwm3Regs.TZEINT.bit.CBC = 0; // Trip Zones Cycle By Cycle Int Enable
3077 EPwm3Regs.TZEINT.bit.DCAEVT1 = 0; // Digital Compare A Event 1 Int Enable
3078 EPwm3Regs.TZEINT.bit.DCAEVT2 = 0; // Digital Compare A Event 2 Int Enable
3079 EPwm3Regs.TZEINT.bit.DCBEVT1 = 0; // Digital Compare B Event 1 Int Enable
3080 EPwm3Regs.TZEINT.bit.DCBEVT2 = 0; // Digital Compare B Event 2 Int Enable
3081 */
3082 EPwm3Regs.TZEINT.all = (EPwm3Regs.TZEINT.all & ~0x7E) | 0x0;
3083
3084 /* // Digital Compare A Control Register
3085 EPwm3Regs.DCACTL.bit.EVT1SYNCE = 0; // DCAEVT1 SYNC Enable
3086 EPwm3Regs.DCACTL.bit.EVT1SOCE = 1; // DCAEVT1 SOC Enable
3087 EPwm3Regs.DCACTL.bit.EVT1FRCSYNCSEL = 0; // DCAEVT1 Force Sync Signal
3088 EPwm3Regs.DCACTL.bit.EVT1SRCSEL = 0; // DCAEVT1 Source Signal
3089 EPwm3Regs.DCACTL.bit.EVT2FRCSYNCSEL = 0; // DCAEVT2 Force Sync Signal
3090 EPwm3Regs.DCACTL.bit.EVT2SRCSEL = 0; // DCAEVT2 Source Signal
3091 */
3092 EPwm3Regs.DCACTL.all = (EPwm3Regs.DCACTL.all & ~0x30F) | 0x4;
3093
3094 /* // Digital Compare B Control Register
3095 EPwm3Regs.DCBCTL.bit.EVT1SYNCE = 0; // DCBEVT1 SYNC Enable
3096 EPwm3Regs.DCBCTL.bit.EVT1SOCE = 0; // DCBEVT1 SOC Enable
3097 EPwm3Regs.DCBCTL.bit.EVT1FRCSYNCSEL = 0; // DCBEVT1 Force Sync Signal
3098 EPwm3Regs.DCBCTL.bit.EVT1SRCSEL = 0; // DCBEVT1 Source Signal
3099 EPwm3Regs.DCBCTL.bit.EVT2FRCSYNCSEL = 0; // DCBEVT2 Force Sync Signal
3100 EPwm3Regs.DCBCTL.bit.EVT2SRCSEL = 0; // DCBEVT2 Source Signal
3101 */
3102 EPwm3Regs.DCBCTL.all = (EPwm3Regs.DCBCTL.all & ~0x30F) | 0x0;
3103
3104 /* // Digital Compare Trip Select Register
3105 EPwm3Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 0; // Digital Compare A High COMP Input Select
3106
3107 EPwm3Regs.DCTRIPSEL.bit.DCALCOMPSEL = 1; // Digital Compare A Low COMP Input Select
3108 EPwm3Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 0; // Digital Compare B High COMP Input Select
3109 EPwm3Regs.DCTRIPSEL.bit.DCBLCOMPSEL = 1; // Digital Compare B Low COMP Input Select
3110
3111
3112
3113
3114
3115 */
3116 EPwm3Regs.DCTRIPSEL.all = (EPwm3Regs.DCTRIPSEL.all & ~ 0xFFFF) | 0x1010;
3117
3118 /* // Trip Zone Digital Comparator Select Register
3119 EPwm3Regs.TZDCSEL.bit.DCAEVT1 = 0; // Digital Compare Output A Event 1
3120 EPwm3Regs.TZDCSEL.bit.DCAEVT2 = 0; // Digital Compare Output A Event 2
3121 EPwm3Regs.TZDCSEL.bit.DCBEVT1 = 0; // Digital Compare Output B Event 1
3122 EPwm3Regs.TZDCSEL.bit.DCBEVT2 = 0; // Digital Compare Output B Event 2
3123 */
3124 EPwm3Regs.TZDCSEL.all = (EPwm3Regs.TZDCSEL.all & ~0xFFF) | 0x0;
3125
3126 /* // Digital Compare Filter Control Register
3127 EPwm3Regs.DCFCTL.bit.BLANKE = 0; // Blanking Enable/Disable
3128 EPwm3Regs.DCFCTL.bit.PULSESEL = 1; // Pulse Select for Blanking & Capture Alignment
3129 EPwm3Regs.DCFCTL.bit.BLANKINV = 0; // Blanking Window Inversion
3130 EPwm3Regs.DCFCTL.bit.SRCSEL = 0; // Filter Block Signal Source Select
3131 */
3132 EPwm3Regs.DCFCTL.all = (EPwm3Regs.DCFCTL.all & ~0x3F) | 0x10;
3133 EPwm3Regs.DCFOFFSET = 0; // Digital Compare Filter Offset Register
3134 EPwm3Regs.DCFWINDOW = 0; // Digital Compare Filter Window Register
3135
3136 /* // Digital Compare Capture Control Register
3137 EPwm3Regs.DCCAPCTL.bit.CAPE = 0; // Counter Capture Enable
3138 */
3139 EPwm3Regs.DCCAPCTL.all = (EPwm3Regs.DCCAPCTL.all & ~0x1) | 0x0;
3140
3141 /* // HRPWM Configuration Register
3142 EPwm3Regs.HRCNFG.bit.SWAPAB = 0; // Swap EPWMA and EPWMB Outputs Bit
3143 EPwm3Regs.HRCNFG.bit.SELOUTB = 0; // EPWMB Output Selection Bit
3144 */
3145 EPwm3Regs.HRCNFG.all = (EPwm3Regs.HRCNFG.all & ~0xA0) | 0x0;
3146
3147 /* Update the Link Registers with the link value for all the Compare values and TBPRD */
3148 /* No error is thrown if the ePWM register exists in the model or not */
3149 EPwm3Regs.EPWMXLINK.bit.TBPRDLINK = 2;
3150 EPwm3Regs.EPWMXLINK.bit.CMPALINK = 2;
3151 EPwm3Regs.EPWMXLINK.bit.CMPBLINK = 2;
3152 EPwm3Regs.EPWMXLINK.bit.CMPCLINK = 2;
3153 EPwm3Regs.EPWMXLINK.bit.CMPDLINK = 2;
3154 EDIS;
3155 EALLOW;
3156 CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
3157 EDIS;
3158 }
3159
3160 /* Start for S-Function (c2802xpwm): '<S4>/ePWM2' incorporates:
3161 * Constant: '<Root>/Constant2'
3162 */
3163 EALLOW;
3164 CpuSysRegs.PCLKCR2.bit.EPWM6 = 1;
3165 CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
3166 EDIS;
3167
3168 /*** Initialize ePWM6 modules ***/
3169 {
3170 /* // Time Base Control Register
3171 EPwm6Regs.TBCTL.bit.CTRMODE = 2; // Counter Mode
3172 EPwm6Regs.TBCTL.bit.SYNCOSEL = 3; // Sync Output Select
3173 EPwm6Regs.TBCTL.bit.PRDLD = 0; // Shadow select
3174 EPwm6Regs.TBCTL.bit.PHSEN = 0; // Phase Load Enable
3175 EPwm6Regs.TBCTL.bit.PHSDIR = 0; // Phase Direction Bit
3176 EPwm6Regs.TBCTL.bit.HSPCLKDIV = 0; // High Speed TBCLK Pre-scaler
3177 EPwm6Regs.TBCTL.bit.CLKDIV = 0; // Time Base Clock Pre-scaler
3178 EPwm6Regs.TBCTL.bit.SWFSYNC = 0; // Software Force Sync Pulse
3179 */
3180 EPwm6Regs.TBCTL.all = (EPwm6Regs.TBCTL.all & ~0x3FFF) | 0x32;
3181
3182 /*-- Setup Time-Base (TB) Submodule --*/
3183 EPwm6Regs.TBPRD = 12500; // Time Base Period Register
3184
3185 /* // Time-Base Phase Register
3186 EPwm6Regs.TBPHS.bit.TBPHS = 0; // Phase offset register
3187 */
3188 EPwm6Regs.TBPHS.all = (EPwm6Regs.TBPHS.all & ~0xFFFF0000) | 0x0;
3189
3190 // Time Base Counter Register
3191 EPwm6Regs.TBCTR = 0x0000; /* Clear counter*/
3192
3193 /*-- Setup Counter_Compare (CC) Submodule --*/
3194 /* // Counter Compare Control Register
3195 EPwm6Regs.CMPCTL.bit.SHDWAMODE = 0; // Compare A Register Block Operating Mode
3196 EPwm6Regs.CMPCTL.bit.SHDWBMODE = 0; // Compare B Register Block Operating Mode
3197 EPwm6Regs.CMPCTL.bit.LOADAMODE = 0; // Active Compare A Load
3198 EPwm6Regs.CMPCTL.bit.LOADBMODE = 0; // Active Compare B Load
3199 */
3200 EPwm6Regs.CMPCTL.all = (EPwm6Regs.CMPCTL.all & ~0x5F) | 0x0;
3201
3202 /* EPwm6Regs.CMPCTL2.bit.SHDWCMODE = 0; // Compare C Register Block Operating Mode
3203
3204 EPwm6Regs.CMPCTL2.bit.SHDWDMODE = 0; // Compare D Register Block Operating Mode
3205 */
3206 EPwm6Regs.CMPCTL2.all = (EPwm6Regs.CMPCTL2.all & ~0x50) | 0x0;
3207 EPwm6Regs.CMPA.bit.CMPA = 3750; // Counter Compare A Register
3208 EPwm6Regs.CMPB.bit.CMPB = 3750; // Counter Compare B Register
3209 EPwm6Regs.CMPC = 32000; // Counter Compare C Register
3210 EPwm6Regs.CMPD = 32000; // Counter Compare D Register
3211
3212 /*-- Setup Action-Qualifier (AQ) Submodule --*/
3213 EPwm6Regs.AQCTLA.all = 150; // Action Qualifier Control Register For Output A
3214 EPwm6Regs.AQCTLB.all = 1545; // Action Qualifier Control Register For Output B
3215
3216 /* // Action Qualifier Software Force Register
3217 EPwm6Regs.AQSFRC.bit.RLDCSF = 0; // Reload from Shadow Options
3218 */
3219 EPwm6Regs.AQSFRC.all = (EPwm6Regs.AQSFRC.all & ~0xC0) | 0x0;
3220
3221 /* // Action Qualifier Continuous S/W Force Register
3222 EPwm6Regs.AQCSFRC.bit.CSFA = 0; // Continuous Software Force on output A
3223 EPwm6Regs.AQCSFRC.bit.CSFB = 0; // Continuous Software Force on output B
3224 */
3225 EPwm6Regs.AQCSFRC.all = (EPwm6Regs.AQCSFRC.all & ~0xF) | 0x0;
3226
3227 /*-- Setup Dead-Band Generator (DB) Submodule --*/
3228 /* // Dead-Band Generator Control Register
3229 EPwm6Regs.DBCTL.bit.OUT_MODE = 3; // Dead Band Output Mode Control
3230 EPwm6Regs.DBCTL.bit.IN_MODE = 0; // Dead Band Input Select Mode Control
3231 EPwm6Regs.DBCTL.bit.POLSEL = 2; // Polarity Select Control
3232 EPwm6Regs.DBCTL.bit.HALFCYCLE = 0; // Half Cycle Clocking Enable
3233 */
3234 EPwm6Regs.DBCTL.all = (EPwm6Regs.DBCTL.all & ~0x803F) | 0xB;
3235 EPwm6Regs.DBRED.bit.DBRED = 0; // Dead-Band Generator Rising Edge Delay Count Register
3236 EPwm6Regs.DBFED.bit.DBFED = 0; // Dead-Band Generator Falling Edge Delay Count Register
3237
3238 /*-- Setup Event-Trigger (ET) Submodule --*/
3239 /* // Event Trigger Selection and Pre-Scale Register
3240 EPwm6Regs.ETSEL.bit.SOCAEN = 0; // Start of Conversion A Enable
3241 EPwm6Regs.ETSEL.bit.SOCASELCMP = 0;
3242 EPwm6Regs.ETSEL.bit.SOCASEL = 0 ; // Start of Conversion A Select
3243 EPwm6Regs.ETPS.bit.SOCAPRD = 1; // EPWM6SOCA Period Select
3244
3245 EPwm6Regs.ETSEL.bit.SOCBEN = 0; // Start of Conversion B Enable
3246
3247 EPwm6Regs.ETSEL.bit.SOCBSELCMP = 0;
3248 EPwm6Regs.ETSEL.bit.SOCBSEL = 1; // Start of Conversion A Select
3249 EPwm6Regs.ETPS.bit.SOCBPRD = 1; // EPWM6SOCB Period Select
3250 EPwm6Regs.ETSEL.bit.INTEN = 0; // EPWM6INTn Enable
3251 EPwm6Regs.ETSEL.bit.INTSELCMP = 0;
3252 EPwm6Regs.ETSEL.bit.INTSEL = 1; // Start of Conversion A Select
3253
3254 EPwm6Regs.ETPS.bit.INTPRD = 1; // EPWM6INTn Period Select
3255 */
3256 EPwm6Regs.ETSEL.all = (EPwm6Regs.ETSEL.all & ~0xFF7F) | 0x1001;
3257 EPwm6Regs.ETPS.all = (EPwm6Regs.ETPS.all & ~0x3303) | 0x1101;
3258
3259 /*-- Setup PWM-Chopper (PC) Submodule --*/
3260 /* // PWM Chopper Control Register
3261 EPwm6Regs.PCCTL.bit.CHPEN = 0; // PWM chopping enable
3262 EPwm6Regs.PCCTL.bit.CHPFREQ = 0; // Chopping clock frequency
3263 EPwm6Regs.PCCTL.bit.OSHTWTH = 0; // One-shot pulse width
3264 EPwm6Regs.PCCTL.bit.CHPDUTY = 0; // Chopping clock Duty cycle
3265 */
3266 EPwm6Regs.PCCTL.all = (EPwm6Regs.PCCTL.all & ~0x7FF) | 0x0;
3267
3268 /*-- Set up Trip-Zone (TZ) Submodule --*/
3269 EALLOW;
3270 EPwm6Regs.TZSEL.all = 0; // Trip Zone Select Register
3271
3272 /* // Trip Zone Control Register
3273 EPwm6Regs.TZCTL.bit.TZA = 3; // TZ1 to TZ6 Trip Action On EPWM6A
3274 EPwm6Regs.TZCTL.bit.TZB = 3; // TZ1 to TZ6 Trip Action On EPWM6B
3275 EPwm6Regs.TZCTL.bit.DCAEVT1 = 3; // EPWM6A action on DCAEVT1
3276 EPwm6Regs.TZCTL.bit.DCAEVT2 = 3; // EPWM6A action on DCAEVT2
3277 EPwm6Regs.TZCTL.bit.DCBEVT1 = 3; // EPWM6B action on DCBEVT1
3278 EPwm6Regs.TZCTL.bit.DCBEVT2 = 3; // EPWM6B action on DCBEVT2
3279 */
3280 EPwm6Regs.TZCTL.all = (EPwm6Regs.TZCTL.all & ~0xFFF) | 0xFFF;
3281
3282 /* // Trip Zone Enable Interrupt Register
3283 EPwm6Regs.TZEINT.bit.OST = 0; // Trip Zones One Shot Int Enable
3284 EPwm6Regs.TZEINT.bit.CBC = 0; // Trip Zones Cycle By Cycle Int Enable
3285 EPwm6Regs.TZEINT.bit.DCAEVT1 = 0; // Digital Compare A Event 1 Int Enable
3286 EPwm6Regs.TZEINT.bit.DCAEVT2 = 0; // Digital Compare A Event 2 Int Enable
3287 EPwm6Regs.TZEINT.bit.DCBEVT1 = 0; // Digital Compare B Event 1 Int Enable
3288 EPwm6Regs.TZEINT.bit.DCBEVT2 = 0; // Digital Compare B Event 2 Int Enable
3289 */
3290 EPwm6Regs.TZEINT.all = (EPwm6Regs.TZEINT.all & ~0x7E) | 0x0;
3291
3292 /* // Digital Compare A Control Register
3293 EPwm6Regs.DCACTL.bit.EVT1SYNCE = 0; // DCAEVT1 SYNC Enable
3294 EPwm6Regs.DCACTL.bit.EVT1SOCE = 1; // DCAEVT1 SOC Enable
3295 EPwm6Regs.DCACTL.bit.EVT1FRCSYNCSEL = 0; // DCAEVT1 Force Sync Signal
3296 EPwm6Regs.DCACTL.bit.EVT1SRCSEL = 0; // DCAEVT1 Source Signal
3297 EPwm6Regs.DCACTL.bit.EVT2FRCSYNCSEL = 0; // DCAEVT2 Force Sync Signal
3298 EPwm6Regs.DCACTL.bit.EVT2SRCSEL = 0; // DCAEVT2 Source Signal
3299 */
3300 EPwm6Regs.DCACTL.all = (EPwm6Regs.DCACTL.all & ~0x30F) | 0x4;
3301
3302 /* // Digital Compare B Control Register
3303 EPwm6Regs.DCBCTL.bit.EVT1SYNCE = 0; // DCBEVT1 SYNC Enable
3304 EPwm6Regs.DCBCTL.bit.EVT1SOCE = 0; // DCBEVT1 SOC Enable
3305 EPwm6Regs.DCBCTL.bit.EVT1FRCSYNCSEL = 0; // DCBEVT1 Force Sync Signal
3306 EPwm6Regs.DCBCTL.bit.EVT1SRCSEL = 0; // DCBEVT1 Source Signal
3307 EPwm6Regs.DCBCTL.bit.EVT2FRCSYNCSEL = 0; // DCBEVT2 Force Sync Signal
3308 EPwm6Regs.DCBCTL.bit.EVT2SRCSEL = 0; // DCBEVT2 Source Signal
3309 */
3310 EPwm6Regs.DCBCTL.all = (EPwm6Regs.DCBCTL.all & ~0x30F) | 0x0;
3311
3312 /* // Digital Compare Trip Select Register
3313 EPwm6Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 0; // Digital Compare A High COMP Input Select
3314
3315 EPwm6Regs.DCTRIPSEL.bit.DCALCOMPSEL = 1; // Digital Compare A Low COMP Input Select
3316 EPwm6Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 0; // Digital Compare B High COMP Input Select
3317 EPwm6Regs.DCTRIPSEL.bit.DCBLCOMPSEL = 1; // Digital Compare B Low COMP Input Select
3318
3319
3320
3321
3322
3323 */
3324 EPwm6Regs.DCTRIPSEL.all = (EPwm6Regs.DCTRIPSEL.all & ~ 0xFFFF) | 0x1010;
3325
3326 /* // Trip Zone Digital Comparator Select Register
3327 EPwm6Regs.TZDCSEL.bit.DCAEVT1 = 0; // Digital Compare Output A Event 1
3328 EPwm6Regs.TZDCSEL.bit.DCAEVT2 = 0; // Digital Compare Output A Event 2
3329 EPwm6Regs.TZDCSEL.bit.DCBEVT1 = 0; // Digital Compare Output B Event 1
3330 EPwm6Regs.TZDCSEL.bit.DCBEVT2 = 0; // Digital Compare Output B Event 2
3331 */
3332 EPwm6Regs.TZDCSEL.all = (EPwm6Regs.TZDCSEL.all & ~0xFFF) | 0x0;
3333
3334 /* // Digital Compare Filter Control Register
3335 EPwm6Regs.DCFCTL.bit.BLANKE = 0; // Blanking Enable/Disable
3336 EPwm6Regs.DCFCTL.bit.PULSESEL = 1; // Pulse Select for Blanking & Capture Alignment
3337 EPwm6Regs.DCFCTL.bit.BLANKINV = 0; // Blanking Window Inversion
3338 EPwm6Regs.DCFCTL.bit.SRCSEL = 0; // Filter Block Signal Source Select
3339 */
3340 EPwm6Regs.DCFCTL.all = (EPwm6Regs.DCFCTL.all & ~0x3F) | 0x10;
3341 EPwm6Regs.DCFOFFSET = 0; // Digital Compare Filter Offset Register
3342 EPwm6Regs.DCFWINDOW = 0; // Digital Compare Filter Window Register
3343
3344 /* // Digital Compare Capture Control Register
3345 EPwm6Regs.DCCAPCTL.bit.CAPE = 0; // Counter Capture Enable
3346 */
3347 EPwm6Regs.DCCAPCTL.all = (EPwm6Regs.DCCAPCTL.all & ~0x1) | 0x0;
3348
3349 /* // HRPWM Configuration Register
3350 EPwm6Regs.HRCNFG.bit.SWAPAB = 0; // Swap EPWMA and EPWMB Outputs Bit
3351 EPwm6Regs.HRCNFG.bit.SELOUTB = 0; // EPWMB Output Selection Bit
3352 */
3353 EPwm6Regs.HRCNFG.all = (EPwm6Regs.HRCNFG.all & ~0xA0) | 0x0;
3354
3355 /* Update the Link Registers with the link value for all the Compare values and TBPRD */
3356 /* No error is thrown if the ePWM register exists in the model or not */
3357 EPwm6Regs.EPWMXLINK.bit.TBPRDLINK = 5;
3358 EPwm6Regs.EPWMXLINK.bit.CMPALINK = 5;
3359 EPwm6Regs.EPWMXLINK.bit.CMPBLINK = 5;
3360 EPwm6Regs.EPWMXLINK.bit.CMPCLINK = 5;
3361 EPwm6Regs.EPWMXLINK.bit.CMPDLINK = 5;
3362 EDIS;
3363 EALLOW;
3364 CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
3365 EDIS;
3366 }
3367
3368 /* Start for S-Function (c2802xpwm): '<S4>/ePWM3' incorporates:
3369 * Constant: '<Root>/Constant2'
3370 */
3371 EALLOW;
3372 CpuSysRegs.PCLKCR2.bit.EPWM4 = 1;
3373 CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 0;
3374 EDIS;
3375
3376 /*** Initialize ePWM4 modules ***/
3377 {
3378 /* // Time Base Control Register
3379 EPwm4Regs.TBCTL.bit.CTRMODE = 2; // Counter Mode
3380 EPwm4Regs.TBCTL.bit.SYNCOSEL = 3; // Sync Output Select
3381 EPwm4Regs.TBCTL.bit.PRDLD = 0; // Shadow select
3382 EPwm4Regs.TBCTL.bit.PHSEN = 0; // Phase Load Enable
3383 EPwm4Regs.TBCTL.bit.PHSDIR = 0; // Phase Direction Bit
3384 EPwm4Regs.TBCTL.bit.HSPCLKDIV = 0; // High Speed TBCLK Pre-scaler
3385 EPwm4Regs.TBCTL.bit.CLKDIV = 0; // Time Base Clock Pre-scaler
3386 EPwm4Regs.TBCTL.bit.SWFSYNC = 0; // Software Force Sync Pulse
3387 */
3388 EPwm4Regs.TBCTL.all = (EPwm4Regs.TBCTL.all & ~0x3FFF) | 0x32;
3389
3390 /*-- Setup Time-Base (TB) Submodule --*/
3391 EPwm4Regs.TBPRD = 12500; // Time Base Period Register
3392
3393 /* // Time-Base Phase Register
3394 EPwm4Regs.TBPHS.bit.TBPHS = 0; // Phase offset register
3395 */
3396 EPwm4Regs.TBPHS.all = (EPwm4Regs.TBPHS.all & ~0xFFFF0000) | 0x0;
3397
3398 // Time Base Counter Register
3399 EPwm4Regs.TBCTR = 0x0000; /* Clear counter*/
3400
3401 /*-- Setup Counter_Compare (CC) Submodule --*/
3402 /* // Counter Compare Control Register
3403 EPwm4Regs.CMPCTL.bit.SHDWAMODE = 0; // Compare A Register Block Operating Mode
3404 EPwm4Regs.CMPCTL.bit.SHDWBMODE = 0; // Compare B Register Block Operating Mode
3405 EPwm4Regs.CMPCTL.bit.LOADAMODE = 0; // Active Compare A Load
3406 EPwm4Regs.CMPCTL.bit.LOADBMODE = 0; // Active Compare B Load
3407 */
3408 EPwm4Regs.CMPCTL.all = (EPwm4Regs.CMPCTL.all & ~0x5F) | 0x0;
3409
3410 /* EPwm4Regs.CMPCTL2.bit.SHDWCMODE = 0; // Compare C Register Block Operating Mode
3411
3412 EPwm4Regs.CMPCTL2.bit.SHDWDMODE = 0; // Compare D Register Block Operating Mode
3413 */
3414 EPwm4Regs.CMPCTL2.all = (EPwm4Regs.CMPCTL2.all & ~0x50) | 0x0;
3415 EPwm4Regs.CMPA.bit.CMPA = 3750; // Counter Compare A Register
3416 EPwm4Regs.CMPB.bit.CMPB = 3750; // Counter Compare B Register
3417 EPwm4Regs.CMPC = 32000; // Counter Compare C Register
3418 EPwm4Regs.CMPD = 32000; // Counter Compare D Register
3419
3420 /*-- Setup Action-Qualifier (AQ) Submodule --*/
3421 EPwm4Regs.AQCTLA.all = 150; // Action Qualifier Control Register For Output A
3422 EPwm4Regs.AQCTLB.all = 1545; // Action Qualifier Control Register For Output B
3423
3424 /* // Action Qualifier Software Force Register
3425 EPwm4Regs.AQSFRC.bit.RLDCSF = 0; // Reload from Shadow Options
3426 */
3427 EPwm4Regs.AQSFRC.all = (EPwm4Regs.AQSFRC.all & ~0xC0) | 0x0;
3428
3429 /* // Action Qualifier Continuous S/W Force Register
3430 EPwm4Regs.AQCSFRC.bit.CSFA = 0; // Continuous Software Force on output A
3431 EPwm4Regs.AQCSFRC.bit.CSFB = 0; // Continuous Software Force on output B
3432 */
3433 EPwm4Regs.AQCSFRC.all = (EPwm4Regs.AQCSFRC.all & ~0xF) | 0x0;
3434
3435 /*-- Setup Dead-Band Generator (DB) Submodule --*/
3436 /* // Dead-Band Generator Control Register
3437 EPwm4Regs.DBCTL.bit.OUT_MODE = 3; // Dead Band Output Mode Control
3438 EPwm4Regs.DBCTL.bit.IN_MODE = 0; // Dead Band Input Select Mode Control
3439 EPwm4Regs.DBCTL.bit.POLSEL = 2; // Polarity Select Control
3440 EPwm4Regs.DBCTL.bit.HALFCYCLE = 0; // Half Cycle Clocking Enable
3441 */
3442 EPwm4Regs.DBCTL.all = (EPwm4Regs.DBCTL.all & ~0x803F) | 0xB;
3443 EPwm4Regs.DBRED.bit.DBRED = 0; // Dead-Band Generator Rising Edge Delay Count Register
3444 EPwm4Regs.DBFED.bit.DBFED = 0; // Dead-Band Generator Falling Edge Delay Count Register
3445
3446 /*-- Setup Event-Trigger (ET) Submodule --*/
3447 /* // Event Trigger Selection and Pre-Scale Register
3448 EPwm4Regs.ETSEL.bit.SOCAEN = 0; // Start of Conversion A Enable
3449 EPwm4Regs.ETSEL.bit.SOCASELCMP = 0;
3450 EPwm4Regs.ETSEL.bit.SOCASEL = 0 ; // Start of Conversion A Select
3451 EPwm4Regs.ETPS.bit.SOCAPRD = 1; // EPWM4SOCA Period Select
3452
3453 EPwm4Regs.ETSEL.bit.SOCBEN = 0; // Start of Conversion B Enable
3454
3455 EPwm4Regs.ETSEL.bit.SOCBSELCMP = 0;
3456 EPwm4Regs.ETSEL.bit.SOCBSEL = 1; // Start of Conversion A Select
3457 EPwm4Regs.ETPS.bit.SOCBPRD = 1; // EPWM4SOCB Period Select
3458 EPwm4Regs.ETSEL.bit.INTEN = 0; // EPWM4INTn Enable
3459 EPwm4Regs.ETSEL.bit.INTSELCMP = 0;
3460 EPwm4Regs.ETSEL.bit.INTSEL = 1; // Start of Conversion A Select
3461
3462 EPwm4Regs.ETPS.bit.INTPRD = 1; // EPWM4INTn Period Select
3463 */
3464 EPwm4Regs.ETSEL.all = (EPwm4Regs.ETSEL.all & ~0xFF7F) | 0x1001;
3465 EPwm4Regs.ETPS.all = (EPwm4Regs.ETPS.all & ~0x3303) | 0x1101;
3466
3467 /*-- Setup PWM-Chopper (PC) Submodule --*/
3468 /* // PWM Chopper Control Register
3469 EPwm4Regs.PCCTL.bit.CHPEN = 0; // PWM chopping enable
3470 EPwm4Regs.PCCTL.bit.CHPFREQ = 0; // Chopping clock frequency
3471 EPwm4Regs.PCCTL.bit.OSHTWTH = 0; // One-shot pulse width
3472 EPwm4Regs.PCCTL.bit.CHPDUTY = 0; // Chopping clock Duty cycle
3473 */
3474 EPwm4Regs.PCCTL.all = (EPwm4Regs.PCCTL.all & ~0x7FF) | 0x0;
3475
3476 /*-- Set up Trip-Zone (TZ) Submodule --*/
3477 EALLOW;
3478 EPwm4Regs.TZSEL.all = 0; // Trip Zone Select Register
3479
3480 /* // Trip Zone Control Register
3481 EPwm4Regs.TZCTL.bit.TZA = 3; // TZ1 to TZ6 Trip Action On EPWM4A
3482 EPwm4Regs.TZCTL.bit.TZB = 3; // TZ1 to TZ6 Trip Action On EPWM4B
3483 EPwm4Regs.TZCTL.bit.DCAEVT1 = 3; // EPWM4A action on DCAEVT1
3484 EPwm4Regs.TZCTL.bit.DCAEVT2 = 3; // EPWM4A action on DCAEVT2
3485 EPwm4Regs.TZCTL.bit.DCBEVT1 = 3; // EPWM4B action on DCBEVT1
3486 EPwm4Regs.TZCTL.bit.DCBEVT2 = 3; // EPWM4B action on DCBEVT2
3487 */
3488 EPwm4Regs.TZCTL.all = (EPwm4Regs.TZCTL.all & ~0xFFF) | 0xFFF;
3489
3490 /* // Trip Zone Enable Interrupt Register
3491 EPwm4Regs.TZEINT.bit.OST = 0; // Trip Zones One Shot Int Enable
3492 EPwm4Regs.TZEINT.bit.CBC = 0; // Trip Zones Cycle By Cycle Int Enable
3493 EPwm4Regs.TZEINT.bit.DCAEVT1 = 0; // Digital Compare A Event 1 Int Enable
3494 EPwm4Regs.TZEINT.bit.DCAEVT2 = 0; // Digital Compare A Event 2 Int Enable
3495 EPwm4Regs.TZEINT.bit.DCBEVT1 = 0; // Digital Compare B Event 1 Int Enable
3496 EPwm4Regs.TZEINT.bit.DCBEVT2 = 0; // Digital Compare B Event 2 Int Enable
3497 */
3498 EPwm4Regs.TZEINT.all = (EPwm4Regs.TZEINT.all & ~0x7E) | 0x0;
3499
3500 /* // Digital Compare A Control Register
3501 EPwm4Regs.DCACTL.bit.EVT1SYNCE = 0; // DCAEVT1 SYNC Enable
3502 EPwm4Regs.DCACTL.bit.EVT1SOCE = 1; // DCAEVT1 SOC Enable
3503 EPwm4Regs.DCACTL.bit.EVT1FRCSYNCSEL = 0; // DCAEVT1 Force Sync Signal
3504 EPwm4Regs.DCACTL.bit.EVT1SRCSEL = 0; // DCAEVT1 Source Signal
3505 EPwm4Regs.DCACTL.bit.EVT2FRCSYNCSEL = 0; // DCAEVT2 Force Sync Signal
3506 EPwm4Regs.DCACTL.bit.EVT2SRCSEL = 0; // DCAEVT2 Source Signal
3507 */
3508 EPwm4Regs.DCACTL.all = (EPwm4Regs.DCACTL.all & ~0x30F) | 0x4;
3509
3510 /* // Digital Compare B Control Register
3511 EPwm4Regs.DCBCTL.bit.EVT1SYNCE = 0; // DCBEVT1 SYNC Enable
3512 EPwm4Regs.DCBCTL.bit.EVT1SOCE = 0; // DCBEVT1 SOC Enable
3513 EPwm4Regs.DCBCTL.bit.EVT1FRCSYNCSEL = 0; // DCBEVT1 Force Sync Signal
3514 EPwm4Regs.DCBCTL.bit.EVT1SRCSEL = 0; // DCBEVT1 Source Signal
3515 EPwm4Regs.DCBCTL.bit.EVT2FRCSYNCSEL = 0; // DCBEVT2 Force Sync Signal
3516 EPwm4Regs.DCBCTL.bit.EVT2SRCSEL = 0; // DCBEVT2 Source Signal
3517 */
3518 EPwm4Regs.DCBCTL.all = (EPwm4Regs.DCBCTL.all & ~0x30F) | 0x0;
3519
3520 /* // Digital Compare Trip Select Register
3521 EPwm4Regs.DCTRIPSEL.bit.DCAHCOMPSEL = 0; // Digital Compare A High COMP Input Select
3522
3523 EPwm4Regs.DCTRIPSEL.bit.DCALCOMPSEL = 1; // Digital Compare A Low COMP Input Select
3524 EPwm4Regs.DCTRIPSEL.bit.DCBHCOMPSEL = 0; // Digital Compare B High COMP Input Select
3525 EPwm4Regs.DCTRIPSEL.bit.DCBLCOMPSEL = 1; // Digital Compare B Low COMP Input Select
3526
3527
3528
3529
3530
3531 */
3532 EPwm4Regs.DCTRIPSEL.all = (EPwm4Regs.DCTRIPSEL.all & ~ 0xFFFF) | 0x1010;
3533
3534 /* // Trip Zone Digital Comparator Select Register
3535 EPwm4Regs.TZDCSEL.bit.DCAEVT1 = 0; // Digital Compare Output A Event 1
3536 EPwm4Regs.TZDCSEL.bit.DCAEVT2 = 0; // Digital Compare Output A Event 2
3537 EPwm4Regs.TZDCSEL.bit.DCBEVT1 = 0; // Digital Compare Output B Event 1
3538 EPwm4Regs.TZDCSEL.bit.DCBEVT2 = 0; // Digital Compare Output B Event 2
3539 */
3540 EPwm4Regs.TZDCSEL.all = (EPwm4Regs.TZDCSEL.all & ~0xFFF) | 0x0;
3541
3542 /* // Digital Compare Filter Control Register
3543 EPwm4Regs.DCFCTL.bit.BLANKE = 0; // Blanking Enable/Disable
3544 EPwm4Regs.DCFCTL.bit.PULSESEL = 1; // Pulse Select for Blanking & Capture Alignment
3545 EPwm4Regs.DCFCTL.bit.BLANKINV = 0; // Blanking Window Inversion
3546 EPwm4Regs.DCFCTL.bit.SRCSEL = 0; // Filter Block Signal Source Select
3547 */
3548 EPwm4Regs.DCFCTL.all = (EPwm4Regs.DCFCTL.all & ~0x3F) | 0x10;
3549 EPwm4Regs.DCFOFFSET = 0; // Digital Compare Filter Offset Register
3550 EPwm4Regs.DCFWINDOW = 0; // Digital Compare Filter Window Register
3551
3552 /* // Digital Compare Capture Control Register
3553 EPwm4Regs.DCCAPCTL.bit.CAPE = 0; // Counter Capture Enable
3554 */
3555 EPwm4Regs.DCCAPCTL.all = (EPwm4Regs.DCCAPCTL.all & ~0x1) | 0x0;
3556
3557 /* // HRPWM Configuration Register
3558 EPwm4Regs.HRCNFG.bit.SWAPAB = 0; // Swap EPWMA and EPWMB Outputs Bit
3559 EPwm4Regs.HRCNFG.bit.SELOUTB = 0; // EPWMB Output Selection Bit
3560 */
3561 EPwm4Regs.HRCNFG.all = (EPwm4Regs.HRCNFG.all & ~0xA0) | 0x0;
3562
3563 /* Update the Link Registers with the link value for all the Compare values and TBPRD */
3564 /* No error is thrown if the ePWM register exists in the model or not */
3565 EPwm4Regs.EPWMXLINK.bit.TBPRDLINK = 3;
3566 EPwm4Regs.EPWMXLINK.bit.CMPALINK = 3;
3567 EPwm4Regs.EPWMXLINK.bit.CMPBLINK = 3;
3568 EPwm4Regs.EPWMXLINK.bit.CMPCLINK = 3;
3569 EPwm4Regs.EPWMXLINK.bit.CMPDLINK = 3;
3570 EDIS;
3571 EALLOW;
3572 CpuSysRegs.PCLKCR0.bit.TBCLKSYNC = 1;
3573 EDIS;
3574 }
3575
3576 /* Start for S-Function (c2802xadc): '<S2>/ADC2' */
3577 if (adcDInitFlag == 0) {
3578 InitAdcD();
3579 adcDInitFlag = 1;
3580 }
3581
3582 config_ADCD_SOC2 ();
3583
3584 /* Start for RateTransition: '<S2>/TmpRTBAtAdd10Inport2' */
3585 Inverter_001_B.TmpRTBAtAdd10Inport2 =
3586 Inverter_001_P.TmpRTBAtAdd10Inport2_InitialCon;
3587
3588 /* Start for S-Function (c2802xadc): '<S2>/ADC3' */
3589 if (adcDInitFlag == 0) {
3590 InitAdcD();
3591 adcDInitFlag = 1;
3592 }
3593
3594 config_ADCD_SOC5 ();
3595
3596 /* Start for RateTransition: '<S2>/TmpRTBAtAdd9Inport2' */
3597 Inverter_001_B.TmpRTBAtAdd9Inport2 =
3598 Inverter_001_P.TmpRTBAtAdd9Inport2_InitialCond;
3599
3600 /* Start for S-Function (c2802xadc): '<S2>/ADC4' */
3601 if (adcDInitFlag == 0) {
3602 InitAdcD();
3603 adcDInitFlag = 1;
3604 }
3605
3606 config_ADCD_SOC7 ();
3607
3608 /* Start for RateTransition: '<Root>/TmpRTBAtConstant12Outport1' */
3609 Inverter_001_B.TmpRTBAtConstant12Outport1 =
3610 Inverter_001_P.TmpRTBAtConstant12Outport1_Init;
3611
3612 /* Start for RateTransition: '<S2>/TmpRTBAtAdd16Inport2' */
3613 Inverter_001_B.TmpRTBAtAdd16Inport2 =
3614 Inverter_001_P.TmpRTBAtAdd16Inport2_InitialCon;
3615
3616 /* Start for S-Function (c2802xadc): '<S2>/ADC5' */
3617 if (adcAInitFlag == 0) {
3618 InitAdcA();
3619 adcAInitFlag = 1;
3620 }
3621
3622 config_ADCA_SOC4 ();
3623
3624 /* Start for RateTransition: '<S2>/TmpRTBAtAdd5Inport2' */
3625 Inverter_001_B.TmpRTBAtAdd5Inport2 =
3626 Inverter_001_P.TmpRTBAtAdd5Inport2_InitialCond;
3627
3628 /* Start for S-Function (c2802xadc): '<S2>/ADC6' */
3629 if (adcAInitFlag == 0) {
3630 InitAdcA();
3631 adcAInitFlag = 1;
3632 }
3633
3634 config_ADCA_SOC6 ();
3635
3636 /* Start for RateTransition: '<S2>/TmpRTBAtAdd4Inport2' */
3637 Inverter_001_B.TmpRTBAtAdd4Inport2 =
3638 Inverter_001_P.TmpRTBAtAdd4Inport2_InitialCond;
3639
3640 /* Start for S-Function (c2802xadc): '<S2>/ADC7' */
3641 if (adcAInitFlag == 0) {
3642 InitAdcA();
3643 adcAInitFlag = 1;
3644 }
3645
3646 config_ADCA_SOC8 ();
3647
3648 /* Start for RateTransition: '<S2>/TmpRTBAtAdd3Inport2' */
3649 Inverter_001_B.TmpRTBAtAdd3Inport2 =
3650 Inverter_001_P.TmpRTBAtAdd3Inport2_InitialCond;
3651
3652 /* Start for S-Function (c2802xadc): '<S2>/ADC9' */
3653 if (adcCInitFlag == 0) {
3654 InitAdcC();
3655 adcCInitFlag = 1;
3656 }
3657
3658 config_ADCC_SOC10 ();
3659
3660 /* Start for RateTransition: '<S2>/TmpRTBAtAdd7Inport2' */
3661 Inverter_001_B.TmpRTBAtAdd7Inport2 =
3662 Inverter_001_P.TmpRTBAtAdd7Inport2_InitialCond;
3663
3664 /* Start for S-Function (c2802xadc): '<S2>/ADC10' */
3665 if (adcCInitFlag == 0) {
3666 InitAdcC();
3667 adcCInitFlag = 1;
3668 }
3669
3670 config_ADCC_SOC11 ();
3671
3672 /* Start for RateTransition: '<S2>/TmpRTBAtAdd2Inport2' */
3673 Inverter_001_B.TmpRTBAtAdd2Inport2 =
3674 Inverter_001_P.TmpRTBAtAdd2Inport2_InitialCond;
3675
3676 /* Start for S-Function (c2802xadc): '<S2>/ADC11' */
3677 if (adcCInitFlag == 0) {
3678 InitAdcC();
3679 adcCInitFlag = 1;
3680 }
3681
3682 config_ADCC_SOC12 ();
3683
3684 /* Start for S-Function (c2837xdipc_rx): '<Root>/IPC Receive' */
3685 IPCInit(CHANNEL0, 1);
3686
3687 /* Start for MATLABSystem: '<Root>/DAC' */
3688 MW_ConfigureDACA();
3689
3690 /* Start for MATLABSystem: '<Root>/DAC1' */
3691 MW_ConfigureDACB();
3692
3693 /* Start for MATLABSystem: '<Root>/DAC2' */
3694 MW_ConfigureDACC();
3695
3696 /* InitializeConditions for RateTransition: '<Root>/TmpRTBAtConstant62Outport1' */
3697 Inverter_001_DW.TmpRTBAtConstant62Outport1_Buff =
3698 Inverter_001_P.TmpRTBAtConstant62Outport1_Init;
3699
3700 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd11Inport2' */
3701 Inverter_001_DW.TmpRTBAtAdd11Inport2_Buffer0 =
3702 Inverter_001_P.TmpRTBAtAdd11Inport2_InitialCon;
3703
3704 /* InitializeConditions for RateTransition: '<Root>/Rate Transition1' */
3705 Inverter_001_DW.RateTransition1_Buffer0 =
3706 Inverter_001_P.RateTransition1_InitialConditio;
3707
3708 /* InitializeConditions for UnitDelay: '<S34>/Unit Delay' */
3709 Inverter_001_DW.UnitDelay_DSTATE_lw =
3710 Inverter_001_P.UnitDelay_InitialCondition_pq;
3711
3712 /* InitializeConditions for UnitDelay: '<S7>/Unit Delay' */
3713 Inverter_001_DW.UnitDelay_DSTATE = Inverter_001_P.UnitDelay_InitialCondition;
3714
3715 /* InitializeConditions for UnitDelay: '<S7>/Unit Delay1' */
3716 Inverter_001_DW.UnitDelay1_DSTATE = Inverter_001_P.UnitDelay1_InitialCondition;
3717
3718 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd10Inport2' */
3719 Inverter_001_DW.TmpRTBAtAdd10Inport2_Buffer0 =
3720 Inverter_001_P.TmpRTBAtAdd10Inport2_InitialCon;
3721
3722 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd9Inport2' */
3723 Inverter_001_DW.TmpRTBAtAdd9Inport2_Buffer0 =
3724 Inverter_001_P.TmpRTBAtAdd9Inport2_InitialCond;
3725
3726 /* InitializeConditions for RateTransition: '<Root>/TmpRTBAtConstant12Outport1' */
3727 Inverter_001_DW.TmpRTBAtConstant12Outport1_Buff =
3728 Inverter_001_P.TmpRTBAtConstant12Outport1_Init;
3729
3730 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd16Inport2' */
3731 Inverter_001_DW.TmpRTBAtAdd16Inport2_Buffer0 =
3732 Inverter_001_P.TmpRTBAtAdd16Inport2_InitialCon;
3733
3734 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd5Inport2' */
3735 Inverter_001_DW.TmpRTBAtAdd5Inport2_Buffer0 =
3736 Inverter_001_P.TmpRTBAtAdd5Inport2_InitialCond;
3737
3738 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd4Inport2' */
3739 Inverter_001_DW.TmpRTBAtAdd4Inport2_Buffer0 =
3740 Inverter_001_P.TmpRTBAtAdd4Inport2_InitialCond;
3741
3742 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd3Inport2' */
3743 Inverter_001_DW.TmpRTBAtAdd3Inport2_Buffer0 =
3744 Inverter_001_P.TmpRTBAtAdd3Inport2_InitialCond;
3745
3746 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd7Inport2' */
3747 Inverter_001_DW.TmpRTBAtAdd7Inport2_Buffer0 =
3748 Inverter_001_P.TmpRTBAtAdd7Inport2_InitialCond;
3749
3750 /* InitializeConditions for RateTransition: '<S2>/TmpRTBAtAdd2Inport2' */
3751 Inverter_001_DW.TmpRTBAtAdd2Inport2_Buffer0 =
3752 Inverter_001_P.TmpRTBAtAdd2Inport2_InitialCond;
3753
3754 /* InitializeConditions for UnitDelay: '<S8>/Unit Delay' */
3755 Inverter_001_DW.UnitDelay_DSTATE_c =
3756 Inverter_001_P.UnitDelay_InitialCondition_e;
3757
3758 /* InitializeConditions for UnitDelay: '<S8>/Unit Delay1' */
3759 Inverter_001_DW.UnitDelay1_DSTATE_k =
3760 Inverter_001_P.UnitDelay1_InitialCondition_g;
3761
3762 /* InitializeConditions for UnitDelay: '<S9>/Unit Delay' */
3763 Inverter_001_DW.UnitDelay_DSTATE_f =
3764 Inverter_001_P.UnitDelay_InitialCondition_i;
3765
3766 /* InitializeConditions for UnitDelay: '<S9>/Unit Delay1' */
3767 Inverter_001_DW.UnitDelay1_DSTATE_j =
3768 Inverter_001_P.UnitDelay1_InitialCondition_b;
3769
3770 /* InitializeConditions for UnitDelay: '<S10>/Unit Delay' */
3771 Inverter_001_DW.UnitDelay_DSTATE_g =
3772 Inverter_001_P.UnitDelay_InitialCondition_n;
3773
3774 /* InitializeConditions for UnitDelay: '<S10>/Unit Delay1' */
3775 Inverter_001_DW.UnitDelay1_DSTATE_l =
3776 Inverter_001_P.UnitDelay1_InitialCondition_a;
3777
3778 /* InitializeConditions for UnitDelay: '<S11>/Unit Delay' */
3779 Inverter_001_DW.UnitDelay_DSTATE_k =
3780 Inverter_001_P.UnitDelay_InitialCondition_c;
3781
3782 /* InitializeConditions for UnitDelay: '<S11>/Unit Delay1' */
3783 Inverter_001_DW.UnitDelay1_DSTATE_h =
3784 Inverter_001_P.UnitDelay1_InitialCondition_l;
3785
3786 /* InitializeConditions for UnitDelay: '<S12>/Unit Delay' */
3787 Inverter_001_DW.UnitDelay_DSTATE_p =
3788 Inverter_001_P.UnitDelay_InitialCondition_cr;
3789
3790 /* InitializeConditions for UnitDelay: '<S12>/Unit Delay1' */
3791 Inverter_001_DW.UnitDelay1_DSTATE_i =
3792 Inverter_001_P.UnitDelay1_InitialCondition_l1;
3793
3794 /* InitializeConditions for UnitDelay: '<S13>/Unit Delay' */
3795 Inverter_001_DW.UnitDelay_DSTATE_d =
3796 Inverter_001_P.UnitDelay_InitialCondition_k;
3797
3798 /* InitializeConditions for UnitDelay: '<S13>/Unit Delay1' */
3799 Inverter_001_DW.UnitDelay1_DSTATE_hy =
3800 Inverter_001_P.UnitDelay1_InitialCondition_f;
3801
3802 /* InitializeConditions for UnitDelay: '<S14>/Unit Delay' */
3803 Inverter_001_DW.UnitDelay_DSTATE_j =
3804 Inverter_001_P.UnitDelay_InitialCondition_d;
3805
3806 /* InitializeConditions for UnitDelay: '<S14>/Unit Delay1' */
3807 Inverter_001_DW.UnitDelay1_DSTATE_jm =
3808 Inverter_001_P.UnitDelay1_InitialCondition_m;
3809
3810 /* InitializeConditions for UnitDelay: '<S15>/Unit Delay' */
3811 Inverter_001_DW.UnitDelay_DSTATE_l =
3812 Inverter_001_P.UnitDelay_InitialCondition_p;
3813
3814 /* InitializeConditions for UnitDelay: '<S15>/Unit Delay1' */
3815 Inverter_001_DW.UnitDelay1_DSTATE_p =
3816 Inverter_001_P.UnitDelay1_InitialCondition_e;
3817
3818 /* InitializeConditions for UnitDelay: '<S30>/Unit Delay3' */
3819 Inverter_001_DW.UnitDelay3_DSTATE = Inverter_001_P.UnitDelay3_InitialCondition;
3820
3821 /* InitializeConditions for UnitDelay: '<S30>/Unit Delay2' */
3822 Inverter_001_DW.UnitDelay2_DSTATE = Inverter_001_P.UnitDelay2_InitialCondition;
3823
3824 /* InitializeConditions for UnitDelay: '<S30>/Unit Delay1' */
3825 Inverter_001_DW.UnitDelay1_DSTATE_b =
3826 Inverter_001_P.UnitDelay1_InitialCondition_b1;
3827
3828 /* InitializeConditions for UnitDelay: '<S29>/Unit Delay3' */
3829 Inverter_001_DW.UnitDelay3_DSTATE_c =
3830 Inverter_001_P.UnitDelay3_InitialCondition_g;
3831
3832 /* InitializeConditions for UnitDelay: '<S29>/Unit Delay2' */
3833 Inverter_001_DW.UnitDelay2_DSTATE_h =
3834 Inverter_001_P.UnitDelay2_InitialCondition_h;
3835
3836 /* InitializeConditions for UnitDelay: '<S29>/Unit Delay1' */
3837 Inverter_001_DW.UnitDelay1_DSTATE_d =
3838 Inverter_001_P.UnitDelay1_InitialCondition_gr;
3839
3840 /* InitializeConditions for UnitDelay: '<S28>/Unit Delay3' */
3841 Inverter_001_DW.UnitDelay3_DSTATE_m =
3842 Inverter_001_P.UnitDelay3_InitialCondition_o;
3843
3844 /* InitializeConditions for UnitDelay: '<S28>/Unit Delay2' */
3845 Inverter_001_DW.UnitDelay2_DSTATE_g =
3846 Inverter_001_P.UnitDelay2_InitialCondition_m;
3847
3848 /* InitializeConditions for UnitDelay: '<S28>/Unit Delay1' */
3849 Inverter_001_DW.UnitDelay1_DSTATE_hyo =
3850 Inverter_001_P.UnitDelay1_InitialCondition_lk;
3851
3852 /* InitializeConditions for UnitDelay: '<S28>/Unit Delay' */
3853 Inverter_001_DW.UnitDelay_DSTATE_lt =
3854 Inverter_001_P.UnitDelay_InitialCondition_ck;
3855
3856 /* InitializeConditions for UnitDelay: '<S24>/Unit Delay3' */
3857 Inverter_001_DW.UnitDelay3_DSTATE_o =
3858 Inverter_001_P.UnitDelay3_InitialCondition_j;
3859
3860 /* InitializeConditions for UnitDelay: '<S24>/Unit Delay2' */
3861 Inverter_001_DW.UnitDelay2_DSTATE_gq =
3862 Inverter_001_P.UnitDelay2_InitialCondition_k;
3863
3864 /* InitializeConditions for UnitDelay: '<S24>/Unit Delay1' */
3865 Inverter_001_DW.UnitDelay1_DSTATE_c =
3866 Inverter_001_P.UnitDelay1_InitialCondition_h;
3867
3868 /* InitializeConditions for UnitDelay: '<S24>/Unit Delay' */
3869 Inverter_001_DW.UnitDelay_DSTATE_a =
3870 Inverter_001_P.UnitDelay_InitialCondition_ph;
3871
3872 /* InitializeConditions for UnitDelay: '<S29>/Unit Delay' */
3873 Inverter_001_DW.UnitDelay_DSTATE_o =
3874 Inverter_001_P.UnitDelay_InitialCondition_f;
3875
3876 /* InitializeConditions for UnitDelay: '<S25>/Unit Delay3' */
3877 Inverter_001_DW.UnitDelay3_DSTATE_g =
3878 Inverter_001_P.UnitDelay3_InitialCondition_p;
3879
3880 /* InitializeConditions for UnitDelay: '<S25>/Unit Delay2' */
3881 Inverter_001_DW.UnitDelay2_DSTATE_m =
3882 Inverter_001_P.UnitDelay2_InitialCondition_b;
3883
3884 /* InitializeConditions for UnitDelay: '<S25>/Unit Delay1' */
3885 Inverter_001_DW.UnitDelay1_DSTATE_m =
3886 Inverter_001_P.UnitDelay1_InitialCondition_fy;
3887
3888 /* InitializeConditions for UnitDelay: '<S25>/Unit Delay' */
3889 Inverter_001_DW.UnitDelay_DSTATE_m =
3890 Inverter_001_P.UnitDelay_InitialCondition_g;
3891
3892 /* InitializeConditions for UnitDelay: '<S30>/Unit Delay' */
3893 Inverter_001_DW.UnitDelay_DSTATE_i =
3894 Inverter_001_P.UnitDelay_InitialCondition_nv;
3895
3896 /* InitializeConditions for UnitDelay: '<S26>/Unit Delay3' */
3897 Inverter_001_DW.UnitDelay3_DSTATE_h =
3898 Inverter_001_P.UnitDelay3_InitialCondition_d;
3899
3900 /* InitializeConditions for UnitDelay: '<S26>/Unit Delay2' */
3901 Inverter_001_DW.UnitDelay2_DSTATE_gh =
3902 Inverter_001_P.UnitDelay2_InitialCondition_f;
3903
3904 /* InitializeConditions for UnitDelay: '<S26>/Unit Delay' */
3905 Inverter_001_DW.UnitDelay_DSTATE_ci =
3906 Inverter_001_P.UnitDelay_InitialCondition_e3;
3907
3908 /* InitializeConditions for UnitDelay: '<S26>/Unit Delay1' */
3909 Inverter_001_DW.UnitDelay1_DSTATE_g =
3910 Inverter_001_P.UnitDelay1_InitialCondition_n;
3911}
3912
3913/* Model terminate function */
3914void Inverter_001_terminate(void)
3915{
3916 /* (no terminate code required) */
3917}
3918
3919/*
3920 * File trailer for generated code.
3921 *
3922 * [EOF]
3923 */
3924