新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > stm32 系統嘀嗒(SysTick) 定時器

        stm32 系統嘀嗒(SysTick) 定時器

        作者: 時間:2016-11-13 來源:網絡 收藏
        系統嘀嗒校準值固定為9000,當系統嘀嗒時鐘設定為9MHz(HCLK/8的最大值),產生1ms時間基準。
        在3.5 的庫中
        void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
        位于 misc.c 文件中
        然后在core_cm3.h 文件中,定義了一個內聯函數,完成定時配置,中斷開啟,定時器開啟的功能。
        /* ################################## SysTick function ############################################ */
        #if (!defined (__Vendor_SysTickConfig)) || (__Vendor_SysTickConfig == 0)
        /* SysTick constants */
        #define SYSTICK_ENABLE 0 /* Config-Bit to start or stop the SysTick Timer */
        #define SYSTICK_TICKINT 1 /* Config-Bit to enable or disable the SysTick interrupt */
        #define SYSTICK_CLKSOURCE 2 /* Clocksource has the offset 2 in SysTick Control and Status Register */
        #define SYSTICK_MAXCOUNT ((1<<24) -1) /* SysTick MaxCount */
        /**
        * @brief Initialize and start the SysTick counter and its interrupt.
        *
        * @param uint32_t ticks is the number of ticks between two interrupts
        * @return none
        *
        * 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_MAXCOUNT) return (1); /* Reload value impossible */
        SysTick->LOAD = (ticks & SYSTICK_MAXCOUNT) - 1; /* set reload register */
        NVIC_SetPriority (SysTick_IRQn, (1<<__NVIC_PRIO_BITS) - 1); /* set Priority for Cortex-M0 System Interrupts */
        SysTick->VAL = (0x00); /* Load the SysTick Counter Value */
        SysTick->CTRL = (1 << SYSTICK_CLKSOURCE) | (1<
        return (0); /* Function successful */
        }
        #endif
        老的庫文件的是6個函數
        1.void SysTick_CLKSourceConfig(uint32_t SysTick_CLKSource)
        下面的這幾個的功能都已經被SysTick_Config() 所替代
        2.voidSysTick_SetReload(void)
        3.voidSysTick_CounterCmd(void)
        4.voidSysTick_ITConfig(void)
        5.voidSysTick_GetCounter(void)
        6.voidSysTick_GetFlagStatus(void)


        關鍵詞: stm32SysTick定時

        評論


        技術專區

        關閉
        主站蜘蛛池模板: 景宁| 长兴县| 芦山县| 故城县| 涿州市| 平利县| 永州市| 大渡口区| 晋江市| 宕昌县| 北宁市| 金门县| 阿尔山市| 常州市| 海林市| 阿拉善右旗| 沙湾县| 越西县| 沙洋县| 宣化县| 布拖县| 桐乡市| 横山县| 镇平县| 西乌| 红安县| 丰台区| 梁山县| 望都县| 平潭县| 临泽县| 漳平市| 安岳县| 临夏市| 孟连| 抚松县| 盘山县| 石首市| 新乡市| 金沙县| 广东省|