Skip to content

Latest commit

 

History

History
176 lines (134 loc) · 7.01 KB

File metadata and controls

176 lines (134 loc) · 7.01 KB

HCS12 Projects

These projects were written in HCS12 Assembly using direct hardware register access, and each one explores a different capability of the microcontroller. The work starts with CPU-only operations, then moves into digital I/O, pull-up resistors, interfacing with embedded peripherals, and driving external hardware.


Table of Contents


Overview

This section focuses on using the HCS12 bench development board to learn low-level interfacing and CPU-level programming. Each project is isolated, meaning it demonstrates one core concept before moving on to the next.

The projects progress from:

  • Basic register-level CPU arithmetic
  • To understanding data direction registers and pull-ups
  • And finally to driving hardware connected to the evaluation board such as LEDs, keypads, speakers, and an LCD display.

Hardware Context

All projects in this folder run on the HCS12 evaluation bench system. Inputs and outputs are mapped directly to registers, and the programmer controls every action through assembly instructions.

The diagram below represents the core programming model used across these projects:

Programming Model

This model shows the accumulators, index registers, stack pointer, program counter, and condition code flags used during arithmetic and instruction execution.


1️⃣ Multiplication

Objective:
Demonstrate arithmetic using CPU registers while observing how the ALU, accumulator pairing (A+B → D register), and condition code register behave during arithmetic execution.

Image:
Uses the CPU programming model shown above, since this project focuses on core registers and flags.

Technical Implementation Notes:

  • Uses built-in arithmetic instructions (MUL, ADDA, ADDB, etc.)
  • Demonstrates how accumulator A and B combine into the 16-bit D register
  • Observes CCR flag behavior: Carry, Negative, Zero, Overflow
  • Reinforces register-level execution with no hardware interaction
  • Shows the relationship between operand size (8-bit vs 16-bit) and instruction effects

Skills Demonstrated:
✔ Register math operations
✔ Understanding CCR flag changes during ALU operations
✔ Working with paired 8-bit registers forming a 16-bit result (A + B = D)


2️⃣ LED_BAR

Objective:
Control digital outputs by configuring data direction registers and using pull-ups to convert switch input into visible output on an LED bar.

Image:
Eval Board

Technical Implementation Notes:

  • Uses DDRH to configure output pins
  • Uses PERT register to enable pull-up resistors for the input port
  • Reads switches using PTT, writes results to PTH
  • Demonstrates bit masking to preserve surrounding register values
  • Implements polling-based processing loop
  • Introduces real hardware timing sensitivity based on switch noise

Skills Demonstrated:
✔ Mapping logical input → physical output
✔ Pull-up resistor configuration and noise-safe input
✔ Continuous real-time polling loop control
✔ Bit masking for selective register modification


3️⃣ Keypad_Controlling_Diode

Objective:
Read an encoded keypad input and decode keypress values to control indicator output logic.

Image:
Keypad

Technical Implementation Notes:

  • Uses 74C922 keypad encoder (binary output: 0–F hexadecimal)
  • Reads input via PTS register
  • Uses PE4 as output enable control for keypad polling
  • Demonstrates right-shift bit manipulation (LSRA) to position relevant bits
  • Relies on conditional branching (BEQ, BNE) for logic flow
  • Introduces device-driven I/O, not raw switch input

Skills Demonstrated:
✔ Keypad interfacing with encoded digital outputs
✔ Bit shifting and input decoding
✔ Conditional execution based on input values
✔ Mapping input values directly to controlled outputs


4️⃣ Buzzer

Objective:
Generate audio output by toggling a digital pin using software-controlled timing loops to produce a square-wave signal.

Image:
(same Eval Trainer image as earlier, there are no additional hardware diagram required)

Technical Implementation Notes:

  • Uses loop-based software delays to generate waveform frequency
  • Implements toggle operation using EORA or bitwise masks
  • Demonstrates toggling output on PP7 pin
  • Highlights limitations of software-generated timing (blocking execution)
  • Introduces concept of human-perceptible timing vs CPU cycle scale

Skills Demonstrated:
✔ Timing generation using CPU loops
✔ Square-wave output generation
✔ Using bit operations to toggle hardware pins
✔ Comparing machine-cycle timing to real-world behavior


5️⃣ LCD

Objective:
Initialize and control a character LCD module using command-based communication and timed data writes.

Image:
LCD Signal Summary
LCD Layout
LCD Control Codes

Technical Implementation Notes:

  • Uses command sequences from LCD controller (e.g., $0C, $28, $06, $01)
  • Implements busy-wait timing technique rather than LCD status read-back
  • Writes ASCII characters using FCC, lookup tables, and pointer indexing
  • Demonstrates difference between control instructions vs data writes
  • Uses string pointer (X index register) with null-terminated message formatting
  • Introduces multi-step subroutine structure (DISPLAYSTRING → DISPLAYCHAR)

Skills Demonstrated:
✔ Working with communication protocols
✔ LCD addressing and timing constraints
✔ ASCII conversion and lookup logic
✔ Pointer indexing with indirect addressing


Skills Gained

Across the HCS12 section, the following core areas were strengthened:

  • CPU computation and condition flag evaluation
  • Input/output mapping and register interpretation
  • Pull-up resistor configuration and signal conditioning
  • Digital interfacing with structured peripherals (keypad encoder, LCD, buzzer, LED bar)
  • Masking, shifting, and selective register modification
  • Loop-based delays and hardware timing effects
  • Polling-based logic control (no interrupts used in this stage)
  • Binary-to-ASCII conversion and lookup-table based output formatting
  • Hardware abstraction using subroutines and controlled program structure
  • Real-time output generation (square-wave buzzer control, live display updates)

These foundational lessons prepare for more advanced robotic behavior in the EEBOT portion of the repository.


Navigation

⬅️ Return to Main Repository
📁 Continue to: EEBOT Projects