Labs / Electronic modules

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.3 · License: CC BY 4.0 · Driver code (misc/ds1232_driver): MIT License

Contents
GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)
GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

I. Module Introduction

Watchdog Module Based on DS1232 Chip with DS1232 chip as the core, integrates power supply monitoring and watchdog timing functions, communicates with the main controller via two digital interfaces DIN / DOUT, the onboard reset button can manually trigger system reset, supports reset control and status indication, provides reliable fault detection and reset guarantee for embedded systems, and is suitable for high-reliability electronic device scenarios.

II. Introduction to Major Chips

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

DS1232 is Maxim a microprocessor monitoring chip (Microprocessor Monitor) launched by the company.

Its main functions are as follows:

Therefore, DS1232 is commonly used in scenarios that require high reliability such as microcontrollers and embedded systems.

2.1 Chip Overview

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

DS1232 is a power supply monitoring chip with a watchdog function, which is mainly used to ensure the stable operation of a single-chip microcomputer system when the power supply is abnormal or the program crashes, and realizes automatic reset by outputting a reset pulse. This chip adopts an 8-pin SMD package, has a built-in temperature compensation circuit, provides two options of power supply monitoring accuracy of 5% or 10%, and the threshold can be set via the TOL pin.

2.2 Pin Definition

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

DS1232 The pin functions of the chip are shown in the following table:

Pin Name

Function Description

VCC

Power Input (+ 5V)

GND

Power Ground

RST inverse

Reset output (active low, connected to MCU RESET pin)

RST

Reset Output (active high, optional)

ST

Watchdog refresh signal input (high-to-low transition)

PBRST

External manual reset input (active low, internal debounce)

TOL

Power supply threshold selection (connect to GND = 4.75V, connect to VCC = 4.5V)

TD Watchdog Timeout Selection (the connection method determines 150ms/600ms/1.2s)

TD

Watchdog timeout selection (150ms/600ms/1.2s determined by wiring)

NC

NC (No function, for SOIC package)

2.3 Functional Block Diagram

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

DS1232 The internal structure of the chip is shown in the figure, which mainly consists of the following parts:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

DS1232 monitors the VCC voltage via the power supply monitoring unit to detect if it drops below the set threshold. Once an abnormality is detected, it immediately outputs a reset signal, and maintains a reset delay of at least 250ms after power is restored to ensure system stability. Meanwhile, the chip supports a key reset input, which will also generate a reset pulse of no less than 250ms after internal debouncing. In addition, it has a built-in watchdog timer: if no trigger pulse from the processor is received within the set timeout period (150ms/600ms/1.2s), the system is considered to be hung up, and a reset signal is automatically issued.All reset requests are processed by the delay processing unit and then output uniformly via the output driver / / RST̅, to ensure that the microprocessor receives reliable reset control.

2.4 Performance Parameters

DS1232 's performance parameters can be analyzed from four dimensions: DC characteristics, AC characteristics, capacitance characteristics and key notes:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

DC electrical characteristics (at 0℃~70℃, VCC = 4.5~5.5V) are as follows:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

AC Electrical Characteristics (0℃~70℃, VCC = 5V±10%) are as follows:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

The key notes are as follows:

2.5 Reference Circuit

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

2.6 Chip Configuration

Note that the DS1232 is designed for 5V operation. If the IO level standard of the MCU in use is 3.3V, ensure proper level compatibility or select a 3.3V monitoring chip to avoid damaging the MCU.

Below are the results of our module test. After powering on the module, we connected channel 0 of the logic analyzer to the RST interface of the watchdog module:

When TD is connected to VCC, the pulse interval shall not be greater than 1.2 seconds, and it is recommended to input a square wave with a frequency of 2Hz:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)
GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

TD When floating, the pulse interval shall not exceed 600 ms, and a square wave with an input frequency of 10 Hz is recommended:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

TD is connected to GND, the pulse interval shall not exceed 0.15 seconds, and a square wave with an input frequency of 30Hz is recommended:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

