English
Language : 

PIC32MX440F256H-80I Datasheet, PDF (483/646 Pages) Microchip Technology – 64/100-Pin General Purpose and USB 32-Bit Flash Microcontrollers
PIC32MX3XX/4XX
EXAMPLE 21-4:
CONFIGURING THE RTCC FOR A ONE-TIME ALARM
/*
The following code example will update the RTCC one-time alarm.
Assumes the interrupts are disabled.
*/
unsigned long alTime=0x16153300;// set time to 04 hr, 15 min, 33 sec
unsigned long alDate=0x06102705;// set date to Friday 27 Oct 2006
// turn off the alarm, chime and alarm repeats; clear
// the alarm mask
while(RTCALRM&0x1000);
RTCALRMCLR=0xCFFF;
ALRMTIME=alTime;
ALRMDATE=alDate;
// wait ALRMSYNC to be off
// clear ALRMEN, CHIME, AMASK and ARPT;
// update the alarm time and date
RTCALRMSET=0x8000|0x00000600; // re-enable the alarm, set alarm mask at once per day
21.3.3 REPEAT ALARM
A repeat alarm can be generated by configuring the
Alarm Repeat Counter bits, ARPT (RTCALRM<7:0>) =
0x00 to 0xFF (0 to 255), and the CHIME bit
(RTCALRM<14>) = 0. Once the alarm is enabled and
an alarm event occurs, the ARPT count is decre-
mented by one. Once the register reaches 0, the alarm
will be generated one last time; after which point,
ALRMEN bit is cleared automatically and the alarm will
turn off. The user must re-enable this bit for any new
alarm configuration.
Note: An alarm event is generated when ARPT
bits are = 0x00.
It is recommended to read and verify the Alarm Sync bit
ALRMSYNC (RTCALRM<12>) = 0, before performing
the following configuration steps:
• Disable alarm – ALRMEN (RTCALRM<15>) = 0.
• Disable chime – CHIME (RTCALRM<14>) = 0.
• Configure alarm repeat counter – ARPT
(RTCALRM<7:0>) = 0x00 to 0xFF.
• Configure alarm date and time – Load
ALRMDATE and ALRMTIME registers with the
desired alarm date/time values.
• Configure mask – Load the desired AMASK
value.
• Enable alarm – ALRMEN (RTCALRM<15>) = 0.
Refer to Example 21-5.
EXAMPLE 21-5:
CONFIGURING THE RTCC FOR A TEN TIMES PER HOUR ALARM
/*
The following code example will update the RTCC repeat alarm.
Assumes the interrupts are disabled.
*/
unsigned long alTime=0x23352300; // set time to 23hr, 35 min, 23 sec
unsigned long alDate=0x06111301; // set date to Monday 13 Nov 2006
while(RTCALRM&0x1000);
RTCALRMCLR=0xCFFF;
ALRMTIME=alTime;
ALRMDATE=alDate;
RTCALRMSET=0x8000|0x0509;
// turn off the alarm, chime and alarm repeats; clear
// the alarm mask
// wait ALRMSYNC to be off
// clear the ALRMEN, CHIME, AMASK and ARPT;
// update the alarm time and date
// re-enable the alarm, set alarm mask at once per hour
// for 10 times repeat
© 2008 Microchip Technology Inc.
Preliminary
DS61143E-page 481