/// <summary> /// Enables / Disables the square wave generation function of the clock. /// Requires a pull-up resistor on the clock's SQW pin. /// </summary> /// <param name="Freq">Desired frequency or disabled</param> /// <param name="OutCtrl">Logical level of output pin when the frequency is disabled (zero by default)</param> public void SetSquareWave(SQWFreq Freq, SQWDisabledOutputControl OutCtrl = SQWDisabledOutputControl.Zero) { byte SqwCtrlReg = (byte)OutCtrl; SqwCtrlReg <<= 3; // bit 7 defines the square wave output level when disabled // bit 6 & 5 are unused if (Freq != SQWFreq.SQW_OFF) { SqwCtrlReg |= 1; } SqwCtrlReg <<= 4; // bit 4 defines if the oscillator generating the square wave frequency is on or off. // bit 3 & 2 are unused SqwCtrlReg |= (byte)Freq; // bit 1 & 0 define the frequency of the square wave WriteRegister(DS1307_SQUARE_WAVE_CTRL_REGISTER_ADDRESS, SqwCtrlReg); }
/// <summary> /// Enables / Disables the square wave generation function of the clock. /// Requires a pull-up resistor on the clock's SQW pin. /// </summary> /// <param name="Freq">Desired frequency or disabled</param> /// <param name="OutCtrl">Logical level of output pin when the frequency is disabled (zero by default)</param> public void SetSquareWave(SQWFreq Freq, SQWDisabledOutputControl OutCtrl = SQWDisabledOutputControl.Zero) { byte SqwCtrlReg = (byte) OutCtrl; SqwCtrlReg <<= 3; // bit 7 defines the square wave output level when disabled // bit 6 & 5 are unused if (Freq != SQWFreq.SQW_OFF) { SqwCtrlReg |= 1; } SqwCtrlReg <<= 4; // bit 4 defines if the oscillator generating the square wave frequency is on or off. // bit 3 & 2 are unused SqwCtrlReg |= (byte) Freq; // bit 1 & 0 define the frequency of the square wave WriteRegister(DS1307_SQUARE_WAVE_CTRL_REGISTER_ADDRESS, SqwCtrlReg); }