GD32定时器无法使用ETI计数,同一个芯片,使用stm32的库则正常运行,没有问题,GD32库代码如下
static void Timer_Rcu_NvicIrq_Init(void)
{
rcu_periph_clock_enable(RCU_GPIOA);
rcu_periph_clock_enable(RCU_AF);
rcu_periph_clock_enable(RCU_TIMER1);
}
static void Timer_Gpio_Init(void)
{
gpio_init(GPIOA, GPIO_MODE_AF_PP, GPIO_OSPEED_50MHZ, GPIO_PIN_0);
}
static void Timer_Config(void)
{
timer_parameter_struct timer_initpara;
// timer_ic_parameter_struct timer_icinitpara;
timer_deinit(TIMER1);
/* initialize TIMER init parameter struct */
timer_struct_para_init(&timer_initpara);
/* TIMER1 configuration */
timer_initpara.prescaler = 0;
timer_initpara.alignedmode = TIMER_COUNTER_EDGE;
timer_initpara.counterdirection = TIMER_COUNTER_UP;
timer_initpara.period = 0xffff;
timer_initpara.clockdivision = TIMER_CKDIV_DIV1;
timer_init(TIMER1, &timer_initpara);
/* slave mode selection : TIMER1 */
/* TIMER1 input trigger : external trigger connected to CI0 */
timer_input_trigger_source_select(TIMER1, TIMER_SMCFG_TRGSEL_CI0FE0);
timer_slave_mode_select(TIMER1, TIMER_SLAVE_MODE_EXTERNAL0);
timer_external_clock_mode1_config(TIMER1, TIMER_EXT_TRI_PSC_OFF, TIMER_ETP_RISING, 0);
timer_enable(TIMER1);
}
|