The SAMD21 “Y2K” Issue?

The SAMD21 microcontroller in the more recent Arduino board designs had a clock/calendar built-in. It’s one of the operating modes of the Real-Time Counter. There are counter fields fields for seconds, minutes, hours, (optional AM/PM), days, months, and years. However the year field is only 6 bits, allowing for only 64 years starting at a leap year reference point.

This looks like Y2K all over again! If set with a base year of 2000, the date will overflow New Years Day, 2064. Thankfully, I won’t be around by then, but some of you might! I decided to test it out by setting the date December 31, 2063 at one minute to midnight and letting it run, displaying the date and time every 5 seconds. I also monitored the overflow flag and displayed when it got set.

Here’s the perhaps good news with 24-hour clock mode (displaying data as MM/DD/YY):

Current time:12/31/63 23:59:50
Current time:12/31/63 23:59:55
OVERFLOW!
Current time:01/01/00 00:00:00
Current time:01/01/00 00:00:05

And in AM/PM mode:

Current time:12/31/63 11:59:50 PM
Current time:12/31/63 11:59:55 PM
OVERFLOW!
Current time:01/01/00 12:00:00 AM
Current time:01/01/00 12:00:05 AM

So if you are expecting your SAMD21 Arduino board using the clock/calendar to run through the end of the 21st century, don’t reset the overflow flag but add 64 to the year. Sadly there is no way to programatically set overflow flag, so if you need to set the clock in 2064, lets say after a power failure, you will be out of luck.

The alarm feature also has the ability to reset the clock to 01/01/00 00:00:00. A prize goes to whoever can figure out a use for this. It reminds me of an alarm clock that when the alarm goes off starts flashing 88:88.