-
GD32F350的TIMER_CHx_ON无法输出
测试过TIM2_CH3输出PWM是好用的,下面是InitTIM15_CH0_ON的初始化函数,并不能让PB6输出PWMvoidInitTIM15_CH0_ON(void){/*initializeGPIO*/rcu_periph_clock_enable(RCU_GPIOB);/*!<enableGPIOBclock*/gpio_mode_set(GPIOB,GPIO_MODE_AF,GPIO_PUPD_NONE,GPIO_PIN_6);/*!<setPB6modetoAF*/gpio_output_options_set(GPIOB,GPIO_OTYPE_PP,GPIO_OSPEED_MAX,GPIO_PIN_6);/*!<setPB6options*//*associateGPIOandTIMER*/gpio_af_set(GPIOB,GPIO_AF_2,GPIO_PIN_6);/*!<setPB6modetoAF2(TIMER15_CH0_ON)*//*initializeTIMER*/voidinitTimer15(void);}voidinitTimer15(void){/*enabletheTIMER15clock*/rcu_periph_clock_enable(RCU_TIMER15);/*clearpara.ofTIMER15*/timer_deinit(TIMER15);/*initializeTIMER15freq=108M/(215+1),duty=timer15_count0/1000,count=timer15_count0+timer15_count1*/timer_parameter_structtimer_initpara;timer_initpara.prescaler=215;timer_initpara.alignedmode=TIMER_COUNTER_EDGE;timer_initpara.counterdirection=TIMER_COUNTER_UP;timer_initpara.period=999;timer_initpara.clockdivision=TIMER_CKDIV_DIV1;timer_initpara.repetitioncounter=0;timer_init(TIMER15,&timer_initpara);/*configtimeroutput*/timer_oc_parameter_structtimer_ocinitpara;timer_ocinitpara.outputstate=TIMER_CCX_DISABLE;/*!<disableTIMER_CHx*/timer_ocinitpara.outputnstate=TIMER_CCXN_ENABLE;/*!<enableTIMER_CHxN*/timer_ocinitpara.ocnpolarity=TIMER_OCN_POLARITY_LOW;timer_ocinitpara.ocnidlestate=TIMER_OCN_IDLE_STATE_LOW;timer_channel_output_config(TIMER15,TIMER_CH_0,&timer_ocinitpara);//timer_auto_reload_shadow_enable(TIMER15);timer_primary_output_config(TIMER15,ENABLE);/*setTIMER_CHxPWMduty*/timer_channel_output_pulse_value_config(TIMER15,TIMER_CH_0,1000);timer_channel_ou
2022-06-09 8