Skip to the content
PCBKitNew board
2 layers114.3 × 88.9 mmCrickHit PCB, the printed circuit board in 3D

Real-time cricket batting game on the TI MSPM0G3507 (ARM Cortex-M0+) with triple-ISR architecture, custom KiCad PCB, 5-bit DAC audio, and 3D-printed enclosure. Built for ECE 319H at UT Austin.

Size
114.3 × 88.9 mm
Copper layers
2
Thickness
1.6 mm
Parts
54
Nets
69
Pads
210
Tracks, vias
353, 41
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
11 May 2026
Updated
12 May 2026

Overview

CrickHit PCB is an open-source printed circuit board by devanshjoshi08, from the devanshjoshi08/CrickHit repository on GitHub. It is a 2-layer board of 114.3 × 88.9 mm with 54 parts on 69 nets, routed with 353 tracks and 41 vias.

It is built around the TSOP31438 and ULN2003BD. Its parts include 18 resistors, 7 connectors, 6 ICs, 4 capacitors and 4 diodes. It belongs with the audio and music boards of this library.

Main components

2

README

README.md

CrickHit

An Embedded Real-Time Cricket Game on the TI MSPM0G3507


Project Overview

CrickHit is a real-time cricket batting game built from scratch on the TI MSPM0G3507 LaunchPad with a ST7735R 128x160 TFT LCD. The player controls a batsman using a slide potentiometer and physical switches to hit balls bowled with realistic curve trajectories. The game runs entirely on bare-metal interrupts with no RTOS, using fixed-point physics, sprite compositing, a custom 5-bit binary-weighted DAC for audio, and multilingual UI support.

Developed as the final project for ECE 319H: Introduction to Embedded Systems (Honors) at The University of Texas at Austin, Spring 2026.

Authors: Devansh Joshi and Calum Cheah


Gameplay / Demo

A top-down cricket scene is rendered on the LCD. A bowler at the top of the screen delivers balls toward the stumps at the bottom. The player moves the batsman horizontally with a slide potentiometer and triggers left or right bat swings using physical switches.

A demo of CrickHit is available here:

Video Thumbnail Title

Scoring

Runs are awarded based on how precisely the bat contacts the ball:

ResultConditionRuns
Perfect HitBall within 3px of ideal contact point+6
Good HitBall within 8px of ideal contact point+4
HitBall within 14px of ideal contact point+2
WideBall delivered too far from the batsman+1
Wicket (OUT)Ball hits the stumps without being hitScore resets

Swinging on the correct side (left swing for balls approaching from the left, right swing for the right) gives a threshold bonus. Swinging on the wrong side applies a 2px penalty to all scoring thresholds, making it harder to score high.

Ball Physics

Each delivery uses kinematic equations with 6-bit fixed-point arithmetic for sub-pixel precision:

  • Initial horizontal velocity is randomized
  • A curve acceleration (ax) is computed so the ball arcs toward the stumps
  • Target position uses a Gaussian random distribution (Central Limit Theorem approximation) so slower deliveries aim more accurately at the stumps while faster ones scatter wider
  • Speed-proportional jitter is added to the scoring calculation to prevent quantization lockout at high speeds, where the large step size would otherwise restrict the ball to only a few Y positions in the hit zone

Wide Detection

A ball is called wide if it passes the batsman's reach without being hit:

  • Off-wide: Ball passes more than 15px past the batsman's right edge
  • Leg-wide: Ball is left of the pitch with a gap greater than 3px from the batsman's left edge

If a wide ball subsequently hits the stumps or gets hit by the bat, the wide run is revoked.

Game Controls

InputAction
Slide potentiometerMove batsman left/right
LEFT switch (PA25)Swing bat to the left
RIGHT switch (PA27)Swing bat to the right
TOP switch (PA24)Increase ball delivery speed
BOTTOM switch (PA26)Decrease ball delivery speed
TOP + BOTTOMReturn to home screen
LEFT + RIGHTPause / unpause
S1 (LaunchPad)Enable speaker
S2 (LaunchPad)Disable speaker

A 1500ms cooldown is enforced between swings to prevent spam.


Hardware

Platform

  • MCU: TI MSPM0G3507 LaunchPad (ARM Cortex-M0+, 80 MHz)
  • Display: ST7735R 128x160 TFT LCD over SPI

Pin Assignments

