The crystal runs at 32.768KHz. If repeatedly divided by two this can be reduced to a 1Hz clock, one cycle per second, which is why this frequency is used. When computers move the bits of a number one position to the right, this divides the number by two. For example 52 decimal is 110100. Shifting the bits one to the right gives 11010 which is 26 decimal, half of 52.
Use this principle on 32768Hz. 32768 / 2 = 16384 / 2 = 8192 / 2 = 4096 / 2 = 2048 / 2 = 1024 / 2 = 512 / 2 = 256 / 2 = 128 / 2 = 64 / 2 = 32 / 2 = 16 / 2 = 8 / 2 = 4 / 2 = 2 / 2 = 1. Thus providing a signal which occurs exactly once every second, which can be used to count the seconds in a date and time.
The DS1302 has a trickle charge circuit built in, if the backup battery used is rechargeable, the DS1302 can be configured to trickle charge the backup battery while the supply voltage is present. In the Python code this feature has been turned off as a non-rechargeable coin cell battery is being used.
3V3
|
Vcc (Pin 1)
|
SCLK (GPIO 2)
|
SCLK (Pin 7)
|
CE (GPIO 3)
|
CE (Pin 5)
|
I/O (GPIO 4)
|
I/O (Pin 6)
|
GND
|
GND (Pin 4)
|