RTC for Timestamping of Temperature Measurements

In this application note, the RTC is used to keep track of real time in order to take a temperature measurement at defined intervals and generate a corresponding timestamp. In this case, a flag "tick" is raised to indicate that the subroutine "tock" may be called from the main while loop. This is done instead of calling "tock" directly from the ISR to ensure that the procedure does not have interrupt priority.

The TWI module used to interface with the temperature sensor requires an interrupt to complete operation; this means a deadlock may occur from an interrupt being generated inside another interrupt if their respective priorities are not correctly configured. In the given example, the "tock" subroutine is called from the main loop for simplicity, and therefore the configuration of interrupt priorities is not necessary. The functionality of the "tock" subroutine includes taking a temperature measurement, updating the time, and sending the updated buffer to the SD card.