TA的每日心情 | 开心 2017-9-5 22:21 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]初来乍到
|
收到GD32F450有段时间了,偶尔有空看看,原来以为和ST的完全兼容,准备拿来公司做项目用的,后来发现差别还是挺大的,里面的定时器用STCubeMX生成后只有一个定时器可以正常,其他都不能使用,还需要花时间去学习习惯GD的驱动代码库
自己花时间写了一个定时器的代码发现不能进入中断,pend不能置位
void inittimer(void)
{
timer_parameter_struct* timer_initpara ;
timer_break_parameter_struct timer_breakpara;
rcu_periph_clock_enable(RCU_TIMER1);
rcu_timer_clock_prescaler_config(RCU_TIMER_PSC_MUL4);
timer_deinit(TIMER1);
timer_initpara->prescaler = 63;
timer_initpara->alignedmode = TIMER_COUNTER_EDGE;
timer_initpara->clockdivision = TIMER_CKDIV_DIV1;
timer_initpara->counterdirection = TIMER_COUNTER_UP;
timer_initpara->period = 2000-1;
timer_initpara->repetitioncounter = 0;
//timer_breakpara.breakpolarity
timer_init(TIMER1,timer_initpara);
timer_input_trigger_source_select(TIMER1,TIMER_SMCFG_TRGSEL_ITI0);
//timer_primary_output_config(TIMER0,ENABLE);
//timer_slave_mode_select(TIMER0,TIMER_SLAVE_MODE_EVENT);
timer_interrupt_enable(TIMER1,TIMER_INT_UP);
/* auto-reload preload enable */
//timer_auto_reload_shadow_enable(TIMER0);
//timer_interrupt_enable(TIMER0,TIMER_INT_TRG);
timer_enable(TIMER1);
}
/**
\brief configure the nested vectored interrupt controller
\param[in] none
\param[out] none
\retval none
*/
void nvic_configuration(void)
{
nvic_priority_group_set(NVIC_PRIGROUP_PRE1_SUB3);
nvic_irq_enable(TIMER1_IRQn, 1, 3);//TIMER0_CC_IRQn
}
|
|