电机调速程序中pwm初始化代码如下所示:
PIN_Config timerPinTable[] = { PWM_OPEN_IOID | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_INPUT_DIS | PIN_DRVSTR_MAX,
PIN_TERMINATE };
void board_pwm_init()
{
#ifdef PWM_EXAMPLE
//RTOS: Enable peripheral domain and clocks for timer
Power_setDependency(PERIPH_GPT0);
//RTOS: Disallow standby while timer is running
//Power_setConstraint (Power_SB_DISALLOW);-----------------------------------
//RTOS: Open and assign pins through PIN driver
hPin = PIN_open(&pinState, timerPinTable);
// RTOS: Route pin to timer0A module
// IOC Port events 0-7 are mapped to GPT timers 0A,0B,1A,1B...3B
PINCC26XX_setMux(hPin, PWM_OPEN_IOID, IOC_PORT_MCU_PORT_EVENT0);
// Timer A in PWM mode, don't care about Timer B but ASSERTS in driverLib requires it
// to be set to something
TimerConfigure(GPT0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM|TIMER_CFG_B_CAP_COUNT);
}
电机控制结束后调用关闭pwm接口如下:
void board_pwm_stop()
{
TimerDisable(GPT0_BASE,TIMER_A);
Power_setConstraint (Power_STANDBY);
}
调用关闭pwm接口同时配置成输出低电平 但是低功耗进不了了。。。