在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,91精品国产91免费

<menu id="6qfwx"><li id="6qfwx"></li></menu>
    1. <menu id="6qfwx"><dl id="6qfwx"></dl></menu>

      <label id="6qfwx"><ol id="6qfwx"></ol></label><menu id="6qfwx"></menu><object id="6qfwx"><strike id="6qfwx"><noscript id="6qfwx"></noscript></strike></object>
        1. <center id="6qfwx"><dl id="6qfwx"></dl></center>

            新聞中心

            EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > STM32 v3.5固件庫(kù)systick ms延時(shí)

            STM32 v3.5固件庫(kù)systick ms延時(shí)

            作者: 時(shí)間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
            《如何從STM32F10xxx固件庫(kù)V2.0.3升級(jí)為STM32F10xxx標(biāo)準(zhǔn)外設(shè)庫(kù)V3.0.0》一文中的“3.3.2 SysTick”講到:
            在標(biāo)準(zhǔn)外設(shè)庫(kù)中移除了SysTick的驅(qū)動(dòng),因此用戶必須調(diào)用CMSIS定義的函數(shù)。
            CMSIS只提供了一個(gè)SysTick設(shè)置的函數(shù),替代了STM32原有SysTick驅(qū)動(dòng)的全部函數(shù)。
            SysTick_Config(uint32_t ticks);
            該函數(shù)設(shè)置了自動(dòng)重載入計(jì)數(shù)器(LOAD)的值,SysTick IRQ的優(yōu)先級(jí),復(fù)位了計(jì)數(shù)器(VAL)的值,開始計(jì)數(shù)并打開SysTick IRQ中斷。SysTick時(shí)鐘默認(rèn)使用系統(tǒng)時(shí)鐘。
            下面的例程為使用固件庫(kù)V2.0.3進(jìn)行SysTick設(shè)置:
            /* Select the HCLK Clock as SysTick clock source (72MHz) */
            SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
            /* SysTick end of count event each 1ms with input clock equal to 72MHz (HCLK) */
            SysTick_SetReload(72000);
            /* Enable SysTick interrupt */
            SysTick_ITConfig(ENABLE);
            下面的例程為使用標(biāo)準(zhǔn)外設(shè)庫(kù)V3.0.0進(jìn)行SysTick設(shè)置:
            /* Setup SysTick Timer for 1 msec interrupts */
            if (SysTick_Config(SystemFrequency / 1000)) /* SystemFrequency is defined in “system_stm32f10x.h” and equal to HCLK frequency */
            {
            /* Capture error */
            while (1);
            }
            2.0庫(kù)函數(shù)延時(shí)代碼

            /*初始化時(shí)鐘*/

            本文引用地址:http://www.biyoush.com/article/201612/325082.htm

            void Init_SysTick(void)
            {
            /* Disable SysTick Counter */
            SysTick_CounterCmd(SysTick_Counter_Disable);

            /* Disable the SysTick Interrupt */
            SysTick_ITConfig(DISABLE);

            /* Configure HCLK clock as SysTick clock source */
            SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8);

            /* SysTick interrupt each 1000 Hz with HCLK equal to 72MHz */
            SysTick_SetReload(9000);

            /* Enable the SysTick Interrupt */
            SysTick_ITConfig(ENABLE);
            }

            /*延時(shí)1ms函數(shù)*/

            __IO uint32_t TimingDelay;

            void delay_ms(__IO uint32_t nTime)
            {
            /* Enable the SysTick Counter */
            SysTick_CounterCmd(SysTick_Counter_Enable);

            TimingDelay = nTime;

            while(TimingDelay != 0);

            /* Disable SysTick Counter */
            SysTick_CounterCmd(SysTick_Counter_Disable);

            /* Clear SysTick Counter */
            SysTick_CounterCmd(SysTick_Counter_Clear);
            }

            /*stm32f10x_it.c中的void SysTick_Handler(void)函數(shù)改為*/
            extern __IO uint32_t TimingDelay;

            void SysTick_Handler(void)
            {
            if (TimingDelay != 0x00)
            {
            TimingDelay--;
            }
            }

            /*用法,延時(shí)1秒*/
            delay_ms(1000);

            3.5庫(kù)函數(shù)延時(shí)代碼

            /*初始化時(shí)鐘*/

            void Init_SysTick(void)
            {
            if(SysTick_Config(SystemCoreClock / 1000)) //注意:3.5庫(kù)中SystemFrequency 被SystemCoreClock 取代。
            while(1);
            }

            /*延時(shí)1ms函數(shù)*/

            __IO uint32_t TimingDelay;

            void delay_ms(__IO uint32_t nTime)
            {
            TimingDelay = nTime;
            while(TimingDelay != 0);
            }

            /*stm32f10x_it.c中的void SysTick_Handler(void)函數(shù)改為*/

            extern __IO uint32_t TimingDelay;

            void SysTick_Handler(void)
            {
            if (TimingDelay != 0x00)
            {
            TimingDelay--;
            }
            }

            /*用法,延時(shí)1秒*/

            delay_ms(1000);



            評(píng)論


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

            關(guān)閉