laitimes

DS3231 clock chip

author:APPLE频道

Loading...

I. Preface

The DS3231 is a clock chip with a punctuality of 2ppm. The basic functions of the project are tested below, and the basic scheme is used to verify the basic scheme for later re-engineering. • Basic test data is provided.

DS3231 clock chip

Second, the test circuit

  Design the circuit, where the microcontroller is STM32F103. Connect the DS3231 chip via the I2C bus. Lay single-sided PCB, suitable for one-minute plate making. A minute later, the test board was obtained. Welding test below.

DS3231 clock chip
DS3231 clock chip

▲ Figure 1.2.1 Test circuit diagram

DS3231 clock chip

▲ Figure 1.2.2 PCB diagram of experimental circuit

3. Welding test

  Soldering the circuit board, which also has a jumper that is not shorted with 0 ohms. The soldered microcontroller is an APM32 microcontroller, which is said to be fully compatible with STM32 microcontrollers. Let's put it to the test.

DS3231 clock chip

  First, the STM32's I2C bus is used to test whether the DS3231 can be accessed. Enable the I2C function in CubeMX and set the clock frequency to 100kHz. According to the DS3231 data sheet, it is known that it corresponds to an I2C bus address of 0x68. Call the I2C function in the HAL library to determine if there is a device at this address on the bus. Please note that the device address here should be shifted one bit from the original address to the left, and finally form the first 7 bits of the first byte. For the winter rain DS3231, it corresponds to the 0xd0.

DS3231 clock chip
DS3231 clock chip
DS3231 clock chip

  Observe the I2C bus waveform, with the clock signal on top and the data signal on the bottom. After the start signal, the address of the DS3231 is sent next, followed by a 0, indicating the write to the I2C device. This is followed by a reply signal returned by the DS3231. Finally, there is the I2C stop signal. This gives you the right access to the DS3231 chip.

DS3231 clock chip

4. Basic functions of the DS3231

  The DS3231 has 19 internal registers, which are read below. First, the I2C write command is used to write to the address of the read register. Start with 0 every time. Then read 19 registers. According to the DS3231's data sheet, the clock and the date are from front to back. As you can see, the first byte is the second count of the clock, which is BCD encoded. The last two digits are the temperature values.

DS3231 clock chip
DS3231 clock chip
DS3231 clock chip

  When designing the schematic, forget to add a pull-up resistor to the DS3231 clock output. In this way, the clock signal cannot be observed. A 20k ohm resistor is temporarily flown up on the circuit board to observe the clock signal output at the first pin. By default, this pin outputs a clock signal. Using an oscilloscope probe, differential measurements are made locally, and on the oscilloscope, the output clock waveform is displayed. It can be seen that the clock has a frequency of 32.768kHz. Because it is an open output, the rising edge of the pulse signal is relatively slow.

DS3231 clock chip
DS3231 clock chip
DS3231 clock chip

  The frequency of the pulse was measured using a FLUKE45, and the result showed an inaccurate 32.768kHz, and due to the accuracy of the multimeter, it could only be displayed to an accuracy of 1Hz.

DS3231 clock chip

  The clock signal is tested below using an FA-2 frequency meter. It can be displayed at a frequency of up and down 0.01Hz. It's the most accurate frequency meter I've ever had.

DS3231 clock chip

  By pressing the GATE button to change the frequencymeter gating time to 10 seconds, the resolution of the frequencymeter can reach 1/100,000 Hz, and you can see that the frequency stability of the DS3231 is in thousandths of a second. However, by modifying the weathering compensation registers in the DS3231, the change in frequency cannot be observed.

DS3231 clock chip

  In addition to the 32.756kHz pulse output at the first pin, the DS3231 can also be registered-controlled at the INT pin square wave output. The waveform of the INT pin is observed below. In principle, it requires an externally applied pull-up resistor. The pull-up resistor of the IO port of the microcontroller itself is applied here, and you can see that there is a corresponding output square wave. The frequency of a square wave is 8.096kHz. By modifying the value of the control register, you can change the frequency of the square wave. It's now 1024Hz.

DS3231 clock chip
DS3231 clock chip
DS3231 clock chip
DS3231 clock chip

※Summary※

  This article tests the basic functions of the DS3231 clock chip. This provides a basic experience for later engineering applications. It has an integrated quartz crystal as well as a temperature sensor. Capable of achieving 2ppm clock timing accuracy. Later, its timing function and output pulse function were used to optimize the design of a previous device.

DS3231 clock chip

Resources

[1]

https://www.analog.com/media/en/technical-documentation/data-sheets/DS3231.pdf: https://www.analog.com/media/en/technical-documentation/data-sheets/DS3231.pdf

[2]

DS3231: https://www.analog.com/media/cn/technical-documentation/data-sheets/DS3231_cn.pdf

Read on