PeripheralPin(s)Function
SPI1 SCLKPB9LCD clock
SPI1 CSPB6LCD chip select
SPI1 MOSIPB8LCD data
LCD ResetPB15ST7735 !RST
LCD D/CPA13ST7735 RS (Data/Command)
Slide PotPB18 (ADC1 Ch5)Batsman horizontal position
5-bit DACPB0-PB4Binary-weighted audio output
Speaker EnablePB12Active-low speaker control
TOP SwitchPA24Increase ball speed
LEFT SwitchPA25Left bat swing
BOTTOM SwitchPA26Decrease ball speed
RIGHT SwitchPA27Right bat swing
LED 0PA152-run hit indicator
LED 1PA164-run hit indicator
LED 2PA176-run hit indicator

Required Components

  • MSPM0G3507 LaunchPad
  • ST7735R 128x160 TFT LCD
  • Slide potentiometer
  • 4 momentary push switches
  • 5-bit binary-weighted DAC
  • Speaker with enable circuit
  • 3 LEDs with current-limiting resistors

Custom PCB

We designed a custom PCB in KiCad that consolidates all of the hardware circuitry onto a single board. The PCB integrates the ST7735R LCD connector, the 5-bit binary-weighted DAC, the speaker amplifier circuit (MCP34119P), all four game switches, the slide potentiometer input, LED indicators, IR receiver (TSOP31438), a ULN2003B Darlington driver, UART debugging header, and TExaS connector -- all routed to the MSPM0G3507 LaunchPad. This eliminates the need for breadboard wiring and makes the entire system compact and reliable.

3D-Printed Enclosure

A custom controller-style enclosure was designed in Autodesk Fusion to house the PCB and LaunchPad together as a handheld game controller.

image image

An STL of the enclosure is included in the 3D_Enclosure/


Software Architecture

Interrupt-Driven Design

The entire game runs on three interrupt sources with no polling loops in the main thread:

ISRSourceRatePurpose
TIMG12_IRQHandlerTimerG1230 HzMain game tick: polls ADC, updates all sprite positions, runs collision detection, sets render flag
TIMG0_IRQHandlerTimerG01 kHzSwing cooldown timer (counts up to 1500ms between allowed swings)
SysTickSysTick11 kHzStreams audio samples through the 5-bit DAC

The main loop blocks on a flag set by the 30 Hz ISR, then handles rendering, UI updates, and screen transitions. All ST7735 drawing occurs in main context only, never inside an ISR.

Object-Oriented Sprite System

A Sprite base class provides position tracking, dirty-flag rendering, overlap detection, and background-aware erasure. Four derived classes implement the game objects:

Ball -- Fixed-point position (fx, fy) and velocity (vx, vy) with curve acceleration (ax). A 5-state machine drives the lifecycle:

text
IDLE --> BOWLING --> HIT_LEFT/HIT_RIGHT --> RESET --> IDLE
                 \-> (stump collision) --> RESET --> IDLE

Batsman -- Position mapped from the slide potentiometer ADC reading (calibrated range 1587-192). Left swing has 8 animation frames, right swing has 10. The current frame pointer is updated each game tick during a swing.

Bowler -- Cycles through 7 animation frames. Frame 4 is the release frame, which triggers ball delivery with randomized trajectory parameters.

Stump -- Two frames (intact and broken). On wicket, the broken frame displays for 30 game ticks (~1 second) before the OUT screen appears.

Rendering Pipeline

The Renderer module composites sprites against the pitch background to prevent texture artifacts:

  1. For each pixel in a sprite, check if it's transparent (BG_COLOR = 0x9772)
  2. If transparent, fetch the corresponding pixel from the pitch bitmap (or outfield green if outside the pitch bounds)
  3. White crease pixels in the pitch are substituted with pitch surface color to avoid visual bleed
  4. The composed buffer is written as a single SPI transaction for flicker-free output

EraseToBackground() restores the pitch texture when a sprite moves, handling the partial-width erase case when the batsman slides left or right.

Audio System

Three sound effects are stored as raw sample arrays and played through a 5-bit binary-weighted DAC at 11 kHz via SysTick:

SoundSamplesTrigger
IPL Stadium28,179Title screen crowd atmosphere
Bat Hit2,239Ball contacts bat
Stump Hit3,592Ball hits stumps (wicket)

The speaker can be muted/unmuted at runtime via the LaunchPad S1/S2 buttons, controlled through GPIO PB12.

