打印

GD32F103外部脉冲计数

[复制链接]
2367|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
yangfrch|  楼主 | 2022-12-20 19:35 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
yangfrch|  楼主 | 2022-12-20 19:37 | 只看该作者
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);
}

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

8

帖子

0

粉丝