#include "config.h" typedef int (*PUpdateFun)(void); #define EINTTIME 5 void RTCIni(void) { PREINT = Fpclk/32768-1; PREFRAC = Fpclk-(Fpclk/32768)*32768; SEC = 0; CCR = 0x01; } void DelayNS(unsigned int dly) { uint32 i; for(;dly>0; dly--) for(i=0; i<5000; i++); } void IRQ_Eint1(void) { uint32 sec=0; uint32 times; uint32 bak; uint16 f; PUpdateFun update; RTCIni(); /*初始化RTC*/ Led_Init(); while((EXTINT&0x02)!=0) /*等待中断结束*/ { EXTINT = 0x02; } times = CTIME0; bak = times&0x3F; if(bak>EINTTIME) /*中断时间是否有EINTTIME秒*/ { HC595_SendDat(0xF0); DelayNS(10); HC595_SendDat(0x0F); DelayNS(10); memcpy((void *)0x81000000,(const void *)0x80180000,0x80000); /*把flash中更新模块的代码拷贝到ram*/ update = (PUpdateFun)0x81000000; /*运行ram*/ update(); } VICVectAddr = 0; }