Skip to the content
2 layers80 × 60 mmATmega32 Clock, the printed circuit board in 3D

GROUP8

Size
80 × 60 mm
Copper layers
2
Thickness
1.6 mm
Parts
20
Nets
39
Pads
87
Tracks, vias
96, 0
Pours
2
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
30 Jun 2026
Updated
2 Jul 2026

Overview

ATmega32 Clock is an open-source printed circuit board by chikotaraufu-netizen, from the chikotaraufu-netizen/ATmega32_Timer_Digital_Clock_Scheduler- repository on GitHub. It is a 2-layer board of 80 × 60 mm with 20 parts on 39 nets, routed with 96 tracks and 0 vias.

It is built around the ATMEGA32A-PU. Its parts include 6 resistors, 5 capacitors, 4 switches, 2 diodes and 1 IC. It belongs with the lEDs and displays boards and the AVR (ATmega, ATtiny) boards of this library.

Main components

1

README

README.md

⏱️ ATmega32 Timer-Based Digital Clock & Task Scheduler

Platform Clock License Build

A precision digital clock and cooperative task scheduler built on the ATmega32 microcontroller, leveraging Timer1 in CTC mode for accurate 1Hz timekeeping with USART-based HH:MM:SS display and multi-task LED scheduling.


📋 Table of Contents


🎯 Project Overview

This project implements a real-time digital clock and cooperative task scheduler on the ATmega32 microcontroller running at 8 MHz with an external crystal oscillator. The system uses Timer1 in CTC (Clear Timer on Compare Match) mode with a prescaler of 1024 and an OCR1A value of 7812 to generate a precise 1 Hz interrupt—the heartbeat of the entire system.

The clock displays time in HH:MM:SS format via the USART interface at 9600 baud, while the task scheduler manages two LED tasks using a non-blocking, ISR-flag-driven architecture:

  • Status LED (PB0): Toggles every 2 seconds
  • Task LED (PB1): Flashes every 5 seconds

Three hardware buttons provide user interaction for time setting, field incrementing, and clock reset—all with internal pull-up resistors and active-low logic.


✨ Features

FeatureDescription
Precision TimekeepingTimer1 CTC mode with 1024 prescaler generates accurate 1Hz tick
USART DisplayReal-time HH:MM:SS output at 9600 baud (8N1)
Task SchedulerCooperative, flag-based scheduler with configurable task intervals
Status LEDHeartbeat indicator toggling every 2 seconds
Task LEDPeriodic flash every 5 seconds for task activity indication
Time Set ModeCycle through HH → MM → SS fields with SET button
Increment FunctionIncrement the currently selected time field
Clock ResetInstantly reset time to 00:00:00
Non-Blocking DesignISR sets flags only; all processing happens in the main loop
Low PowerEfficient design suitable for battery-powered operation

🏗️ System Architecture

The system follows a flag-based cooperative scheduling architecture where the Timer1 ISR sets scheduler flags, and the main loop polls and services those flags. This ensures deterministic behavior with minimal interrupt latency.

mermaid
graph TB
    subgraph Hardware["🔧 Hardware Layer"]
        XTAL["8 MHz Crystal<br/>Oscillator"]
        MCU["ATmega32<br/>Microcontroller"]
        BTNS["Buttons<br/>SET | INC | RESET"]
        LEDS["LEDs<br/>Status | Task"]
        UART["USART<br/>TX/RX"]
    end

    subgraph Firmware["💻 Firmware Layer"]
        TIMER["Timer1 ISR<br/>CTC @ 1Hz"]
        SCHED["Task Scheduler<br/>Flag Polling"]
        CLOCK["Clock Module<br/>HH:MM:SS"]
        BTNDRV["Button Driver<br/>Debounce + Read"]
        LEDDRV["LED Driver<br/>Toggle/Flash"]
        UARTDRV["USART Driver<br/>9600 8N1"]
    end

    XTAL --> MCU
    MCU --> TIMER
    TIMER -->|"tick_flag"| SCHED
    SCHED --> CLOCK
    SCHED --> LEDDRV
    BTNS --> BTNDRV

