F2837xD_EPwm.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  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. // Included Files
  44. //
  45. #include "F2837xD_device.h"
  46. #include "F2837xD_Examples.h"
  47. //
  48. // InitEPwmGpio - Initialize all EPWM modules' GPIOs
  49. //
  50. void InitEPwmGpio(void)
  51. {
  52. InitEPwm1Gpio();
  53. InitEPwm2Gpio();
  54. InitEPwm3Gpio();
  55. InitEPwm4Gpio();
  56. InitEPwm5Gpio();
  57. InitEPwm6Gpio();
  58. InitEPwm7Gpio();
  59. InitEPwm8Gpio();
  60. InitEPwm9Gpio();
  61. InitEPwm10Gpio();
  62. InitEPwm11Gpio();
  63. InitEPwm12Gpio();
  64. }
  65. //
  66. // InitEPwm1Gpio - Initialize EPWM1 GPIOs
  67. //
  68. void InitEPwm1Gpio(void)
  69. {
  70. EALLOW;
  71. //
  72. // Disable internal pull-up for the selected output pins
  73. // for reduced power consumption
  74. // Pull-ups can be enabled or disabled by the user.
  75. // Comment out other unwanted lines.
  76. //
  77. GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1; // Disable pull-up on GPIO0 (EPWM1A)
  78. GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; // Disable pull-up on GPIO1 (EPWM1B)
  79. // GpioCtrlRegs.GPEPUD.bit.GPIO145 = 1; // Disable pull-up on GPIO145 (EPWM1A)
  80. // GpioCtrlRegs.GPEPUD.bit.GPIO146 = 1; // Disable pull-up on GPIO146 (EPWM1B)
  81. //
  82. // Configure EPWM-1 pins using GPIO regs
  83. // This specifies which of the possible GPIO pins will be EPWM1 functional
  84. // pins.
  85. // Comment out other unwanted lines.
  86. //
  87. GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; // Configure GPIO0 as EPWM1A
  88. GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; // Configure GPIO1 as EPWM1B
  89. // GpioCtrlRegs.GPEMUX2.bit.GPIO145 = 1; // Configure GPIO145 as EPWM1A
  90. // GpioCtrlRegs.GPEMUX2.bit.GPIO146 = 1; // Configure GPIO0146 as EPWM1B
  91. EDIS;
  92. }
  93. //
  94. // InitEPwm2Gpio - Initialize EPWM2 GPIOs
  95. //
  96. void InitEPwm2Gpio(void)
  97. {
  98. EALLOW;
  99. //
  100. // Disable internal pull-up for the selected output pins
  101. // for reduced power consumption
  102. // Pull-ups can be enabled or disabled by the user.
  103. // This will enable the pullups for the specified pins.
  104. // Comment out other unwanted lines.
  105. //
  106. GpioCtrlRegs.GPAPUD.bit.GPIO2 = 1; // Disable pull-up on GPIO2 (EPWM2A)
  107. GpioCtrlRegs.GPAPUD.bit.GPIO3 = 1; // Disable pull-up on GPIO3 (EPWM2B)
  108. // GpioCtrlRegs.GPEPUD.bit.GPIO147 = 1; // Disable pull-up on GPIO147 (EPWM2A)
  109. // GpioCtrlRegs.GPEPUD.bit.GPIO148 = 1; // Disable pull-up on GPIO148 (EPWM2B)
  110. //
  111. // Configure EPwm-2 pins using GPIO regs
  112. // This specifies which of the possible GPIO pins will be EPWM2 functional pins.
  113. // Comment out other unwanted lines.
  114. //
  115. GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 1; // Configure GPIO2 as EPWM2A
  116. GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 1; // Configure GPIO3 as EPWM2B
  117. // GpioCtrlRegs.GPEMUX2.bit.GPIO147 = 1; // Configure GPIO147 as EPWM2A
  118. // GpioCtrlRegs.GPEMUX2.bit.GPIO148 = 1; // Configure GPIO148 as EPWM2B
  119. EDIS;
  120. }
  121. //
  122. // InitEPwm3Gpio - Initialize EPWM3 GPIOs
  123. //
  124. void InitEPwm3Gpio(void)
  125. {
  126. EALLOW;
  127. //
  128. // Disable internal pull-up for the selected output pins
  129. // for reduced power consumption
  130. // Pull-ups can be enabled or disabled by the user.
  131. // This will enable the pullups for the specified pins.
  132. // Comment out other unwanted lines.
  133. //
  134. GpioCtrlRegs.GPAPUD.bit.GPIO4 = 1; // Disable pull-up on GPIO4 (EPWM3A)
  135. GpioCtrlRegs.GPAPUD.bit.GPIO5 = 1; // Disable pull-up on GPIO5 (EPWM3B)
  136. // GpioCtrlRegs.GPEPUD.bit.GPIO149 = 1; // Disable pull-up on GPIO149 (EPWM3A)
  137. // GpioCtrlRegs.GPEPUD.bit.GPIO150 = 1; // Disable pull-up on GPIO150 (EPWM3B)
  138. //
  139. // Configure EPwm-3 pins using GPIO regs
  140. // This specifies which of the possible GPIO pins will be EPWM3 functional pins.
  141. // Comment out other unwanted lines.
  142. //
  143. GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 1; // Configure GPIO4 as EPWM3A
  144. GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 1; // Configure GPIO5 as EPWM3B
  145. // GpioCtrlRegs.GPEMUX2.bit.GPIO149 = 1; // Configure GPIO149 as EPWM3A
  146. // GpioCtrlRegs.GPEMUX2.bit.GPIO150 = 1; // Configure GPIO150 as EPWM3B
  147. EDIS;
  148. }
  149. //
  150. // InitEPwm4Gpio - Initialize EPWM4 GPIOs
  151. //
  152. void InitEPwm4Gpio(void)
  153. {
  154. EALLOW;
  155. //
  156. // Disable internal pull-up for the selected output pins
  157. // for reduced power consumption
  158. // Pull-ups can be enabled or disabled by the user.
  159. // This will enable the pullups for the specified pins.
  160. // Comment out other unwanted lines.
  161. //
  162. GpioCtrlRegs.GPAPUD.bit.GPIO6 = 1; // Disable pull-up on GPIO6 (EPWM4A)
  163. GpioCtrlRegs.GPAPUD.bit.GPIO7 = 1; // Disable pull-up on GPIO7 (EPWM4B)
  164. // GpioCtrlRegs.GPEPUD.bit.GPIO151 = 1; // Disable pull-up on GPIO151 (EPWM4A)
  165. // GpioCtrlRegs.GPEPUD.bit.GPIO152 = 1; // Disable pull-up on GPIO152 (EPWM4B)
  166. //
  167. // Configure EPWM-4 pins using GPIO regs
  168. // This specifies which of the possible GPIO pins will be EPWM4 functional
  169. // pins.
  170. // Comment out other unwanted lines.
  171. //
  172. GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 1; // Configure GPIO6 as EPWM4A
  173. GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 1; // Configure GPIO7 as EPWM4B
  174. // GpioCtrlRegs.GPEMUX2.bit.GPIO151 = 1; // Configure GPIO151 as EPWM4A
  175. // GpioCtrlRegs.GPEMUX2.bit.GPIO152 = 1; // Configure GPIO152 as EPWM4B
  176. EDIS;
  177. }
  178. //
  179. // InitEPwm5Gpio - Initialize EPWM5 GPIOs
  180. //
  181. void InitEPwm5Gpio(void)
  182. {
  183. EALLOW;
  184. //
  185. // Disable internal pull-up for the selected output pins
  186. // for reduced power consumption
  187. // Pull-ups can be enabled or disabled by the user.
  188. // This will enable the pullups for the specified pins.
  189. // Comment out other unwanted lines.
  190. //
  191. GpioCtrlRegs.GPAPUD.bit.GPIO8 = 1; // Disable pull-up on GPIO8 (EPWM5A)
  192. GpioCtrlRegs.GPAPUD.bit.GPIO9 = 1; // Disable pull-up on GPIO9 (EPWM5B)
  193. // GpioCtrlRegs.GPEPUD.bit.GPIO153 = 1; // Disable pull-up on GPIO153 (EPWM5A)
  194. // GpioCtrlRegs.GPEPUD.bit.GPIO154 = 1; // Disable pull-up on GPIO154 (EPWM5B)
  195. //
  196. // Configure EPWM-5 pins using GPIO regs
  197. // This specifies which of the possible GPIO pins will be EPWM5 functional
  198. // pins.
  199. // Comment out other unwanted lines.
  200. //
  201. GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 1; // Configure GPIO8 as EPWM5A
  202. GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 1; // Configure GPIO9 as EPWM5B
  203. // GpioCtrlRegs.GPEMUX2.bit.GPIO153 = 1; // Configure GPIO153 as EPWM5A
  204. // GpioCtrlRegs.GPEMUX2.bit.GPIO154 = 1; // Configure GPIO0154 as EPWM5B
  205. EDIS;
  206. }
  207. //
  208. // InitEPwm6Gpio - Initialize EPWM6 GPIOs
  209. //
  210. void InitEPwm6Gpio(void)
  211. {
  212. EALLOW;
  213. //
  214. // Disable internal pull-up for the selected output pins
  215. // for reduced power consumption
  216. // Pull-ups can be enabled or disabled by the user.
  217. // This will enable the pullups for the specified pins.
  218. // Comment out other unwanted lines.
  219. //
  220. GpioCtrlRegs.GPAPUD.bit.GPIO10 = 1; // Disable pull-up on GPIO10 (EPWM6A)
  221. GpioCtrlRegs.GPAPUD.bit.GPIO11 = 1; // Disable pull-up on GPIO11 (EPWM6B)
  222. // GpioCtrlRegs.GPEPUD.bit.GPIO155 = 1; // Disable pull-up on GPIO155 (EPWM6A)
  223. // GpioCtrlRegs.GPEPUD.bit.GPIO156 = 1; // Disable pull-up on GPIO156 (EPWM6B)
  224. //
  225. // Configure EPWM-6 pins using GPIO regs
  226. // This specifies which of the possible GPIO pins will be EPWM6 functional
  227. // pins.
  228. // Comment out other unwanted lines.
  229. //
  230. GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 1; // Configure GPIO10 as EPWM6A
  231. GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 1; // Configure GPIO11 as EPWM6B
  232. // GpioCtrlRegs.GPEMUX2.bit.GPIO155 = 1; // Configure GPIO155 as EPWM6A
  233. // GpioCtrlRegs.GPEMUX2.bit.GPIO156 = 1; // Configure GPIO156 as EPWM6B
  234. EDIS;
  235. }
  236. //
  237. // InitEPwm7Gpio - Initialize EPWM7 GPIOs
  238. //
  239. void InitEPwm7Gpio(void)
  240. {
  241. EALLOW;
  242. //
  243. // Disable internal pull-up for the selected output pins
  244. // for reduced power consumption
  245. // Pull-ups can be enabled or disabled by the user.
  246. // This will enable the pullups for the specified pins.
  247. // Comment out other unwanted lines.
  248. //
  249. GpioCtrlRegs.GPAPUD.bit.GPIO12 = 1; // Disable pull-up on GPIO12 (EPWM7A)
  250. GpioCtrlRegs.GPAPUD.bit.GPIO13 = 1; // Disable pull-up on GPIO13 (EPWM7B)
  251. // GpioCtrlRegs.GPEPUD.bit.GPIO157 = 1; // Disable pull-up on GPIO157 (EPWM7A)
  252. // GpioCtrlRegs.GPEPUD.bit.GPIO158 = 1; // Disable pull-up on GPIO158 (EPWM7B)
  253. //
  254. // Configure EPWM-6 pins using GPIO regs
  255. // This specifies which of the possible GPIO pins will be EPWM6 functional
  256. // pins.
  257. // Comment out other unwanted lines.
  258. //
  259. GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 1; // Configure GPIO12 as EPWM7A
  260. GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 1; // Configure GPIO13 as EPWM7B
  261. // GpioCtrlRegs.GPEMUX2.bit.GPIO157 = 1; // Configure GPIO157 as EPWM7A
  262. // GpioCtrlRegs.GPEMUX2.bit.GPIO158 = 1; // Configure GPIO158 as EPWM7B
  263. EDIS;
  264. }
  265. //
  266. // InitEPwm8Gpio - Initialize EPWM8 GPIOs
  267. //
  268. void InitEPwm8Gpio(void)
  269. {
  270. EALLOW;
  271. //
  272. // Disable internal pull-up for the selected output pins
  273. // for reduced power consumption
  274. // Pull-ups can be enabled or disabled by the user.
  275. // This will enable the pullups for the specified pins.
  276. // Comment out other unwanted lines.
  277. //
  278. GpioCtrlRegs.GPAPUD.bit.GPIO14 = 1; // Disable pull-up on GPIO14 (EPWM8A)
  279. GpioCtrlRegs.GPAPUD.bit.GPIO15 = 1; // Disable pull-up on GPIO15 (EPWM8B)
  280. // GpioCtrlRegs.GPEPUD.bit.GPIO159 = 1; // Disable pull-up on GPIO159 (EPWM8A)
  281. // GpioCtrlRegs.GPFPUD.bit.GPIO160 = 1; // Disable pull-up on GPIO160 (EPWM8B)
  282. //
  283. // Configure EPWM-6 pins using GPIO regs
  284. // This specifies which of the possible GPIO pins will be EPWM6 functional
  285. // pins.
  286. // Comment out other unwanted lines.
  287. //
  288. GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 1; // Configure GPIO14 as EPWM8A
  289. GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 1; // Configure GPIO15 as EPWM8B
  290. // GpioCtrlRegs.GPEMUX2.bit.GPIO159 = 1; // Configure GPIO159 as EPWM8A
  291. // GpioCtrlRegs.GPFMUX1.bit.GPIO160 = 1; // Configure GPIO160 as EPWM8B
  292. EDIS;
  293. }
  294. //
  295. // InitEPwm9Gpio - Initialize EPWM9 GPIOs
  296. //
  297. void InitEPwm9Gpio(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.GPFPUD.bit.GPIO161 = 1; // Disable pull-up on GPIO161 (EPWM9A)
  308. GpioCtrlRegs.GPFPUD.bit.GPIO162 = 1; // Disable pull-up on GPIO162 (EPWM9B)
  309. //
  310. // Configure EPWM-6 pins using GPIO regs
  311. // This specifies which of the possible GPIO pins will be EPWM6 functional
  312. // pins.
  313. // Comment out other unwanted lines.
  314. //
  315. GpioCtrlRegs.GPFMUX1.bit.GPIO161 = 1; // Configure GPIO161 as EPWM9A
  316. GpioCtrlRegs.GPFMUX1.bit.GPIO162 = 1; // Configure GPIO162 as EPWM9B
  317. EDIS;
  318. }
  319. //
  320. // InitEPwm10Gpio - Initialize EPWM10 GPIOs
  321. //
  322. void InitEPwm10Gpio(void)
  323. {
  324. EALLOW;
  325. //
  326. // Disable internal pull-up for the selected output pins
  327. // for reduced power consumption
  328. // Pull-ups can be enabled or disabled by the user.
  329. // This will enable the pullups for the specified pins.
  330. // Comment out other unwanted lines.
  331. //
  332. GpioCtrlRegs.GPFPUD.bit.GPIO163 = 1; // Disable pull-up on GPIO163 (EPWM10A)
  333. GpioCtrlRegs.GPFPUD.bit.GPIO164 = 1; // Disable pull-up on GPIO164 (EPWM10B)
  334. //
  335. // Configure EPWM-6 pins using GPIO regs
  336. // This specifies which of the possible GPIO pins will be EPWM6 functional
  337. // pins.
  338. // Comment out other unwanted lines.
  339. //
  340. GpioCtrlRegs.GPFMUX1.bit.GPIO163 = 1; // Configure GPIO163 as EPWM10A
  341. GpioCtrlRegs.GPFMUX1.bit.GPIO164 = 1; // Configure GPIO164 as EPWM10B
  342. EDIS;
  343. }
  344. //
  345. // InitEPwm11Gpio - Initialize EPWM11 GPIOs
  346. //
  347. void InitEPwm11Gpio(void)
  348. {
  349. EALLOW;
  350. //
  351. // Disable internal pull-up for the selected output pins
  352. // for reduced power consumption
  353. // Pull-ups can be enabled or disabled by the user.
  354. // This will enable the pullups for the specified pins.
  355. // Comment out other unwanted lines.
  356. //
  357. GpioCtrlRegs.GPFPUD.bit.GPIO165 = 1; // Disable pull-up on GPIO165 (EPWM11A)
  358. GpioCtrlRegs.GPFPUD.bit.GPIO166 = 1; // Disable pull-up on GPIO166 (EPWM11B)
  359. //
  360. // Configure EPWM-6 pins using GPIO regs
  361. // This specifies which of the possible GPIO pins will be EPWM6 functional
  362. // pins.
  363. // Comment out other unwanted lines.
  364. //
  365. GpioCtrlRegs.GPFMUX1.bit.GPIO165 = 1; // Configure GPIO165 as EPWM11A
  366. GpioCtrlRegs.GPFMUX1.bit.GPIO166 = 1; // Configure GPIO166 as EPWM11B
  367. EDIS;
  368. }
  369. //
  370. // InitEPwm12Gpio - Initialize EPWM12 GPIOs
  371. //
  372. void InitEPwm12Gpio(void)
  373. {
  374. EALLOW;
  375. //
  376. // Disable internal pull-up for the selected output pins
  377. // for reduced power consumption
  378. // Pull-ups can be enabled or disabled by the user.
  379. // This will enable the pullups for the specified pins.
  380. // Comment out other unwanted lines.
  381. //
  382. GpioCtrlRegs.GPFPUD.bit.GPIO167 = 1; // Disable pull-up on GPIO167 (EPWM12A)
  383. GpioCtrlRegs.GPFPUD.bit.GPIO168 = 1; // Disable pull-up on GPIO168 (EPWM12B)
  384. //
  385. // Configure EPWM-6 pins using GPIO regs
  386. // This specifies which of the possible GPIO pins will be EPWM6 functional
  387. // pins.
  388. // Comment out other unwanted lines.
  389. //
  390. GpioCtrlRegs.GPFMUX1.bit.GPIO167 = 1; // Configure GPIO167 as EPWM12A
  391. GpioCtrlRegs.GPFMUX1.bit.GPIO168 = 1; // Configure GPIO168 as EPWM12B
  392. EDIS;
  393. }