Here, we can see that in practical applications, the watchdog feeding frequency needs to be faster than what is specified in the chip datasheet, because DS1232 factors such as internal timing accuracy error, sampling delay, and pulse width requirements mean that strictly feeding the watchdog at the theoretical limit value will easily lead to failures. Therefore, in engineering practice, it is always recommended to set the watchdog feeding period to 1/2 of the timeout period or even shorter.

In the provided datasheet, we can also see that the timing accuracy is approximately −58.33% / + 66.67%(relative to the typical value):

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

None.

2.8 PCB Routing Precautions

None.

III. Instructions for Circuit Engineering and Module Usage

3.1 Circuit Source Engineering

To obtain the source project of the circuit, please follow the official account [Freak Embedded]

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_Watchdog Module Based on DS1232 Chip_v1.0_2025-10-24.pdf 1.8 MB

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

This module provides a pair of digital input/output interfaces DIN (RESET) and DOUT (WDI): Note that IN and OUT are defined relative to the main controller;DIN (RESET) functions as "main controller output, module input", which is used for the main controller to send reset control commands to the module or receive reset signals output by the module;DOUT (WDI) functions as "module output, main controller input", through which the module outputs a watchdog feeding detection signal to the main controller, and the main controller needs to periodically trigger WDI to prevent the module from triggering a system reset.

This module is equipped with a manual reset button, which allows manual triggering of system reset in emergency scenarios; it is configured with TD and TOL three short-circuit points, and users can flexibly configure by short-circuiting different points:

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and connect the watchdog module based on the DS1232 chip to communicate with the main controller via the DIO interface.

Here, we first need to solder the short-circuit points of the GraftSense-DS1232 watchdog module on the back side for TD and TOL to VCC respectively:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

Then use the HY2.0-4P connection cable to connect the module to the GraftPort-RP2040 development board's DIO0 interface:

The module connections are shown in the following table:

Development Board Pins

Module Pins

Description

Pin 6

DIN

Watchdog Input: The MCU periodically toggles this pin to feed the watchdog.

Pin 7

DOUT

Watchdog reset output (ResetOutput), the MCU can detect the reset signal via interrupt

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

Enter ds1232_driver to search, and the following will be displayed:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

Click to copy the local installation command:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

Here, we can use the mip tool to import module driver library code. Below are the usage commands for the mpremote tool:

mpremote mip install github:FreakStudioCN/GraftSense-Drivers-MicroPython/misc/ds1232_driver

Import the DS1232 watchdog driver - MicroPython driver code, then copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-        
# @Time    : 2025/8/25 6:46 PM
# @Author  : Li Qingshui
# @File    : main.py       
# @Description : External DS1232 watchdog module test program

# ======================================== Import Modules =========================================

# Import hardware-related modules
from machine import Pin, Timer
# Import time-related modules
import time

# Import the DS1232 watchdog module
from ds1232 import DS1232

# ======================================== Global Variables ============================================

# GPIO connected to the DS1232 WDI pin
WDI_PIN = 7
# GPIO connected to the DS1232 RST pin
RST_PIN = 6
# Feed interval, in ms
FEED_INTERVAL = 300
# Delay before stopping feeding, in ms
STOP_FEED_DELAY = 10000

# Define global variables
wdg = None
stop_feed_timer = None
# Global flag: detects whether RST was triggered
system_reset_flag = False

# ======================================== Functions ============================================

def rst_callback(pin: Pin) -> None:
    """
    DS1232 RST pin trigger callback function.

    Args:
        pin (Pin): The GPIO pin that triggered this callback.

    Returns:
        None
    """
    # Declare global variables
    global system_reset_flag

    # Set the flag; the main loop breaks out after detecting it
    system_reset_flag = True
    print("DS1232 RST pin triggered.")