Architecture Principles

  1. ISR Minimalism: The Timer1 Compare Match ISR only increments a counter and sets boolean flags—no heavy processing inside the ISR.
  2. Flag-Based Scheduling: The main loop continuously polls scheduler flags and dispatches tasks when their flags are set.
  3. Separation of Concerns: Clock logic, LED control, button handling, and USART communication are modular and independent.
  4. Non-Blocking I/O: All operations are non-blocking to maintain responsive button handling and accurate timing.

🔌 Hardware Requirements

ComponentSpecificationQuantity
ATmega32 MicrocontrollerPDIP-40 package (U1)1
Crystal Oscillator8 MHz, HC49-U Vertical (Y1)1
Load Capacitors22 pF ceramic (C3, C4)2
Decoupling Capacitors100 nF ceramic (C1 VCC, C2 AVCC, C5 AREF)3
LEDs5mm, any color (D1 Task, D2 Status)2
LED Current Limiting Resistors220Ω, ¼W (R3, R5)2
Button Pull-up Resistors10 kΩ (R1 Reset, R2 SET, R4 INC, R6 RESET_CLK)4
Tactile Push Buttons6mm, normally open (SW1 Reset, SW2 SET, SW3 INC, SW4 CLOCK_RESET)4
USART Connector1×3 pin header 2.54mm (J1: GND, TXD, RXD)1
USB-to-UART AdapterFTDI/CH340/CP2102 (3.3V/5V)1
Breadboard or PCBStandard breadboard or custom PCB1
Power Supply5V DC regulated1
Jumper WiresMale-to-male, assortedAs needed

Schematic Overview

text
                        +----[VCC 5V]----+
                        |                |
                   [10kΩ]R1         [100nF]C1 (VCC decoupling)
                        |                |
          +----[SW1]----+---[RESET]------+---[GND]
          |
    +-----+-----+
    |  ATmega32  |
    |            |
    | PA0 (40)---+---[10kΩ R2]---[VCC]   [SW2 SET]---[GND]
    | PA1 (39)---+---[10kΩ R4]---[VCC]   [SW3 INC]---[GND]
    | PA2 (38)---+---[10kΩ R6]---[VCC]   [SW4 RST]---[GND]
    |            |
    | PB0 (1)----+---[220Ω R5]---[LED D2 STATUS]---[GND]
    | PB1 (2)----+---[220Ω R3]---[LED D1 TASK]-----[GND]
    |            |
    | PD0 (14)---+---[J1 Pin3 RXD]
    | PD1 (15)---+---[J1 Pin2 TXD]       J1 Pin1 = GND
    |            |
    | XTAL1(13)--+---[8MHz Y1]---+---[22pF C3]---[GND]
    | XTAL2(12)--+---[8MHz Y1]---+---[22pF C4]---[GND]
    |            |
    | VCC (10)---+---[5V]    [100nF C1]---[GND]
    | GND (11)---+---[GND]

💻 Software Requirements

ToolVersionPurpose
AVR-GCC≥ 5.4.0C compiler for AVR targets
AVR Libc≥ 2.0.0Standard C library for AVR
AVRDUDE≥ 6.3Flash programmer utility
GNU Make≥ 4.0Build automation
Serial TerminalPuTTY / minicom / screenUSART output viewing

Installation (Ubuntu/Debian)

bash
sudo apt-get update
sudo apt-get install gcc-avr avr-libc avrdude make

Installation (macOS with Homebrew)

bash
brew tap osx-cross/avr
brew install avr-gcc avrdude

Installation (Windows)

Download and install WinAVR or use the Microchip AVR Toolchain.


📌 Pin Mapping

Pin #Port/PinFunctionDirectionConfigurationDescription
40PA0SET_BTNInputExternal 10kΩ Pull-up (R2)Enter time-set mode / cycle fields
39PA1INC_BTNInputExternal 10kΩ Pull-up (R4)Increment selected time field
38PA2CLOCK_RESETInputExternal 10kΩ Pull-up (R6)Reset clock to 00:00:00
1PB0LED_STATUSOutputActive High, 220Ω (R5)Status heartbeat LED (2s toggle)
2PB1LED_TASKOutputActive High, 220Ω (R3)Task indicator LED (5s flash)
9~RESETRESETInputExternal 10kΩ Pull-up (R1)Hardware reset (SW1)
10VCCPower—+5V DCDigital supply voltage
11GNDGround—0VDigital ground
12XTAL2Crystal—8 MHz + 22pF capCrystal oscillator output
13XTAL1Crystal—8 MHz + 22pF capCrystal oscillator input
14PD0USART_RXDInput—USART Receive Data
15PD1USART_TXDOutput—USART Transmit Data
30AVCCAnalog VCC—+5V DCAnalog supply voltage
31AGNDAnalog GND—0VAnalog ground

