在定时器配置里配置一下就可以了
/* CH0 configuration in OC TOGGLE mode */
if (LED_CCXN) {
timer_ocintpara.outputstate = TIMER_CCX_DISABLE; //ͨµÀÊä³ö״̬
timer_ocintpara.outputnstate = TIMER_CCXN_ENABLE; //»¥²¹Í¨µÀÊä³ö״̬
timer_ocintpara.ocnpolarity = TIMER_OCN_POLARITY_HIGH; //»¥²¹Í¨µÀÊä³ö¼«ÐÔ
timer_ocintpara.ocnidlestate = TIMER_OCN_IDLE_STATE_LOW;//¿ÕÏÐ״̬Ï»¥²¹Í¨µÀÊä³ö¼«ÐÔ
}else{
timer_ocintpara.outputstate = TIMER_CCX_ENABLE; //ͨµÀÊä³ö״̬
timer_ocintpara.outputnstate = TIMER_CCXN_DISABLE; //»¥²¹Í¨µÀÊä³ö״̬
timer_ocintpara.ocpolarity = TIMER_OC_POLARITY_HIGH; //ͨµÀÊä³ö¼«ÐÔ
timer_ocintpara.ocidlestate = TIMER_OC_IDLE_STATE_LOW; //¿ÕÏÐ״̬ÏÂͨµÀÊä³ö
}
timer_channel_output_config(ThisTIMER, TimerCh, &timer_ocintpara);
//1= TIMER_OC_MODE_TOGGLE
// timer_channel_output_mode_config(ThisTIMER, TimerCh, TIMER_OC_MODE_TOGGLE);
// timer_channel_output_shadow_config(ThisTIMER, TimerCh, TIMER_OC_SHADOW_ENABLE);
// or
//2= TIMER_OC_MODE_PWM0
timer_channel_output_mode_config(ThisTIMER, TimerCh, TIMER_OC_MODE_PWM0);
timer_channel_output_pulse_value_config(ThisTIMER,TimerCh,2500-1);
timer_channel_output_shadow_config(ThisTIMER, TimerCh, TIMER_OC_SHADOW_ENABLE);
/* auto-reload preload enable */
|