Including a Real Time Clock makes the XMC4200 a rare breed amongst microcontrollers. It's also a blessing for me, as my project requires time-keeping and scheduling functions.
When you configure the RTC APP in DAVE you are presented with two tabs.
In the General Settings tab, pictured below, current time and alarm time can be set.
What we learn immediately from the image below is that, as far as the RTC is concerned, the world was created on January 1, 1970. 
Figure 1 - RTC General Settings
The second tab is for configuring interrupt settings. I used this tab to set up an interrupt every second.
For the moment, I have not enabled Alarm interrupts. However, in the future I will return to this setting because in the end, I will use the Alarm interrupt to activate the sprinkler.
Figure 2 - RTC Interrupt Settings
The interrupt handler that is executed every second is shown below. For the moment, I use it to toggle the user LED.
The first time I read from the RTC I noticed that January is month 0.
And the 1st day of each month is day 0.
Figure 3- Month 0, Day 0?
Since I prefer 1970.01.01 over 1970.00.00, I decided to create a new data type called human_time_t and a couple of functions to convert between the native RTC format and the preferred 'human' format.
Figure 4 - Functions to convert between time formats
I was curious to see how leap years were handled. 
In the first test, I set the date to 2020.02.28 and the time to 23:59:45.
When I read back the time the following was displayed:
Figure 5 - February 28, 2020
A few moments later I read back the following:
Figure 6 - February 29, 2020
So, February 28 transitioned to February 29. That is good, because 2020 is a leap year.
I did the same type of test for 2021.
Initially the date and time displayed was:
Figure 7 - February 28, 2021
A few moments later, the following was read back:
Figure 8 - March 1, 2021
This time February 28 transitioned to March 1. This is perfectly fine since 2021 is not a leap year.
Up until now I had never written any microcontroller code that required a Real Time Clock function... so it was pretty cool.
Thank you for taking the time to read this blog,
Dan