📖 For the complete 40-pin mapping, see documentation/pin_mapping_table.md


🔨 Build Instructions

1. Clone the Repository

bash
git clone https://github.com/yourusername/atmega32-digital-clock.git
cd atmega32-digital-clock

2. Configure the Makefile

Verify the following settings in Makefile:

makefile
MCU       = atmega32
F_CPU     = 8000000UL
PROGRAMMER = usbasp
PORT      = usb
BAUD      = 9600

3. Compile the Project

bash
make all

This will produce main.hex in the build directory.

4. Set Fuse Bits (First Time Only)

Configure the ATmega32 for an external 8 MHz crystal:

bash
# Low Fuse:  0xFF (External Crystal, full swing, 16K CK + 64ms startup)
# High Fuse: 0xD9 (JTAG disabled, EEPROM preserved, Boot size 256 words)
avrdude -c usbasp -p m32 -U lfuse:w:0xFF:m -U hfuse:w:0xD9:m

⚠️ Warning: Incorrect fuse settings can brick your microcontroller. Double-check values before programming.

5. Flash the Firmware

bash
make flash
# or manually:
avrdude -c usbasp -p m32 -U flash:w:main.hex:i

6. Connect Serial Terminal

bash
# Linux
minicom -D /dev/ttyUSB0 -b 9600

# macOS
screen /dev/cu.usbserial-XXXX 9600

# Windows
# Use PuTTY with COM port at 9600 baud, 8N1

7. Verify Operation

After programming and connecting the serial terminal, you should see:

text
=====================================
  ATmega32 Digital Clock v1.0
  Timer1 CTC Mode | 8MHz Crystal
=====================================

TIME: 00:00:00
[500ms Tick] Ext Task
TIME: 00:00:01
[500ms Tick] Ext Task
TIME: 00:00:02
[500ms Tick] Ext Task
TIME: 00:00:03
[500ms Tick] Ext Task
TIME: 00:00:04
[500ms Tick] Ext Task
TIME: 00:00:05
TASK: SENSOR SAMPLE
[500ms Tick] Ext Task
...

🕹️ Usage

Normal Operation

Upon power-up, the clock starts at 00:00:00 and counts up. Time is displayed on the serial terminal every second.

Button Functions

ButtonActionBehavior
SET (PA0)PressEnters time-set mode. Successive presses cycle: Hours → Minutes → Seconds → Exit
INCREMENT (PA1)PressIncrements the currently selected field (wraps: 23→0 for hours, 59→0 for min/sec)
RESET (PA2)PressImmediately resets the clock to 00:00:00

LED Indicators

LEDPortBehavior
Status LEDPB0Toggles ON/OFF every 2 seconds — heartbeat indicator
Task LEDPB1Brief flash every 5 seconds — scheduled task indicator

📁 Repository Structure

text
atmega32-digital-clock/
│
├── README.md                              # This file
├── LICENSE                                # MIT License
│
├── firmware/                              # Firmware source and hex
│   ├── src/                               # C Source files
│   │   ├── main.c                         # Main application entry
│   │   ├── timer.c                        # Timer config and ISR
│   │   ├── display.c                      # USART output logic
│   │   ├── scheduler.c                    # Non-blocking scheduler
│   │   └── buttons.c                      # Button debounce logic
│   ├── include/                           # Header files
│   │   ├── config.h                       # Pin definitions & constants
│   │   ├── timer.h
│   │   ├── display.h
│   │   ├── scheduler.h
│   │   └── buttons.h
│   ├── hex/
│   │   └── main.hex                       # Compiled firmware binary
│   └── Makefile                           # Build configuration
│
├── documentation/                         # Project documentation
│   ├── timer_configuration.md             # Timer1 CTC mode setup

