TI的TMS320F28377可以输出12对PWM,只是根据封装不同,有些PWM的引脚没有引出使得其路数减少了一些。在TI的例程中,一般都使用的EPWM1,EPWM2,EPWM3,对于EPWM9,EPWM10,EPWM11,EPWM12的配置在例程中给出的关于GPIO口的配置如下,以EPWM9为例:void InitEPwm9Gpio(void){ EALLOW;/*Disable internal pull-up for the selected output pins for reduced power consumption *///Pull-ups can be enabled or disabled by the user.//This will enable the pullups for the specified pins. GpioCtrlRegs.GPFPUD.bit.GPIO161 = 1; // Disable pull-up on GPIO161 (EPWM9A) GpioCtrlRegs.GPFPUD.bit.GPIO162 = 1; // Disable pull-up on GPIO162 (EPWM9B)/*Configure EPWM-6 pins using GPIO regs*///This specifies which of the possible GPIO pins will be EPWM6 functional pins.//Comment out other unwanted lines. GpioCtrlRegs.GPFMUX1.bit.GPIO161 = 1; // Configure GPIO161 as EPWM9A GpioCtrlRegs.GPFMUX1.bit.GPIO162 = 1; // Configure GPIO162 as EPWM9B EDIS;}可以看到配置给EPWM9的IO口是161和162,查看datasheet可以知道,对于EPWM9,其IO的分配可以是GPIO16,GPIO17,也可以是GPIO161,GPIO162,其中GPIO161,GPIO162是针对BGA封装的,我们平时使用的100脚的PZP和176脚的PTP封装中,EPWM9使用的是GPIO16,GPIO17。所以要对例程中的引脚定义进行更改。在例程中,对于PWM12345678的引脚定义代码如下,以EPWM1为例,前两条语句是禁止这两个引脚上拉,后两条语句是将该IO口定义为EPWM1输出。GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1; GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1; GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1; GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1; 在将GPIO16,GPIO17定义为PWM输出时,通过查看datasheet的PinMultiplexing可以知道,要将GPIO16,GPIO17定义为PWM输出,不仅需要需要定义其GPAMUX1位为01,还需要定义GPAGMUX1位为01,所以定义的语句应该如下:GpioCtrlRegs.GPAPUD.bit.GPIO16 = 1; GpioCtrlRegs.GPAPUD.bit.GPIO17 = 1; GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1; GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1; GpioCtrlRegs.GPAGMUX2.bit.GPIO16 = 1; GpioCtrlRegs.GPAGMUX2.bit.GPIO17 = 1; 至此,完成了EPWM9的IO口配置,其重点在于引脚的更改,和引脚配置时于EPWM12345678不同的地方。