#pragma interrupt InterruptHandlerHigh
void InterruptHandlerHigh (void)
{
PIR3bits.RTCCIF=0;
read();
}
#pragma code high_vector =0x0008
void InterruptVectorHigh (void)
{
_asm
GOTO InterruptHandlerHigh
_endasm
}
#pragma code
void main(void)
{
//unsigned int i;
OSCCONbits.SCS = 3;
OSCCONbits.IRCF = 7;
OSCTUNEbits.PLLEN = 1; //定义使用内部振荡器
TRISAbits.TRISA5 = 0;
DSCONHbits.RTCWDIS = 0;
ANCON0 = 0XFF;
ANCON1 = 0X1F;
T1CONbits.T1OSCEN = 1;
RTCC_Init();
PIR3bits.RTCCIF = 0;
PIE3bits.RTCCIE = 1;
IPR3bits.RTCCIP = 1;
while(1)
{
}
}
void unlock(void)
{
_asm movlb 0x0F _endasm
INTCONbits.GIE = 0;
EECON2 = 0X55;
EECON2 = 0XAA;
RTCCFGbits.RTCWREN = 1;
}
void setALARM(void)
{
unsigned int t;
unlock();
ALRMCFGbits.ALRMEN = 0;
while(RTCCFGbits.RTCSYNC==1);
ALRMCFG |= 0x02;
ALRMVALL=0X01; //day 11日
ALRMVALH=0X01; //month 12月
ALRMVALL=0X00; //hour 14时
ALRMVALH=0X05; //weekday 星期五
ALRMVALL=0X00; //second 59秒
ALRMVALH=0X00; //minute 39分
ALRMCFG |= 0x02;
alarm.day = ALRMVALL;
alarm.month = ALRMVALH;
alarm.hour = ALRMVALL;
alarm.week = ALRMVALH;
alarm.seconds = ALRMVALL;
alarm.minutes = ALRMVALH;
RTCCFGbits.RTCEN = 1;
RTCCFGbits.RTCWREN = 0;
}
void setRTCCtime(void)
{
unlock();
RTCCFGbits.RTCEN = 0;
ALRMCFGbits.ALRMEN = 0;
ALRMCFGbits.AMASK = 0;
ALRMRPT = 0;
ALRMCFGbits.CHIME = 1;
PADCFG1 = 0X00;
RTCCFG |= 0x03;
RTCVALL=0X15; //year 0x
RTCVALH=0X0;
RTCVALL=0X31; //day
RTCVALH=0X12; //month
RTCVALL=0X23; //hour
RTCVALH=0X04; //weekday
RTCVALL=0X58; //second
RTCVALH=0X59; //min 0x
RTCCFGbits.RTCOE = 0;
ALRMCFGbits.ALRMEN = 1;
RTCCFGbits.RTCWREN = 0;
}
void RTCC_Init(void)
{
setRTCCtime();
setALARM();
}
为什么中断进不去呢,求高手来看一下,时钟正常,alarm寄存器也写入了,就是在中断进不去?为什么?
|