本帖最后由 goodjob 于 2022-10-19 15:45 编辑
求助,AT32F421F8P7的PA2作为TMR15CH1没有PWM输出,配置完全按照例程的tmr3修改,定时器有正常运行,但PWM没有输出,请帮忙看下配置代码哪里有问题?测试PA2设置成普通IO翻转输出正常。同样的配置方式,配置TMR14CH1,PA4输出正常
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
crm_periph_clock_enable(CRM_GPIOF_PERIPH_CLOCK, TRUE);
crm_periph_clock_enable(CRM_TMR15_PERIPH_CLOCK, TRUE);
gpio_default_para_init(&gpio_init_struct);
gpio_init_struct.gpio_pins = GPIO_PINS_2;
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
gpio_init(GPIOA, &gpio_init_struct);
gpio_pin_mux_config(GPIOA, GPIO_PINS_SOURCE2, GPIO_MUX_0);
/* tmr15 time base configuration */
tmr_base_init(TMR15, 1000, 47);
tmr_cnt_dir_set(TMR15, TMR_COUNT_UP);
tmr_clock_source_div_set(TMR15, TMR_CLOCK_DIV1);
//TMR15_CH1
tmr_output_default_para_init(&tmr_oc_init_structure);
tmr_oc_init_structure.oc_mode = TMR_OUTPUT_CONTROL_PWM_MODE_A;
tmr_oc_init_structure.oc_idle_state = FALSE;
tmr_oc_init_structure.oc_polarity = TMR_OUTPUT_ACTIVE_HIGH;
tmr_oc_init_structure.oc_output_state = TRUE;
tmr_output_channel_config(TMR15, TMR_SELECT_CHANNEL_1, &tmr_oc_init_structure);
tmr_channel_value_set(TMR15, TMR_SELECT_CHANNEL_1,500);
tmr_output_channel_buffer_enable(TMR15, TMR_SELECT_CHANNEL_1, TRUE);
tmr_period_buffer_enable(TMR15, TRUE);
/* tmr enable counter */
tmr_counter_enable(TMR15, TRUE); |