Skip to content

isStopped()

Arnd edited this page Sep 28, 2020 · 1 revision

This function returns true when the oscillator is stopped and false when the oscillator is running.

Reasons for a stopped oscillator are described on page 15 of the datasheet:

OSF: Oscillator stop flag. A logic 1 in this bit indicates that the oscillator either is stopped or was stopped for some period and could be used to judge the validity of the timekeeping data. This bit is set to logic 1 any time that the oscillator stops. This bit remains at logic 1 until written to logic 0. The following are examples of conditions that can cause the OSF bit to be set:

The first time power is applied. The voltages present on both VCC and VBAT are insufficient to support the oscillator. The EOSC bit is turned off in battery-backed mode. External influences on the oscillator (i.e., noise, leakage, etc.).


Example:

...
DS3231M_Class DS3231M; // Create an instance of the DS3231M
...
void setup() {
  Serial.begin(SERIAL_SPEED);
  while (!DS3231M.begin()) { // Initialize RTC communications
    Serial.println("Unable to find DS3231M. Checking again in 1 second.");
    delay(1000);
  } // of loop until device is located
  while (!DS3231M.isStopped()) { // Clock not running
    Serial.println("The oscillator is stopped. Checking again in 1 second.");
    delay(1000);
  } // of loop until the osciallator has started
...
Clone this wiki locally