📸 Screenshots

SimulIDE Simulation Running

SimulIDE Clock Operation

KiCad PCB Layout

PCB Layout


📚 Documentation

Detailed documentation is available in the documentation/ directory:

DocumentDescription
Timer ConfigurationDetailed Timer1 CTC mode setup and register configuration
Compare Match CalculationStep-by-step OCR1A value derivation with accuracy analysis
Pin Mapping TableComplete ATmega32 PDIP-40 pin assignment reference
Test ResultsTest plan, test cases, and verification results
Block DiagramSystem architecture block diagram (Mermaid)
FlowchartProgram flow and ISR logic flowchart (Mermaid)

📄 License

This project is licensed under the MIT License.

text
MIT License

Copyright (c) 2026 ATmega32 Digital Clock Project

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Built with ❤️ for embedded systems enthusiasts
ATmega32 · Timer1 CTC · USART · Cooperative Scheduling

Parts

20
QtyValueFootprintReferences
410kResistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR1, R2, R4, R6
4SW_PushButton_Switch_THT:SW_PUSH_6mmSW1, SW2, SW3, SW4
3100nFCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mmC1, C2, C5
2220Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_HorizontalR3, R5
222pFCapacitor_THT:C_Disc_D5.0mm_W2.5mm_P5.00mmC3, C4
2LEDLED_THT:LED_D5.0mmD1, D2
18MHzCrystal:Crystal_HC49-U_VerticalY1
1ATmega32A-PPackage_DIP:DIP-40_W15.24mmU1
1Conn_01x03_PinConnector_PinHeader_2.54mm:PinHeader_1x03_P2.54mm_VerticalJ1

Similar boards

  • 2 layers347.7 × 146.6 mmMysterium pcb, the printed circuit board in 3D

    Mysterium pcb

    coseyfannitutti/mysterium

    TKL keyboard that can be entirely assembled using only through hole components, including usb type-c

    227 parts541GPL-3.0
  • 2 layers344.4 × 130.8 mmSesame, the printed circuit board in 3D

    Sesame

    str-dst/sesame

    Alice type ergo keyboard using only THT parts

    168 parts331
  • 2 layers364.4 × 167.3 mmRedherring, the printed circuit board in 3D

    Redherring

    dcpedit/redherring

    Red Herring Keyboard PCB and case files

    226 parts253CC-BY-4.0
  • 2 layers228 × 114 mmPlanck thk, the printed circuit board in 3D

    Planck thk

    olkb/planck_thk

    Planck Through Hole Kit

    134 parts169GPL-3.0
  • 2 layers371.5 × 145.3 mmBasketweave, the printed circuit board in 3D

    Basketweave

    null-ll/basketweave

    Through-hole Alice-style keyboard with arrow keys and a rotary encoder

    177 parts129GPL-2.0
  • 2 layers439 × 141.6 mmAek2 usb, the printed circuit board in 3D

    Aek2 usb

    str-dst/aek2_usb

    drop-in replacement pcb for the AEK II

    241 parts55
  • 2 layers317.3 × 154.8 mmLCK75, the printed circuit board in 3D

    LCK75

    lyso1/LCK75

    a 75% through-hole keyboard designed by myself with inspiration from the CFTKB Discipline and Yiancar Gingham

    207 parts45
  • 2 layers285.8 × 124.6 mmPunk75, the printed circuit board in 3D

    Punk75

    dsanchezseco/punk75

    Ortholinear keyboard with 75 keys and all components through hole

    194 parts44GPL-3.0

Questions

How big is the ATmega32 Clock PCB?

It measures 80 × 60 mm and has 2 copper layers, 1.6 mm thick.

What parts does the ATmega32 Clock use?

20 parts, built around the ATMEGA32A-PU. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the ATmega32 Clock KiCad files?

From the chikotaraufu-netizen/ATmega32_Timer_Digital_Clock_Scheduler- repository on GitHub, at the commit this page was made from: the board is kicad/pcb/ATmega32_Clock.kicad_pcb and its schematic kicad/schematic/ATmega32_Clock.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the ATmega32 Clock design in my own project?

Its repository states no licence, so its author keeps all rights: ask chikotaraufu-netizen before reusing the design.