⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watchdog.c

📁 支持三星原产的S3C24A0开发板
💻 C
字号:
//================================================
// Watch-dog timer Interrupt Request Test
// Watchdog.c 24a0A
//================================================
#include "24a0addr.h"
#include "24a0lib.h"
#include "watchdog.h"

volatile int isWdtInt;

void Ch8_WDT_Test(void)
{
    rINTSUBMSK  &= ~(BIT_SUB_WDT | ~BIT_SUB_BATFLT);           
    rINTMSK  &= ~(BIT_WDT_BATFLT); //Watch dog Interrupt service is available
    
     
    pISR_WDT_BATFLT= (unsigned )Wdt_Batflt_Int;
    isWdtInt = 0;

    rWTCON = 0; // wdt reset & interrupt disable
    rWTCON   = ((PCLK/1000000-1)<<8) | (3<<3) | (1<<2); //Prescaler=0x2a(42),Clock division 128,Interrupt enable
    rWTDAT   = 7813 ;          
    rWTCNT   = 7813 ;
    rWTCON   = rWTCON | (1<<5);   //Watch-dog timer enable

    while(isWdtInt != 5); // variable

    Uart_Printf("[ WDT Reset Test]\n");
    Uart_Printf("WDT Reset  after wdt interrupt happened 5 times. \n");    		
 
    // WDT reset enable
    rWTCON = ((PCLK/1000000-1)<<8) |( 1<<5) | (3<<3) | (1);  
    rINTSUBMSK  &= (BIT_SUB_WDT | BIT_SUB_BATFLT);
    rINTMSK |= BIT_WDT_BATFLT;         //WDT Interrupt Mask
}

//---------------------------------------------------------------------
void __irq Wdt_Batflt_Int(void)
{
    if(rSUBSRCPND & 0x00002000){
	rSUBSRCPND = BIT_SUB_WDT;
       Uart_Printf("%d ",++isWdtInt);
    }
    if(rSUBSRCPND & 0x00004000){
	rSUBSRCPND = BIT_WDT_BATFLT;
	Uart_Printf("Battery Fault interrupt occured\n");
    }
    ClearPending(BIT_WDT_BATFLT);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -