单脉冲PWM输出

//–TIMER0_CH0 IO口配置
static void pwm_freq_gpio_config(void)
{
rcu_periph_clock_enable(PWM_FREQ_RCC);

gpio_mode_set(PWM_FREQ_PORT, GPIO_MODE_AF, GPIO_PUPD_NONE, PWM_FREQ_PIN);

gpio_output_options_set(PWM_FREQ_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,PWM_FREQ_PIN);
gpio_af_set(PWM_FREQ_PORT, GPIO_AF_2, PWM_FREQ_PIN);
}

//–TIMER0_CH0 IO口配置
static void pwm_freq_config(void)
{
timer_oc_parameter_struct timer_ocintpara;
timer_parameter_struct timer_initpara;

rcu_periph_clock_enable(RCU_TIMER0); //++PWM输出:单脉冲模式
//=====================================================================================================
//++ TIMER0_CH0 PWM输出配置
timer_deinit(TIMER0);
timer_initpara.prescaler         = 0; //++计数器时钟预分频值,计数器时钟=SystemCoreClock/(0+1)=SystemCoreClock
timer_initpara.alignedmode       = TIMER_COUNTER_EDGE;//++00:无中央对齐模式(边沿对齐模式)。
timer_initpara.counterdirection  = TIMER_COUNTER_UP;//++计数方向,向上计数
timer_init

你可能感兴趣的:(驱动,stm32)