traptw1thin, do you want to measure something in 100 ms without the need to know the year and month, or do you have to know the year and month ?
I have read the thread in that link. They suggest to track millis() on top of the DS3231.
// global variable
volatile unsigned long millis_in_interrupt;
void Interrrupt_1Hz()
{
millis_in_interrupt = millis();
}
void loop()
{
noInterrupts();
unsigned long millis_in_interrupt_copy = millis_in_interrupt;
interrupts();
unsigned long time_passed_since_interrupt = millis() - millis_in_interrupt_copy;
}
However, when using I2C for the DS3231 and the 1Hz output together, there might be a sync mismatch. I can not guarantee that it is reliable.
It is possible to use only millis() for a 10 Hz timer. Some Arduino boards have a crystal, that is accurate. But some have an inaccurate resonator. However, the code by CrossRoads does not stay in pace with the accuracy of the crystal and does not prevent the rollover problem. For a good 10 Hz timer it has to be:
if ( (currentMillis - previousMillis) >= duration) {
previousMillis += duration;
...
In that case the millis() and RTC are seperated and you can not add the real RTC value to that.
The obvious solution is to use a RTC with 0.1s accuracy and SPI interface. I don't know such a RTC.
There are RTCs with 1kHz output. If you are very careful with the code, then even an Arduino Uno can do that.
Perhaps getting the real time during startup and in between the measurements and then let the software take care of it with the 1kHz interrupt.