<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 利用stm32f103的TIM2實現(xiàn)精確延時

          利用stm32f103的TIM2實現(xiàn)精確延時

          作者: 時間:2016-11-19 來源:網絡 收藏
          void TIM_ResetCounter(TIM_TypeDef * TIMx)
          {TIMx->CNT = 0;}void TIM2_Delay_ms(unsigned int cms){unsigned short temp = 0;TIM_TimeBaseInitTypeDef  TIM_TimeBaseStructure;TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);TIM_TimeBaseStructure.TIM_Prescaler = 36000 - 1;TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Down;TIM_TimeBaseStructure.TIM_Period = cms * 2;TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);TIM_Cmd(TIM2, ENABLE);do{temp = TIM_GetCounter(TIM2);}while(temp != 0x01);/*此處不能計數(shù)到0*/TIM_Cmd(TIM2, DISABLE);TIM_ResetCounter(TIM2);/*將計數(shù)寄存器的值恢復為0是必須的*/}


          評論


          技術專區(qū)

          關閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();