在线看毛片网站电影-亚洲国产欧美日韩精品一区二区三区,国产欧美乱夫不卡无乱码,国产精品欧美久久久天天影视,精品一区二区三区视频在线观看,亚洲国产精品人成乱码天天看,日韩久久久一区,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)用 > STM8L探索套件學(xué)習(xí)筆記-窗口看門狗WWDG(十七)

            STM8L探索套件學(xué)習(xí)筆記-窗口看門狗WWDG(十七)

            作者: 時(shí)間:2016-11-24 來源:網(wǎng)絡(luò) 收藏
            窗口看門狗WWDG)通常被用來監(jiān)測(cè)由外部干擾或不可預(yù)見的邏輯條件造成的應(yīng)用程序背離正常的運(yùn)行序列而產(chǎn)生的軟件故障。除非遞減計(jì)數(shù)器的值在T6位變成0前被刷新,看門狗電路在達(dá)到預(yù)置的時(shí)間周期時(shí),會(huì)產(chǎn)生一個(gè)MCU復(fù)位。在遞減計(jì)數(shù)器達(dá)到窗口寄存器數(shù)值之前,如果7位的遞減計(jì)數(shù)器數(shù)值(在控制寄存器中)被刷新,那么也將產(chǎn)生一個(gè)MCU復(fù)位。這表明遞減計(jì)數(shù)器需要在一個(gè)有限的時(shí)間窗口中被刷新。上面提到的T6即是窗口看門狗的自減計(jì)數(shù)器的第六位(最高位)。在該計(jì)數(shù)器的T6位變?yōu)?后(小于0X40),就會(huì)引起一復(fù)位。這是窗口的下限。而當(dāng)計(jì)數(shù)器的值在大雨窗口配置寄存器的窗口值之前就被修改的話,也會(huì)引起一次復(fù)位,這里窗口值是上限。窗口值是由用戶自己設(shè)定的,根據(jù)實(shí)際要求來設(shè)計(jì)窗口值,但是一定要確保窗口值大于0X40,否則窗口就不存在了
            void main(void)
            {
            uint8_t Index;
            GPIO_Init(LED3_PORT,LED3_PIN,GPIO_Mode_Out_PP_Low_Fast);
            //輸出低電平-高速10M
            GPIO_Init(LED4_PORT,LED4_PIN,GPIO_Mode_Out_PP_Low_Fast);
            //輸出低電平-高速10M
            GPIO_Init(KEY_PORT,KEY_PIN,GPIO_Mode_In_FL_IT);
            //輸入浮空-中斷
            /* Set PC1 sensitivity to falling edge and low level 下降沿低電平觸發(fā)*/
            EXTI_SetPinSensitivity(EXTI_Pin_1, EXTI_Trigger_Falling_Low);
            /* Check if the MCU has resumed from WWDG reset */
            if (RST_GetFlagStatus(RST_FLAG_WWDGF) != RESET)
            {
            /* IWDGF flag set */
            /* Toggle LED3 */
            for (Index = 7; Index != 0; Index--)
            {
            GPIO_ToggleBits(LED3_PORT,LED3_PIN);
            Delay(0x7FFF);
            }
            /* Clear WWDGF Flag */
            RST_ClearFlag(RST_FLAG_WWDGF);
            }
            /* WWDG configuration: WWDG is clocked by SYSCLK = 2MHz */
            /* WWDG timeout is equal to 251,9 ms */
            /* Watchdog Window = (COUNTER_INIT - 63) * 1 step
            = 41 * (12288 / 2Mhz)
            = 251,9 ms
            */
            /* Non Allowed Window = (COUNTER_INIT - WINDOW_VALUE) * 1 step
            = (104 - 97) * 1 step
            = 7 * 1 step
            = 7 * (12288 / 2Mhz)
            = 43.008 ms
            */
            /* So the non allowed window starts from 0.0 ms to 43.008 ms
            and the alowed window starts from 43.008 ms to 251,9 ms
            If refresh is done during non allowed window, a reset will occur.
            If refresh is done during allowed window, no reset will occur.
            If the WWDG down counter reaches 63, a reset will occur. */
            WWDG_Init(COUNTER_INIT, WINDOW_VALUE);
            /* enable interrupts by switching to level 0 */
            enableInterrupts();
            while (1)
            {
            /* Check if WWDG counter refresh is allowed in Allowed window */
            if (AllowedRefresh != 0)
            {
            /* get WWDG counter value */
            /* wait until WWDG counter becomes lower than window value */
            while ((WWDG_GetCounter() & 0x7F) > WINDOW_VALUE);
            /* Refresh WWDG counter during allowed window so no MCU reset will occur */
            WWDG_SetCounter(COUNTER_INIT);
            }
            /* Check if WWDG counter refresh is allowed in non Allowed window */
            if (NonAlowedRefresh != 0)
            {
            /* wait until WWDG counter becomes higher than window value */
            while ((WWDG_GetCounter() & 0x7F) < WINDOW_VALUE);
            /* Refresh WWDG counter during non allowed window so MCU reset will occur */
            WWDG_SetCounter(COUNTER_INIT);
            }
            /* Toggle LED4 */
            GPIO_ToggleBits(LED4_PORT,LED4_PIN);
            Delay(0x6FFF);
            }
            }


            評(píng)論


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

            關(guān)閉