美文网首页
stm8s tim1 定时器

stm8s tim1 定时器

作者: 嵌入式工作 | 来源:发表于2019-01-08 11:10 被阅读0次

    初始化

    uint16_t tim1_irq_com_flg=0;
    void tim1_init(void)
    {
    //1分频,向上计数,每50us定时中断一次, 重复计数器值为0   
     TIM1_TimeBaseInit(0,TIM1_COUNTERMODE_UP,800,0);     
     TIM1_ARRPreloadConfig(ENABLE);
     TIM1_ITConfig(TIM1_IT_UPDATE , ENABLE);
     TIM1_Cmd(ENABLE);
    }
    
    
    

    中断处理

    INTERRUPT_HANDLER(TIM1_UPD_OVF_TRG_BRK_IRQHandler, 11)
    {
      /* In order to detect unexpected events during development,
         it is recommended to set a breakpoint on the following instruction.
      */
    tim1_irq_com_flg++;
    TIMER1_Decrement();
      TIM1_ClearITPendingBit(TIM1_IT_UPDATE);
    }
    
    

    相关文章

      网友评论

          本文标题:stm8s tim1 定时器

          本文链接:https://www.haomeiwen.com/subject/htdvrqtx.html