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

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > stm32 學(xué)習(xí)筆記 systick定時(shí)器

          stm32 學(xué)習(xí)筆記 systick定時(shí)器

          作者: 時(shí)間:2016-11-13 來(lái)源:網(wǎng)絡(luò) 收藏
          開發(fā)STM32,遇到一些簡(jiǎn)單的需要計(jì)時(shí)的任務(wù),比如延時(shí)等,最方便的是其提供的systick。

          systick其實(shí)本為移植操作系統(tǒng)提供滴答時(shí)鐘的方便。

          本文引用地址:http://www.ex-cimer.com/article/201611/316276.htm

          前兩天再次接觸STM32,使用了V3.5的庫(kù),突然發(fā)現(xiàn)繁瑣的Systick用法被簡(jiǎn)化成一句話。

          即:

          void SysTick_Configuration(void)
          {
          if (SysTick_Config(SystemCoreClock / 1000000))//72, 1us per tick
          {
          /* Capture error */
          while (1);
          }
          }

          而Systick_Config函數(shù)已經(jīng)取代了之前所有的設(shè)置過(guò)程。

          systick.c文件也被簡(jiǎn)除,該函數(shù)直接歸在了內(nèi)核文件core_cm3.h里面。

          /* ################################## SysTick function ############################################ */

          #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)

          /**
          * @brief Initialize and start the SysTick counter and its interrupt.
          *
          * @param ticks number of ticks between two interrupts
          * @return 1 = failed, 0 = successful
          *
          * Initialise the system tick timer and its interrupt and start the
          * system tick timer / counter in free running mode to generate
          * periodical interrupts.
          */
          static __INLINE uint32_t SysTick_Config(uint32_t ticks)
          {
          if (ticks > SysTick_LOAD_RELOAD_Msk) return (1); /* Reload value impossible */

          SysTick->LOAD = (ticks & SysTick_LOAD_RELOAD_Msk) - 1; /* set reload register */
          NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */
          SysTick->VAL = 0; /* Load the SysTick Counter Value */
          SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
          SysTick_CTRL_TICKINT_Msk |
          SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
          return (0); /* Function successful */
          }

          #endif

          優(yōu)點(diǎn)是設(shè)置相當(dāng)簡(jiǎn)化,

          缺點(diǎn)是控制不如以前靈活了,一旦開啟,確實(shí)沒有庫(kù)函數(shù)方便地重載或禁用。



          關(guān)鍵詞: stm32systick定時(shí)

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁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); })();