新聞中心

S3C2440-WDT

作者: 時(shí)間:2016-12-02 來(lái)源:網(wǎng)絡(luò) 收藏




看門狗定時(shí)器計(jì)數(shù)寄存器:

WTCNT包含看門狗定時(shí)器的當(dāng)前值。



下面是看門狗復(fù)位的程序:

#define WTCON (*(volatile unsigned *) 0x53000000)
#define WTDAT (*(volatile unsigned *) 0x53000004)
#define WTCNT (*(volatile unsigned *) 0x53000008)

int WdtMain(){
WTCON = 0x64<<8; //Prescaler=100,時(shí)鐘頻率為3.9KHz
WTCON |= (0x1<<5)|(0x1); //看門狗定時(shí)器超時(shí),發(fā)出復(fù)位信號(hào)
WTCON |= 0x3<<3; //Division=128
WTDAT = 0x2DC6; //使復(fù)位時(shí)間為3s
WTCNT = 0x2DC6;
while(1){}
return 0;
}

看門狗定時(shí)程序:
#define rGPBCON (*(volatile unsigned *)0x56000010)
#define rGPBDAT (*(volatile unsigned *)0x56000014)
#define rGPBUP (*(volatile unsigned *)0x56000018)
#define rSRCPND (*(volatile unsigned *)0x4a000000)
#define rINTMSK (*(volatile unsigned *)0x4a000008)
#define rINTPND (*(volatile unsigned *)0x4a000010)
#define rSUBSRCPND(*(volatile unsigned *)0x4a000018)
#define rINTSUBMSK(*(volatile unsigned *)0x4a00001c)
#define rWTCON (*(volatile unsigned *)0x53000000)
#define rWTDAT (*(volatile unsigned *)0x53000004)
#define rWTCNT (*(volatile unsigned *)0x53000008)
#define _ISR_STARTADDRESS 0x33ffff00
#define pISR_WDT_AC97 (*(unsigned *)(_ISR_STARTADDRESS+0x44))
#define U32 unsigned int

void delay(int a)
{
int k,i,j;
for(k=0;k<a;k++)
for(i = 0; i < 0xff; i++)
for(j = 0; j < 0xff; j++)
;
}

void __irq WDT_ISR(void){
rGPBDAT |= 0x1;
delay(100);
rGPBDAT &= 0xfe;
rSUBSRCPND = 0x1<<13;
rSRCPND = 0x1<<9; //SRCPND 通過(guò)寫(xiě)入數(shù)據(jù)清零,如果不清零,會(huì)反復(fù)進(jìn)行請(qǐng)求
rINTPND = 0x1<<9;
}

int Main(){
rGPBCON = 0xfffc;
rGPBCON |= 0x1;
rWTCON = 0x64<<8; //Prescaler=100
rWTCON |= (0x1<<5)|(0x1<<2); //WDT計(jì)時(shí)器使能,中斷使能
rWTCON |= 3<<3;
rWTDAT = 0x1E84; //使中斷時(shí)間為2s
rWTCNT = 0x1E84;
rSUBSRCPND = 0x1<<13;
rSRCPND = 0x1<<9; //SRCPND 通過(guò)寫(xiě)入數(shù)據(jù)清零,如果不清零,會(huì)反復(fù)進(jìn)行請(qǐng)求
rINTPND = 0x1<<9;
rINTSUBMSK = "(0x1<<13);
rINTMSK = "(0x1<<9);
pISR_WDT_AC97 = (U32)WDT_ISR;
while(1);
return 0;
}

上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: S3C2440WD

評(píng)論


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

關(guān)閉