Internationalization

The game supports English and Spanish, selectable on the home screen:

  • TOP switch selects English, BOTTOM switch selects Spanish
  • All UI strings ("Score"/"Puntaje", "Wide"/"Ancha", instruction text) are stored in a Phrases[][] lookup table
  • A Devanagari (Hindi) font renderer (HindiFont.h/cpp) with 31 glyphs and diacritic support is included for future localization

Project Structure

text
CrickHit/
|-- README.md
|-- LICENSE
|-- mspm0g3507.cmd                 Linker script
|
|-- src/                           Game source code
|   |-- Lab9HMain.cpp              Main game loop, ISRs, collision detection, game state
|   |-- GameDefs.h                 All constants: sprite dimensions, physics params, thresholds
|   |-- Sprites.h                  Sprite class hierarchy (Sprite, Ball, Batsman, Bowler, Stump)
|   |-- Sprite.cpp                 Base class: draw, erase, overlap detection
|   |-- Ball.cpp                   Fixed-point kinematics, trajectory, state machine
|   |-- Batsman.cpp                Potentiometer input mapping, swing animation
|   |-- Bowler.cpp                 Bowling animation, release frame detection
|   |-- Stump.cpp                  Intact/broken state, hit animation
|   |-- Renderer.h / .cpp          Background-compositing sprite renderer
|   |-- Screens.h / .cpp           Home, instruction, pause, and OUT screens + i18n
|   |-- Sound.h / .cpp             DAC audio playback (SysTick-driven)
|   |-- LED.h / .cpp               Hit-quality LED indicators
|   |-- Switch.h / .cpp            4-switch input reading
|   |-- SmallFont.h / .cpp         Numeric score display font
|   +-- HindiFont.h / .cpp         Devanagari script renderer (31 glyphs, 12x16px)
|
|-- inc/                           Hardware abstraction libraries (see Acknowledgments)
|   |-- Clock.h / .cpp             System clock configuration (80 MHz PLL)

Building and Flashing

Prerequisites

  • Code Composer Studio (CCS) with the TI CLANG compiler (v4.0+)
  • MSPM0 SDK (v2.9+)
  • MSPM0G3507 LaunchPad with hardware wired per the pin assignments above

Setup

  1. Clone this repository into your CCS workspace
  2. File > Import > CCS Projects, point to the cloned folder
  3. Ensure the MSPM0 SDK is installed and COM_TI_MSPM0_SDK_INSTALL_DIR is set
  4. Build the project -- the inc/ folder contains all necessary driver libraries, so no external ValvanoWare dependency is needed
  5. Connect the LaunchPad via USB and flash

The inc/ directory contains the hardware abstraction libraries that originally lived in a shared MSPM0_ValvanoWare/inc/ directory. Include paths have been updated so this project builds standalone.


Development Utilities

curve.py -- Python script that simulates ball trajectories with the same kinematic equations used in the game. Plots predicted paths for tuning physics constants (velocity, acceleration, target variance) without reflashing the board.

flood_fill_sprites.py -- Post-processes images.h after BMP-to-C conversion. Flood-fills exterior background pixels with the transparent color (0x9772) while preserving interior white pixels (bat highlights, ball shine, etc.) that should not be treated as transparent during compositing.


Acknowledgments

This project was built for ECE 319H: Introduction to Embedded Systems (Honors) at The University of Texas at Austin, taught by Professor Ramesh Yerraballi. Thank you to Dr. Yerraballi, Dr. Valvano, Dr. Chin, Dr. Holt, and the ECE319 TAs for their instruction and support throughout ECE319H!

The hardware abstraction libraries in the inc/ directory -- Clock, DAC5, LaunchPad, SPI, ST7735, SlidePot, TExaS, and Timer -- were written by Jonathan Valvano as part of the MSPM0 ValvanoWare curriculum framework. These drivers provide the foundational embedded systems infrastructure (clock configuration, SPI communication, LCD rendering, ADC interfacing, timer management) that CrickHit is built on.


Authors

Devansh Joshi -- GitHub
Calum Cheah -- GitHub


License

This project is licensed under the MIT License.

The hardware abstraction libraries in inc/ are provided by Jonathan Valvano and Texas Instruments under their own respective terms and are not covered by the MIT License.

Parts

