1 //###########################################################################
2 //
3 // FILE: F2837xD_EPwm.c
4 //
5 // TITLE: F2837xD EPwm Initialization & Support Functions.
6 //
7 //###########################################################################
8 // $TI Release: F2837xD Support Library v3.05.00.00 $
9 // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
10 // $Copyright:
11 // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
12 //
13 // Redistribution and use in source and binary forms, with or without
14 // modification, are permitted provided that the following conditions
15 // are met:
16 //
17 // Redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // Redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the
23 // distribution.
24 //
25 // Neither the name of Texas Instruments Incorporated nor the names of
26 // its contributors may be used to endorse or promote products derived
27 // from this software without specific prior written permission.
28 //
29 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 // $
41 //###########################################################################
42
43 //
44 // Included Files
45 //
46 #include "F2837xD_device.h"
47 #include "F2837xD_Examples.h"
48
49 //
50 // InitEPwmGpio - Initialize all EPWM modules' GPIOs
51 //
InitEPwmGpio(void)52 void InitEPwmGpio(void)
53 {
54 InitEPwm1Gpio();
55 InitEPwm2Gpio();
56 InitEPwm3Gpio();
57 InitEPwm4Gpio();
58 InitEPwm5Gpio();
59 InitEPwm6Gpio();
60 InitEPwm7Gpio();
61 InitEPwm8Gpio();
62 InitEPwm9Gpio();
63 InitEPwm10Gpio();
64 InitEPwm11Gpio();
65 InitEPwm12Gpio();
66 }
67
68 //
69 // InitEPwm1Gpio - Initialize EPWM1 GPIOs
70 //
InitEPwm1Gpio(void)71 void InitEPwm1Gpio(void)
72 {
73 EALLOW;
74
75 //
76 // Disable internal pull-up for the selected output pins
77 // for reduced power consumption
78 // Pull-ups can be enabled or disabled by the user.
79 // Comment out other unwanted lines.
80 //
81 GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1; // Disable pull-up on GPIO0 (EPWM1A)
82 GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; // Disable pull-up on GPIO1 (EPWM1B)
83 // GpioCtrlRegs.GPEPUD.bit.GPIO145 = 1; // Disable pull-up on GPIO145 (EPWM1A)
84 // GpioCtrlRegs.GPEPUD.bit.GPIO146 = 1; // Disable pull-up on GPIO146 (EPWM1B)
85
86 //
87 // Configure EPWM-1 pins using GPIO regs
88 // This specifies which of the possible GPIO pins will be EPWM1 functional
89 // pins.
90 // Comment out other unwanted lines.
91 //
92 GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
93 GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO1 as EPWM1B
94 // GpioCtrlRegs.GPEMUX2.bit.GPIO145 = 1; // Configure GPIO145 as EPWM1A
95 // GpioCtrlRegs.GPEMUX2.bit.GPIO146 = 1; // Configure GPIO0146 as EPWM1B
96
97 EDIS;
98 }
99
100 //
101 // InitEPwm2Gpio - Initialize EPWM2 GPIOs
102 //
InitEPwm2Gpio(void)103 void InitEPwm2Gpio(void)
104 {
105 EALLOW;
106
107 //
108 // Disable internal pull-up for the selected output pins
109 // for reduced power consumption
110 // Pull-ups can be enabled or disabled by the user.
111 // This will enable the pullups for the specified pins.
112 // Comment out other unwanted lines.
113 //
114 GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1; // Disable pull-up on GPIO2 (EPWM2A)
115 GpioCtrlRegs.GPAPUD.bit.GPIO3 = 1; // Disable pull-up on GPIO3 (EPWM2B)
116 // GpioCtrlRegs.GPEPUD.bit.GPIO147 = 1; // Disable pull-up on GPIO147 (EPWM2A)
117 // GpioCtrlRegs.GPEPUD.bit.GPIO148 = 1; // Disable pull-up on GPIO148 (EPWM2B)
118
119 //
120 // Configure EPwm-2 pins using GPIO regs
121 // This specifies which of the possible GPIO pins will be EPWM2 functional pins.
122 // Comment out other unwanted lines.
123 //
124 GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1; // Configure GPIO2 as EPWM2A
125 GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 1; // Configure GPIO3 as EPWM2B
126 // GpioCtrlRegs.GPEMUX2.bit.GPIO147 = 1; // Configure GPIO147 as EPWM2A
127 // GpioCtrlRegs.GPEMUX2.bit.GPIO148 = 1; // Configure GPIO148 as EPWM2B
128
129 EDIS;
130 }
131
132 //
133 // InitEPwm3Gpio - Initialize EPWM3 GPIOs
134 //
InitEPwm3Gpio(void)135 void InitEPwm3Gpio(void)
136 {
137 EALLOW;
138
139 //
140 // Disable internal pull-up for the selected output pins
141 // for reduced power consumption
142 // Pull-ups can be enabled or disabled by the user.
143 // This will enable the pullups for the specified pins.
144 // Comment out other unwanted lines.
145 //
146 GpioCtrlRegs.GPAPUD.bit.GPIO4 = 1; // Disable pull-up on GPIO4 (EPWM3A)
147 GpioCtrlRegs.GPAPUD.bit.GPIO5 = 1; // Disable pull-up on GPIO5 (EPWM3B)
148 // GpioCtrlRegs.GPEPUD.bit.GPIO149 = 1; // Disable pull-up on GPIO149 (EPWM3A)
149 // GpioCtrlRegs.GPEPUD.bit.GPIO150 = 1; // Disable pull-up on GPIO150 (EPWM3B)
150
151 //
152 // Configure EPwm-3 pins using GPIO regs
153 // This specifies which of the possible GPIO pins will be EPWM3 functional pins.
154 // Comment out other unwanted lines.
155 //
156 GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1; // Configure GPIO4 as EPWM3A
157 GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1; // Configure GPIO5 as EPWM3B
158 // GpioCtrlRegs.GPEMUX2.bit.GPIO149 = 1; // Configure GPIO149 as EPWM3A
159 // GpioCtrlRegs.GPEMUX2.bit.GPIO150 = 1; // Configure GPIO150 as EPWM3B
160
161 EDIS;
162 }
163
164 //
165 // InitEPwm4Gpio - Initialize EPWM4 GPIOs
166 //
InitEPwm4Gpio(void)167 void InitEPwm4Gpio(void)
168 {
169 EALLOW;
170
171 //
172 // Disable internal pull-up for the selected output pins
173 // for reduced power consumption
174 // Pull-ups can be enabled or disabled by the user.
175 // This will enable the pullups for the specified pins.
176 // Comment out other unwanted lines.
177 //
178 GpioCtrlRegs.GPAPUD.bit.GPIO6 = 1; // Disable pull-up on GPIO6 (EPWM4A)
179 GpioCtrlRegs.GPAPUD.bit.GPIO7 = 1; // Disable pull-up on GPIO7 (EPWM4B)
180 // GpioCtrlRegs.GPEPUD.bit.GPIO151 = 1; // Disable pull-up on GPIO151 (EPWM4A)
181 // GpioCtrlRegs.GPEPUD.bit.GPIO152 = 1; // Disable pull-up on GPIO152 (EPWM4B)
182
183 //
184 // Configure EPWM-4 pins using GPIO regs
185 // This specifies which of the possible GPIO pins will be EPWM4 functional
186 // pins.
187 // Comment out other unwanted lines.
188 //
189 GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1; // Configure GPIO6 as EPWM4A
190 GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 1; // Configure GPIO7 as EPWM4B
191 // GpioCtrlRegs.GPEMUX2.bit.GPIO151 = 1; // Configure GPIO151 as EPWM4A
192 // GpioCtrlRegs.GPEMUX2.bit.GPIO152 = 1; // Configure GPIO152 as EPWM4B
193
194 EDIS;
195 }
196
197 //
198 // InitEPwm5Gpio - Initialize EPWM5 GPIOs
199 //
InitEPwm5Gpio(void)200 void InitEPwm5Gpio(void)
201 {
202 EALLOW;
203 //
204 // Disable internal pull-up for the selected output pins
205 // for reduced power consumption
206 // Pull-ups can be enabled or disabled by the user.
207 // This will enable the pullups for the specified pins.
208 // Comment out other unwanted lines.
209 //
210 GpioCtrlRegs.GPAPUD.bit.GPIO8 = 1; // Disable pull-up on GPIO8 (EPWM5A)
211 GpioCtrlRegs.GPAPUD.bit.GPIO9 = 1; // Disable pull-up on GPIO9 (EPWM5B)
212 // GpioCtrlRegs.GPEPUD.bit.GPIO153 = 1; // Disable pull-up on GPIO153 (EPWM5A)
213 // GpioCtrlRegs.GPEPUD.bit.GPIO154 = 1; // Disable pull-up on GPIO154 (EPWM5B)
214
215 //
216 // Configure EPWM-5 pins using GPIO regs
217 // This specifies which of the possible GPIO pins will be EPWM5 functional
218 // pins.
219 // Comment out other unwanted lines.
220 //
221 GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 1; // Configure GPIO8 as EPWM5A
222 GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 1; // Configure GPIO9 as EPWM5B
223 // GpioCtrlRegs.GPEMUX2.bit.GPIO153 = 1; // Configure GPIO153 as EPWM5A
224 // GpioCtrlRegs.GPEMUX2.bit.GPIO154 = 1; // Configure GPIO0154 as EPWM5B
225
226 EDIS;
227 }
228
229 //
230 // InitEPwm6Gpio - Initialize EPWM6 GPIOs
231 //
InitEPwm6Gpio(void)232 void InitEPwm6Gpio(void)
233 {
234 EALLOW;
235 //
236 // Disable internal pull-up for the selected output pins
237 // for reduced power consumption
238 // Pull-ups can be enabled or disabled by the user.
239 // This will enable the pullups for the specified pins.
240 // Comment out other unwanted lines.
241 //
242 GpioCtrlRegs.GPAPUD.bit.GPIO10 = 1; // Disable pull-up on GPIO10 (EPWM6A)
243 GpioCtrlRegs.GPAPUD.bit.GPIO11 = 1; // Disable pull-up on GPIO11 (EPWM6B)
244 // GpioCtrlRegs.GPEPUD.bit.GPIO155 = 1; // Disable pull-up on GPIO155 (EPWM6A)
245 // GpioCtrlRegs.GPEPUD.bit.GPIO156 = 1; // Disable pull-up on GPIO156 (EPWM6B)
246
247 //
248 // Configure EPWM-6 pins using GPIO regs
249 // This specifies which of the possible GPIO pins will be EPWM6 functional
250 // pins.
251 // Comment out other unwanted lines.
252 //
253 GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 1; // Configure GPIO10 as EPWM6A
254 GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 1; // Configure GPIO11 as EPWM6B
255 // GpioCtrlRegs.GPEMUX2.bit.GPIO155 = 1; // Configure GPIO155 as EPWM6A
256 // GpioCtrlRegs.GPEMUX2.bit.GPIO156 = 1; // Configure GPIO156 as EPWM6B
257
258 EDIS;
259 }
260
261 //
262 // InitEPwm7Gpio - Initialize EPWM7 GPIOs
263 //
InitEPwm7Gpio(void)264 void InitEPwm7Gpio(void)
265 {
266 EALLOW;
267
268 //
269 // Disable internal pull-up for the selected output pins
270 // for reduced power consumption
271 // Pull-ups can be enabled or disabled by the user.
272 // This will enable the pullups for the specified pins.
273 // Comment out other unwanted lines.
274 //
275 GpioCtrlRegs.GPAPUD.bit.GPIO12 = 1; // Disable pull-up on GPIO12 (EPWM7A)
276 GpioCtrlRegs.GPAPUD.bit.GPIO13 = 1; // Disable pull-up on GPIO13 (EPWM7B)
277 // GpioCtrlRegs.GPEPUD.bit.GPIO157 = 1; // Disable pull-up on GPIO157 (EPWM7A)
278 // GpioCtrlRegs.GPEPUD.bit.GPIO158 = 1; // Disable pull-up on GPIO158 (EPWM7B)
279
280 //
281 // Configure EPWM-6 pins using GPIO regs
282 // This specifies which of the possible GPIO pins will be EPWM6 functional
283 // pins.
284 // Comment out other unwanted lines.
285 //
286 GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 1; // Configure GPIO12 as EPWM7A
287 GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 1; // Configure GPIO13 as EPWM7B
288 // GpioCtrlRegs.GPEMUX2.bit.GPIO157 = 1; // Configure GPIO157 as EPWM7A
289 // GpioCtrlRegs.GPEMUX2.bit.GPIO158 = 1; // Configure GPIO158 as EPWM7B
290
291 EDIS;
292 }
293
294 //
295 // InitEPwm8Gpio - Initialize EPWM8 GPIOs
296 //
InitEPwm8Gpio(void)297 void InitEPwm8Gpio(void)
298 {
299 EALLOW;
300 //
301 // Disable internal pull-up for the selected output pins
302 // for reduced power consumption
303 // Pull-ups can be enabled or disabled by the user.
304 // This will enable the pullups for the specified pins.
305 // Comment out other unwanted lines.
306 //
307 GpioCtrlRegs.GPAPUD.bit.GPIO14 = 1; // Disable pull-up on GPIO14 (EPWM8A)
308 GpioCtrlRegs.GPAPUD.bit.GPIO15 = 1; // Disable pull-up on GPIO15 (EPWM8B)
309 // GpioCtrlRegs.GPEPUD.bit.GPIO159 = 1; // Disable pull-up on GPIO159 (EPWM8A)
310 // GpioCtrlRegs.GPFPUD.bit.GPIO160 = 1; // Disable pull-up on GPIO160 (EPWM8B)
311
312 //
313 // Configure EPWM-6 pins using GPIO regs
314 // This specifies which of the possible GPIO pins will be EPWM6 functional
315 // pins.
316 // Comment out other unwanted lines.
317 //
318 GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 1; // Configure GPIO14 as EPWM8A
319 GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 1; // Configure GPIO15 as EPWM8B
320 // GpioCtrlRegs.GPEMUX2.bit.GPIO159 = 1; // Configure GPIO159 as EPWM8A
321 // GpioCtrlRegs.GPFMUX1.bit.GPIO160 = 1; // Configure GPIO160 as EPWM8B
322
323 EDIS;
324 }
325
326 //
327 // InitEPwm9Gpio - Initialize EPWM9 GPIOs
328 //
InitEPwm9Gpio(void)329 void InitEPwm9Gpio(void)
330 {
331 EALLOW;
332 //
333 // Disable internal pull-up for the selected output pins
334 // for reduced power consumption
335 // Pull-ups can be enabled or disabled by the user.
336 // This will enable the pullups for the specified pins.
337 // Comment out other unwanted lines.
338 //
339 GpioCtrlRegs.GPFPUD.bit.GPIO161 = 1; // Disable pull-up on GPIO161 (EPWM9A)
340 GpioCtrlRegs.GPFPUD.bit.GPIO162 = 1; // Disable pull-up on GPIO162 (EPWM9B)
341
342 //
343 // Configure EPWM-6 pins using GPIO regs
344 // This specifies which of the possible GPIO pins will be EPWM6 functional
345 // pins.
346 // Comment out other unwanted lines.
347 //
348 GpioCtrlRegs.GPFMUX1.bit.GPIO161 = 1; // Configure GPIO161 as EPWM9A
349 GpioCtrlRegs.GPFMUX1.bit.GPIO162 = 1; // Configure GPIO162 as EPWM9B
350
351 EDIS;
352 }
353
354 //
355 // InitEPwm10Gpio - Initialize EPWM10 GPIOs
356 //
InitEPwm10Gpio(void)357 void InitEPwm10Gpio(void)
358 {
359 EALLOW;
360 //
361 // Disable internal pull-up for the selected output pins
362 // for reduced power consumption
363 // Pull-ups can be enabled or disabled by the user.
364 // This will enable the pullups for the specified pins.
365 // Comment out other unwanted lines.
366 //
367 GpioCtrlRegs.GPFPUD.bit.GPIO163 = 1; // Disable pull-up on GPIO163 (EPWM10A)
368 GpioCtrlRegs.GPFPUD.bit.GPIO164 = 1; // Disable pull-up on GPIO164 (EPWM10B)
369
370 //
371 // Configure EPWM-6 pins using GPIO regs
372 // This specifies which of the possible GPIO pins will be EPWM6 functional
373 // pins.
374 // Comment out other unwanted lines.
375 //
376 GpioCtrlRegs.GPFMUX1.bit.GPIO163 = 1; // Configure GPIO163 as EPWM10A
377 GpioCtrlRegs.GPFMUX1.bit.GPIO164 = 1; // Configure GPIO164 as EPWM10B
378
379 EDIS;
380 }
381
382 //
383 // InitEPwm11Gpio - Initialize EPWM11 GPIOs
384 //
InitEPwm11Gpio(void)385 void InitEPwm11Gpio(void)
386 {
387 EALLOW;
388 //
389 // Disable internal pull-up for the selected output pins
390 // for reduced power consumption
391 // Pull-ups can be enabled or disabled by the user.
392 // This will enable the pullups for the specified pins.
393 // Comment out other unwanted lines.
394 //
395 GpioCtrlRegs.GPFPUD.bit.GPIO165 = 1; // Disable pull-up on GPIO165 (EPWM11A)
396 GpioCtrlRegs.GPFPUD.bit.GPIO166 = 1; // Disable pull-up on GPIO166 (EPWM11B)
397
398 //
399 // Configure EPWM-6 pins using GPIO regs
400 // This specifies which of the possible GPIO pins will be EPWM6 functional
401 // pins.
402 // Comment out other unwanted lines.
403 //
404 GpioCtrlRegs.GPFMUX1.bit.GPIO165 = 1; // Configure GPIO165 as EPWM11A
405 GpioCtrlRegs.GPFMUX1.bit.GPIO166 = 1; // Configure GPIO166 as EPWM11B
406
407 EDIS;
408 }
409
410 //
411 // InitEPwm12Gpio - Initialize EPWM12 GPIOs
412 //
InitEPwm12Gpio(void)413 void InitEPwm12Gpio(void)
414 {
415 EALLOW;
416 //
417 // Disable internal pull-up for the selected output pins
418 // for reduced power consumption
419 // Pull-ups can be enabled or disabled by the user.
420 // This will enable the pullups for the specified pins.
421 // Comment out other unwanted lines.
422 //
423 GpioCtrlRegs.GPFPUD.bit.GPIO167 = 1; // Disable pull-up on GPIO167 (EPWM12A)
424 GpioCtrlRegs.GPFPUD.bit.GPIO168 = 1; // Disable pull-up on GPIO168 (EPWM12B)
425
426 //
427 // Configure EPWM-6 pins using GPIO regs
428 // This specifies which of the possible GPIO pins will be EPWM6 functional
429 // pins.
430 // Comment out other unwanted lines.
431 //
432 GpioCtrlRegs.GPFMUX1.bit.GPIO167 = 1; // Configure GPIO167 as EPWM12A
433 GpioCtrlRegs.GPFMUX1.bit.GPIO168 = 1; // Configure GPIO168 as EPWM12B
434
435 EDIS;
436 }
437