void setRTCCtime(void)
{
RTCCFG =0xa3
RTCVALL=0x12 //year 0x
RTCVALH=0
RTCVALL=0x28 //day
RTCVALH=0x09 //month
RTCVALL=0x13 //hour
RTCVALH=5 //weekday
RTCVALL=0x00 //second
RTCVALH=0x50 //min 0x
}
void setRTCCalarm(void)
{
ALRMCFG=0xcf
ALRMVALL=0x12
ALRMVALH=0
ALRMVALL=0x28
ALRMVALH=0x09
ALRMVALL=0x13
ALRMVALH=5
ALRMVALL=0x15
ALRMVALH=0x50
}
void RTCC_Init(void)
{
_asm
movlb 0x0f
movlw 0x55
movwf EECON2,0
movlw 0xaa
movwf EECON2,0
bsf RTCCFG,5,1
_endasm
//TCCFGbits.RTCWREN = 1
RTCCFGbits.RTCEN = 1
// RTCCFGbits.RTCOE = 1
ALRMCFG = 0xC8
ALRMCFGbits.ALRMEN = 1
setRTCCtime()
PIE3bits.RTCCIE = 1
IPR3bits.RTCCIP = 1
setRTCCalarm()
RTCCFGbits.RTCWREN = 0
}
#pragma interrupt InterruptServiceHigh // "interrupt" pragma also for high priority
void InterruptServiceHigh(void)
{
if(PIR3bits.RTCCIF)
{
PIR3bits.RTCCIF = 0
//程序
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)