Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

Share this Page URL

5: Interrupts > Tips & Tricks - Pg. 84

84 Chapter 5 Setting the date and time of day becomes an equally simple task with the following code: rtccTimeDate TD = { 0x06, 0x20, // 0x01, 0x11, // 0x12, 0x03, // 0x30, 0x01};// RtccWriteTimeDate( &TD, FALSE); year day, month hour, weekday sec, min Perhaps even more interesting is how the alarm mask definition is simplified: RtccSetAlarmRpt( RTCC_RPT_YEAR, TRUE); As a pro, consider how, instead of setting the AMASK register to a cryptic binary value, we can use a self-explanatory constant: RTCC_RPT_YEAR to decide when the alarm match should trigger our next interrupt. As a con though, consider that the RTCC_RPT_YEAR constant is not documented in the device datasheet but only in the rtcc.h header file (and simply listed in the help file .chm). Once you find it, you will be hard pressed to make sure to match it to the desired pattern of bits in the AMASK register as per the device datasheet. In the next few chapters we will see more such examples of use of the peripheral libraries and in the end I will let you decide how and when you want to take things in your own hands and