54
QtyValueFootprintReferences
51.5kECE319K:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR4, R5, R6, R7, R8
510kECE319K:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR12, R13, R14, R15, R17
4220ECE319K:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR1, R2, R3, R18
4LEDECE319K:LED_D5.0mmD1, D2, D3, D4
4~ECE319K:MountingHole_4_40H1, H2, H3, H4
312kECE319K:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR9, R10, R11
3LOGOLOGOG***, G***, G***
20.1uFECE319K:C_Axial_200milC3, C4
2PTA2043ECE319K:PTA2043potRV1, RV2
2PotECE319K:Testpoint_1x02_P2.54mmJ4, J5
11uFECE319K:CP_Radial_Tantal200milC1
120kECE319K:R_Axial_DIN0204_L3.6mm_D1.6mm_P7.62mm_HorizontalR16
13.3VECE319K:Testpoint_1x02_P2.54mmTP1
14.7uFECE319K:CP_Radial_Tantal200milC2
1Adafruit ST7735RECE319K:adafruit_st7735rU1
1AudioJackECE319K:Jack_3.5mm_CUI_SJ1-3523N_HorizontalJ1
1DACOUTECE319K:Testpoint_1x02_P2.54mmJ7
1DOWNECE319K:SW_PUSH_6mmSW3
1GNDECE319K:Testpoint_1x02_P2.54mmJ6
1HiLetGo_ST7735RECE319K:hiletgo_st7735rU4
1LEFTECE319K:SW_PUSH_6mmSW2
1LP-MSPM0G3507ECE319K:ti_LP_MSPM0G3507U2
1MCP34119PECE319K:DIP-8_W7.62mm_LongPadsU3
1RGHTECE319K:SW_PUSH_6mmSW4
1SpeakerECE319K:PinHeader_1x02_P2.54mm_VerticalJ2
1TExaSECE319K:PinHeader_1x03_P2.54mm_VerticalJP1
1TSOP31438ECE319K:TSOP31438U6
1UART1ECE319K:PinHeader_1x03_P2.54mm_VerticalJ3
1ULN2003BECE319K:DIP-16_W7.62mmU5
1UPECE319K:SW_PUSH_6mmSW1

Questions

How big is the CrickHit PCB PCB?

It measures 114.3 × 88.9 mm and has 2 copper layers, 1.6 mm thick.

What parts does the CrickHit PCB use?

54 parts, built around the TSOP31438 and ULN2003BD. 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 CrickHit PCB KiCad files?

From the devanshjoshi08/CrickHit repository on GitHub, at the commit this page was made from: the board is PCB_Design/CrickHit_PCB.kicad_pcb and its schematic PCB_Design/CrickHit_PCB.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the CrickHit PCB design in my own project?

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

Similar boards

  • 4 layers179.3 × 72.5 mmStarter, the printed circuit board in 3D

    Starter

    alicedimauro/Tilt

    59 parts1
  • 2 layers132.5 × 83 mmAM96353, the printed circuit board in 3D

    AM96353

    ananth-abbaraju/319H_PCB

    44 parts
  • 2 layers114.3 × 88.9 mmKC47852, the printed circuit board in 3D

    KC47852

    KaitlynWChang/ECE-319H-PCB

    53 parts
  • 2 layers114.3 × 88.9 mmJc224364, the printed circuit board in 3D

    Jc224364

    se1yu/BlockBlast

    Using knowledge from ECE 319H at UT Austin (Intro to Embedded Systems) to build a custom video game console and to program Block Blast from scratch.

    54 parts
  • 2 layers114.3 × 88.9 mmMVM833, the printed circuit board in 3D

    MVM833

    SiddharthaG09/319KFinalProject

    For our final project, we recreated Space Invaders in C, using a custom-designed PCB and an MSPM0G3507 microcontroller.

    46 partsMIT
  • 2 layers140.8 × 66.4 mmM0+rixPCB, the printed circuit board in 3D

    M0+rixPCB

    SuryaUT/TheM0trix_Segfaulted

    ECE319H Game

    50 parts
  • 2 layers118 × 100 mmDuelTank, the printed circuit board in 3D

    DuelTank

    SathvikY3533/DuelTanks

    Duel Tanks is a real-time two-player artillery game built completely from scratch on the MSPM0G3507 microcontroller.

    72 parts
  • 2 layers203 × 26.6 mmBlade13, the printed circuit board in 3D

    Blade13

    opulo-inc/lumenpnp

    The LumenPnP is an open source pick and place machine.

    54 parts3.7k