def stop_feed_callback(t: Timer) -> None:
    """
    Timer callback: stop automatic feeding, simulating a feed failure to trigger a reset.

    Args:
        t (Timer): Timer object

    Returns:
        None
    """
    # Declare global variables
    global wdg, stop_feed_timer

    print("Stop feeding watchdog.")
    # Stop feeding
    wdg.stop()
    # Stop this timer so it runs only once
    stop_feed_timer.deinit()

# ======================================== Custom Classes ============================================

# ======================================== Initialization ==========================================

# Power-on delay of 3 s
time.sleep(3)
# Print debug information
print("FreakStudio:: DS1232 Watchdog Test Program.")

# Initialize the DS1232 watchdog
wdg = DS1232(wdi_pin=WDI_PIN, feed_interval=FEED_INTERVAL)
# Feed manually immediately
wdg.kick()

# Configure the RST pin as input with pull-up, triggering the callback
rst_pin = Pin(RST_PIN, Pin.IN, Pin.PULL_UP)
rst_pin.irq(trigger=Pin.IRQ_FALLING, handler=rst_callback)

# Define a timer to delay stopping feeding
stop_feed_timer = Timer()
stop_feed_timer.init(period=STOP_FEED_DELAY, mode=Timer.ONE_SHOT, callback=stop_feed_callback)

# ========================================  Main Program  ===========================================

# Start feeding
print("Start feeding watchdog.")

try:
    # Infinite loop
    while True:
        # Print a log with timestamp
        current_time = time.ticks_ms()
        print(f"System running... Time: {current_time} ms")

        # Check the RST trigger flag
        if system_reset_flag:
            print("System starting reset...")
            # Break out of the while loop
            break

        time.sleep(1)
except KeyboardInterrupt:
    print("Program interrupted.")
finally:
    # Stop feeding
    wdg.stop()
    # Stop the timer
    stop_feed_timer.deinit()

Here, first of all, the MCU will delay for 3 seconds after power-on to complete stable startup, then print debug information, and create a DS1232 object to initialize the WDI pin and the Timer to implement automatic periodic watchdog feeding; meanwhile, the kick () function is called immediately to manually toggle the WDI once to ensure the watchdog starts timing; next, configure the RST pin as input pull-up and bind an interrupt callback for detecting the DS1232 timeout reset signal; then start a one-shot timer to delay the stop of automatic watchdog feeding, so as to simulate watchdog feeding failure to trigger a reset. The program then enters the main loop:

  1. Prints the system running time (in milliseconds) every second.
  2. Check the system_reset_flag flag; if the RST pin is triggered, print the reset information and break out of the loop.
  3. Catch KeyboardInterrupt to allow users to manually interrupt the program.

After the loop ends, stop the finally block from automatically feeding the DS1232 watchdog and release the timer resources to ensure the status safety of the MCU and Timer, thus completing the entire watchdog test process.

Burn the code, open a terminal, and use the mpremote tool to connect to the main controller; the output is as follows:

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

After a restart, before we stop feeding the watchdog, while the MCU is normally sending pulses to the watchdog, press the RST button on the watchdog module, and you will see that a normal reset can still be triggered. This design is intended to provide a reliable external hard reset mechanism: when the software malfunctions or you need to manually restart the entire board, manual reset should have the highest priority.

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)

IV. Drivers

ds1232_driver.zip 10 KB

None.

VI. Revision History

Document Version

Date of Revision

Modifier

Modified Content

v1.0

2025-10-24

Li Zisheng

Initialize the document

The BOM sheet has not been finally checked, the driver has not been re-verified, and the 3.3 application experiment

Not yet specified.

v1.1

2025-12-29

Li Zisheng

Added application experiments and production files

v1.2

2025-12-31

Xin Ruili

Create an open version of the document based on the internal document version v1.1.

v1.3

2026-03-29

Xin Ruili

Modified the application experiment section

VII. Relevant Materials

7.1 Chip Datasheet

DS1232 Watchdog Chip.pdf 99 KB

7.2 Unique Icons for PCB Silkscreen

GraftSense - Watchdog Module Based on DS1232 Chip (Open Version)