Rtc seconds count not updating
Peripherals in the EFM32 libraries can generally be found as a pointer from a memory address.
When you go beyond that range, we turn to the Real Time Clock (RTC), which keeps track of a larger number of ticks, making it suitable to be used to keep track of seconds, hours, days, weeks, months and years, and it does so in a very low power state.This is part three of a five part series on how to build a sprinkler timer using the EFM32 series of MCUs.In the first two parts, we learned how to use the onboard LCD screen and onboard pushbuttons to create an on-screen display, similar to what you would see on, well, a sprinkler timer.We have looked at fast-running timers in chapter five, but those aren’t necessarily the best to use for long-running time keeping purposes such as keeping track of the time of day and the day of the year.The best timer for that purpose is the Real Time Clock (RTC) which is the topic of this section.I will consider zero seconds to be midnight, and keep track of all time from zero.
The RTC has two compare registers that can trigger interrupts when they are reached.
This is the setup function: You can see that the clock divisor is huge at 32768.
The Reference Manual for RTC shows the divisors in integers from 1 to 15, while the CMU requires inputs to be in the form of 2^DIVISOR. So this is why I had to send in such a huge divider.
The RTC is a 24-bit timer where each tick can be configured in the microseconds-to-seconds range.
This allows for a counting range between 512 seconds to 194 days before timer rollover, depending on the length of each tick. I chose the RTC instead of the BURTC for this lesson because I will be running the LCD all of the time, which requires EM2, so I do not need to drop all the way into EM4.
When either of these compare registers are reached, the RTC interrupt handler will run and take care of advancing the clock or starting/stopping the sprinkler.