新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 我的獨立看門狗總結(jié)

我的獨立看門狗總結(jié)

作者: 時間:2013-04-10 來源:網(wǎng)絡 收藏

/* Set the Vector Table base location at 0x20000000 */

NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);

#else /* VECT_TAB_FLASH */

/* Set the Vector Table base location at 0x08000000 */

NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

#endif

NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(NVIC_InitStructure);

}

void Timer_init(void)

{

TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;

// ---------------------------------------------------------------

// TIM3 Configuration: 定時器3配置

// TIM3CLK = 36 MHz, Prescaler =36000, TIM3 counter clock = 1KHz

// SET TTIM3 TIME 200mS

//---------------------------------------------------------------

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);

// Time base configuration

TIM_TimeBaseStructure.TIM_Period = 200;

TIM_TimeBaseStructure.TIM_Prescaler = 0;

TIM_TimeBaseStructure.TIM_ClockDivision = 0;

TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Down;

TIM_TimeBaseInit(TIM3, TIM_TimeBaseStructure);

//Enables peripheral Preload register on ARR

TIM_ARRPreloadConfig(TIM3,ENABLE);

// Prescaler configuration

TIM_PrescalerConfig(TIM3, 35999, TIM_PSCReloadMode_Immediate);

TIM_InternalClockConfig(TIM3);

//Enables TIM interrupts

TIM_ITConfig(TIM3,TIM_FLAG_Update,ENABLE);

//TIM3 enable counter

TIM_Cmd(TIM3, ENABLE);

}

………………………………………………………………………

void TIM3_IRQHandler(void)

{

static u8 count=0;

if (TIM_GetITStatus(TIM3, TIM_IT_Update) != RESET)

{

TIM_ClearITPendingBit(TIM3, TIM_IT_Update);

//TIM3溢出中斷需執(zhí)行的代碼在此添加

count++;

if(count=25)

{

/* Enable write access to _PR and _RLR registers */

_WriteAccessCmd(IWDG_WriteAccess_Enable);

/* Reload IWDG counter */

IWDG_ReloadCounter();

}

}

}

四、結(jié)語

時鐘由內(nèi)部40KHZ提供,所以不受主時鐘的影響,即一旦啟動看門狗,即便在調(diào)試過程中,暫停程序運行,看門狗也將不會停止,在復位時間到后仍會將系統(tǒng)復位。

分頻器相關(guān)文章:分頻器原理
塵埃粒子計數(shù)器相關(guān)文章:塵埃粒子計數(shù)器原理
蜂鳴器相關(guān)文章:蜂鳴器原理

上一頁 1 2 下一頁

關(guān)鍵詞: 獨立看門狗 IWDG 軟件錯誤

評論


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

關(guān)閉