我看到有些资料上 用pISR_WDT_AC97这个地址作为看门狗的中断服务地址。 pISR_WDT_AC97=(unsigned)WatchDog_ISR; 但是我自己写的程序却没有产生中断,什么回事? #define GLOBAL_CLK 1
#include "def.h" #include "2440addr.h" #include "mmu.h" #include "option.h"
#define LED1 (1<<5) // rGPB[5] =1 ; #define LED2 (1<<6) // rGPB[6] =1 ; #define LED3 (1<<7) // rGPB[7] =1 ; #define LED4 (1<<8) // rGPB[8] =1 ;
static int index=0;
void Delay1(int time) { unsigned int i,j; for(i=1;i<100;i++) for(j=1;j<time;j++) ; }
void LightLED(void){ if ( index==1 ) rGPBDAT=rGPBDAT & ~LED1; if ( index==2 ) rGPBDAT=rGPBDAT & ~LED2; if ( index==3) rGPBDAT=rGPBDAT & ~LED3; if ( index==4 ) rGPBDAT=rGPBDAT & ~LED4; Delay1( 20000 ) ; rGPBDAT = 0xfff; } void __irq WatchDog_ISR(void){ //清除中断 ClearPending(BIT_WDT_AC97); ClearPending(BIT_SUB_WDT); if (index >4 ){ index=1; } else{ rINTMSK|=0x200;//mask watchdog timer interrupt index++; } LightLED(); }
void EINT_Init(void){ ClearPending(BIT_WDT_AC97); ClearPending(BIT_SUB_WDT); pISR_WDT_AC97=(unsigned)WatchDog_ISR; //Prescaler value=100; lock dividion factor=128;PCLK=67.5MHz //t_watchdog=1/[PCLK/(Prescaler value+1)/Division_factor]=0.0002 //disable watchdog rWTCON=0x6418; //01100100 00 0 11 0 0 0 //周期T=WTCNT*t_watchdog=3S rWTDAT=15000; rWTCNT=15000; rWTCON=0x643c; //01100100 00 1 11 1 0 0 EnableIrq(BIT_WDT_AC97); EnableIrq(BIT_SUB_WDT); //清除watchdog中断屏蔽位 rINTMOD&=0xFFFFFDFF; } void Main(void){
ChangeClockDivider(3,1); ChangeMPllValue(127,2,1); MMU_Init(); EINT_Init(); while (1); } |