HK32F MCU有一个窗口看门狗和一个独立看门狗,一般使用独立看门狗来防止程序死机,和STM32的看门狗不一样的是,HK32F MCU的看门狗RC时钟为128KHz,STM32位32KHz。
HK32F MCU的独立看门狗驱动如下:
/* Includes ------------------------------------------------------------------*/
#include "hk32f030m_iwdg.h"
/**
* @brief : Max time:8190ms.
* @param : None.
* @retval : None.
*/
void IWDG_Init( uint16_t Time_ms )
{
uint16_t ReloadValue;
if( Time_ms > 8190 )
{
Time_ms = 8190;
}
ReloadValue = Time_ms/2;
IWDG_Enable( );
IWDG_WriteAccessCmd( IWDG_WriteAccess_Enable );
IWDG_SetPrescaler( IWDG_Prescaler_256 );
IWDG_SetReload( ReloadValue );
IWDG_SetWindowValue( ReloadValue );
IWDG_ReloadCounter();
}
/**
* @brief : None.
* @param : None.
* @retval : None.
*/
void IWDG_Feed( void )
{
while( IWDG_GetFlagStatus( IWDG_FLAG_RVU ) != RESET );
IWDG_ReloadCounter();
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
————————————————