int
PWMInit (void)
[
//
// PWM不分频
//
SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2|GPIO_PIN_3);//配置2,3管脚为输出
//配置PF0,PF1分别为M1PWM4,M1PWM5
GPIOPinConfigure(GPIO_PF0_M1PWM4);
GPIOPinConfigure(GPIO_PF1_M1PWM5);
// 配置PF0,PF1为PWM的输出管脚
GPIOPinTypePWM(GPIO_PORTF_BASE, GPIO_PIN_0|GPIO_PIN_1);
//
// Configure the PWM1 to count down without synchroniza
tion.
//配置GEN2递减计数模式不同步模式
PWMGenConfigure(PWM1_BASE, PWM_GEN_2,
PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC);
//设置PWM周期
PWMGenPeriodSet(PWM1_BASE, PWM_GEN_2,100);
//设置PWM占空比
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_4, 10);
PWMPulseWidthSet(PWM1_BASE, PWM_OUT_5, 10);
//使能PWM输出状态
PWMOutputState(PWM1_BASE, PWM_OUT_4_BIT| PWM_OUT_5_BIT, true);
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2, 0x1<<2);//H2管脚置高 对应RESETAB
GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_3, 0x1<<3);//H3管脚置高 对应RESETCD
//
// 使能PWM发生器
PWMGenEnable(PWM1_BASE, PWM_GEN_2);
return(0);
]
PF1能输出PWM,而PF0不能输出PWM
0