# Learning Plan: Understanding Microcontroller Assembly & DSP Fundamentals

**Goal:** Develop sufficient understanding to read and appreciate dsPIC assembly code for a line noise testing product, including basic DSP concepts (Z-transform, digital filtering).

**Duration:** 10-12 weeks (~1 hour/day)  
**Background:** CS degree, extensive high-level programming experience, basic electronics familiarity

---

## Phase 1: Foundations (Weeks 1-3)

### Week 1: Computer Architecture & How Computers Actually Work

**Primary Resource:**  
- **Nand to Tetris Part I** (Coursera, free to audit)  
  - https://www.coursera.org/learn/build-a-computer  
  - Focus on Modules 1-4: Logic gates → ALU → Memory → Machine Language  
  - ~2-3 hours video + 5-10 hours projects per module  
  - You can compress this by watching at 1.5x and doing projects selectively

**Why this matters:** [REDACTED] code operates at a level where you need to understand what registers, memory addresses, and opcodes actually *are*—not as abstractions but as physical realities. Nand to Tetris builds this intuition by having you construct a computer from logic gates up. You'll understand *why* certain architectural decisions exist.

**Daily breakdown:**
- Days 1-2: Module 1 (Boolean logic, basic gates)
- Days 3-4: Module 2 (ALU construction)
- Days 5-6: Module 3 (Memory)
- Day 7: Module 4 intro (Machine language concepts)

**Hands-on:** Follow along with the HDL simulator. The projects are worth doing—they make the concepts concrete.

---

### Week 2: Assembly Language Fundamentals

**Primary Resource:**  
- **Codecademy: Computer Architecture: Assembly Language** (free tier available)  
  - https://www.codecademy.com/learn/computer-architecture-assembly-language  
  - Interactive, browser-based, ~4-6 hours total

**Supplementary:**
- **TutorialsPoint Assembly Tutorial** (reference/reading)  
  - https://www.tutorialspoint.com/assembly_programming/index.htm  
  - Use as reference when you hit concepts that need more explanation

**Key concepts to master this week:**
- Registers (what they are, why they exist)
- Memory addressing modes (immediate, direct, indirect)
- The stack and stack pointer
- Basic instructions: MOV, ADD, SUB, CMP, JMP variants
- Flags/status registers (zero, carry, overflow, negative)
- Subroutines and the call stack

**Note on architecture differences:** These resources teach x86 or generic assembly. The dsPIC is a 16-bit DSC with different registers and instructions, but the *concepts* transfer directly. You're learning the grammar of assembly languages, not memorizing a specific vocabulary.

**Daily breakdown:**
- Days 1-3: Work through Codecademy course
- Days 4-5: Read TutorialsPoint sections on addressing modes and procedures
- Days 6-7: Review and write simple programs in an online x86 emulator

---

### Week 3: Microcontroller Concepts

**Primary Resource:**  
- **"Introduction to Microcontrollers" tutorial series** by Mike Silva  
  - https://www.embeddedrelated.com/showarticle/453.php  
  - Free, text-based, excellent for programmers  
  - Parts 1-8 cover the essentials

**Supplementary:**
- **TutorialsPoint Embedded Systems Tutorial**  
  - https://www.tutorialspoint.com/embedded_systems/index.htm  
  - Sections on microcontroller architecture, memory types, I/O

**Key concepts:**
- Difference between microprocessor and microcontroller
- Program memory vs. data memory (Harvard vs. von Neumann architecture)
- Peripherals: timers, ADC, interrupts, I/O ports
- Clock systems and timing
- Reset and initialization
- Memory-mapped I/O (why addresses control hardware)

**Why this matters:** [REDACTED] dsPIC is a microcontroller—it has on-chip peripherals, multiple memory spaces, and hardware features that don't exist in desktop CPUs. Understanding the microcontroller paradigm explains why the code does things that would seem bizarre in a desktop context (polling registers, setting configuration bits, interrupt service routines).

**Daily breakdown:**
- Days 1-4: Read through Mike Silva's tutorial series
- Days 5-6: TutorialsPoint sections on microcontroller basics
- Day 7: Review and consolidate notes

---

## Phase 2: The dsPIC Architecture (Weeks 4-6)

### Week 4: dsPIC Overview & Documentation Orientation

**Primary Resources:**
- **dsPIC Family Reference Manual** (DS70046E)  
  - https://ww1.microchip.com/downloads/en/DeviceDoc/70046E.pdf  
  - **Read:** Section 1 (Introduction), Section 2 (CPU)  
  - This is ~50 pages of dense but essential material

- **dsPIC Programmer's Reference Manual** (DS70030)  
  - https://ww1.microchip.com/downloads/en/DeviceDoc/70030f.pdf  
  - **Read:** Section 2 (Programmer's Model), Section 3 (Instruction Set Overview)

- **"Getting Started with dsPIC"** (DS70151A)  
  - https://ww1.microchip.com/downloads/en/devicedoc/70151a.pdf  
  - Lighter intro, good starting point

**Key concepts:**
- The W register array (W0-W15)—these are the dsPIC's working registers
- Program Counter (23-bit)
- Status register and flags
- Data memory organization (X and Y data spaces)
- The dual-data-fetch architecture (why it matters for DSP)
- Addressing modes specific to dsPIC

**How to approach the datasheets:** Don't try to memorize. Read for structure and understanding. Make a cheat sheet of registers and their purposes. You'll return to these documents repeatedly.

**Daily breakdown:**
- Days 1-2: "Getting Started with dsPIC" document
- Days 3-4: Family Reference Manual, Sections 1-2 (skim, then re-read carefully)
- Days 5-6: Programmer's Reference Manual, Sections 2-3
- Day 7: Create a personal reference sheet of key registers and concepts

---

### Week 5: dsPIC Instruction Set

**Primary Resource:**
- **dsPIC Programmer's Reference Manual** (DS70030)  
  - Section 4 onwards: Instruction descriptions
  - Focus on instruction categories, not memorizing every instruction

**Study approach:**
1. **MCU-class instructions:** MOV, ADD, SUB, AND, OR, XOR, shifts, branches, calls
2. **DSP-class instructions:** MAC (multiply-accumulate), MPY, accumulators
3. **Special instructions:** REPEAT, DO (hardware loops), table read/write

**Key insight:** The dsPIC has two instruction classes because it's designed for both general control (MCU) and signal processing (DSP). [REDACTED] code likely uses both—control logic in MCU instructions, filtering algorithms in DSP instructions.

**Create a reference card** with:
- Common instructions and what they do
- Addressing mode syntax
- Condition codes and when they're set

**Daily breakdown:**
- Days 1-2: MCU instruction categories (moves, arithmetic, logic)
- Days 3-4: Branch and control flow instructions
- Days 5-6: DSP instructions overview (MAC, accumulators)
- Day 7: Create personal instruction reference card

---

### Week 6: Reading Real dsPIC Assembly

**Primary Resources:**
- **Microchip Application Notes** (search microchip.com for dsPIC examples)
- **dsPIC Language Tools Getting Started** (DS70094)  
  - https://ww1.microchip.com/downloads/en/devicedoc/70094a.pdf  
  - Contains tutorial code examples

**Practice:**
- Find simple dsPIC assembly examples online
- Trace through them line by line
- Look up unfamiliar instructions in the Programmer's Reference Manual
- Ask yourself: What is this code trying to accomplish? Why is it done this way?

**Using [REDACTED] code:**
- Start with the initialization section (typically at reset vector)
- Identify the main loop
- Find the interrupt service routines
- Don't try to understand everything—identify structure first

**Daily breakdown:**
- Days 1-3: Work through Microchip tutorial examples
- Days 4-5: Find and analyze additional dsPIC assembly examples
- Days 6-7: Begin examining structure of [REDACTED] code

---

## Phase 3: Digital Signal Processing Fundamentals (Weeks 7-9)

### Week 7: DSP Concepts & Discrete-Time Signals

**Primary Resource:**
- **Coursera: Digital Signal Processing 1** (EPFL, free to audit)  
  - https://www.coursera.org/learn/dsp1  
  - Module 1: Basics of DSP  
  - Module 2: Vector Spaces (mathematical foundation)

**Supplementary:**
- **MIT OpenCourseWare: Digital Signal Processing** (RES.6-008)  
  - https://ocw.mit.edu/courses/res-6-008-digital-signal-processing-spring-2011/  
  - Lectures 1-4 (free video lectures)

**Key concepts:**
- Discrete-time signals vs. continuous signals
- Sampling and the Nyquist theorem
- Why digital filters exist
- LTI (Linear Time-Invariant) systems
- Convolution (the core operation of filtering)

**Daily breakdown:**
- Days 1-3: Coursera DSP1 Module 1
- Days 4-5: Coursera DSP1 Module 2 (as much as time allows)
- Days 6-7: MIT OCW lectures 1-4 (supplementary)

---

### Week 8: The Z-Transform

**Primary Resource:**
- **Coursera: Digital Signal Processing 1** (continued)  
  - Module 3: Fourier Analysis (builds to Z-transform)

**Supplementary reading:**
- **"Analyzing IIR filters" chapter** from Digital Signals Theory  
  - https://brianmcfee.net/dstbook-site/content/ch12-ztransform/intro.html  
  - Free online textbook, excellent explanations

- **Wikipedia: Infinite Impulse Response**  
  - https://en.wikipedia.org/wiki/Infinite_impulse_response  
  - Good reference for IIR filter basics

**Key concepts:**
- What the Z-transform is and why it's useful (frequency domain analysis for discrete signals)
- Poles and zeros
- Transfer functions: H(z) = Y(z)/X(z)
- Relationship between Z-transform and filter behavior
- Why "Z-transform integer mathematics" means implementing filters in code

**Practical understanding goal:** When your [REDACTED] says "Z-transform integer mathematics," [REDACTED] means the filter coefficients and difference equations are implemented using integer arithmetic (for speed and precision on a fixed-point DSP). You should understand that a filter equation like:

```
y[n] = b0*x[n] + b1*x[n-1] + b2*x[n-2] - a1*y[n-1] - a2*y[n-2]
```

...is what the code is computing, and the coefficients come from Z-transform design.

**Daily breakdown:**
- Days 1-3: Coursera DSP1 Module 3
- Days 4-5: Read supplementary materials on Z-transform
- Days 6-7: Work through simple filter examples, trace the math

---

### Week 9: Digital Filters (IIR Focus)

**Primary Resource:**
- **Coursera: Digital Signal Processing 1** (continued)  
  - Module 4: Introduction to Filtering & Filter Design

**Supplementary:**
- **Cycling '74: Demystifying Digital Filters tutorials**  
  - https://cycling74.com/tutorials/demystifying-digital-filters-part-3  
  - Practical, clear explanations of IIR filters

**Key concepts:**
- FIR vs. IIR filters
- Difference equations
- Filter stability (why poles must be inside the unit circle)
- Common filter types: low-pass, high-pass, band-pass, notch
- Why IIR filters are efficient (fewer coefficients for sharp response)

**For line noise testing:** [REDACTED] likely uses filters to isolate specific frequency bands (60Hz power line noise and harmonics). Understanding filter types helps you see *why* the algorithm is structured as it is.

**Daily breakdown:**
- Days 1-3: Coursera DSP1 Module 4
- Days 4-5: Read Cycling '74 tutorials
- Days 6-7: Review and connect DSP concepts to what the code might be doing

---

## Phase 4: Integration & Hardware Context (Weeks 10-12)

### Week 10: Putting It Together—Code Reading Practice

**Activities:**
- Return to [REDACTED] code with fresh eyes
- Map the code structure:
  - Initialization routines
  - Main processing loop
  - Interrupt handlers
  - Filter implementation sections
- Create an annotated version with your understanding

**Guiding questions:**
- Where does data come from? (ADC peripheral reading the power line signal)
- Where does it go? (Processing, then output/storage)
- What operations transform it? (Filtering, analysis)
- How do interrupts fit in? (Timing, data acquisition)

**Daily breakdown:**
- Days 1-4: Systematic code walkthrough
- Days 5-7: Create annotated documentation of code structure

---

### Week 11: Optional Hardware Practice

**If you want hands-on reinforcement:**

**Option A: Ben Eater's 6502 Computer Kit**  
- https://eater.net/6502  
- ~$100 for kit, extensive YouTube tutorials
- Builds deep understanding of how assembly runs on real hardware
- Different architecture, but concepts transfer

**Option B: Microchip Curiosity Board + MPLAB**  
- ~$30-50 for PIC/dsPIC development board
- Use MPLAB X IDE (free from Microchip)
- Write and debug simple assembly programs
- More directly relevant to [REDACTED] platform

**Option C: Simulation only**  
- Use MPLAB X simulator to step through dsPIC code
- No hardware required
- Can load and trace example programs

**Daily breakdown:**
- Days 1-7: Work through chosen hardware option, or use MPLAB simulator

---

### Week 12: Review & Conversation Prep

**Activities:**
- Review all notes and reference materials
- Prepare specific questions about [REDACTED] code
- Create a glossary of terms you now understand
- Identify areas where you'd like deeper explanation from [REDACTED]

**Goal:** You should now be able to:
1. Read dsPIC assembly and understand the general flow
2. Recognize DSP operations and their purpose
3. Ask intelligent questions about specific implementation choices
4. Understand why certain hardware/software decisions were made

---

## Reference Materials (Keep Accessible)

### Microchip Documentation
| Document | Purpose |
|----------|---------|
| dsPIC Family Reference Manual (DS70046E) | Architecture, peripherals |
| dsPIC Programmer's Reference Manual (DS70030) | Instruction set details |
| Specific device datasheet | Pinouts, electrical specs |

### Online References
- TutorialsPoint Assembly: https://www.tutorialspoint.com/assembly_programming/
- dsPIC instruction quick reference (create your own)
- Z-transform and filter reference (bookmarks from Week 8-9)

### Books (Optional, for deeper study)
- *The Elements of Computing Systems* (Nisan & Schocken)—the Nand to Tetris book
- *Hands-On Electronics* (Kaplan & White)—if you want more analog/digital fundamentals

---

## Adjustments & Pacing Notes

**If you're moving faster:**
- Add more Coursera DSP modules
- Dive deeper into Microchip application notes
- Spend more time with actual code

**If you're moving slower:**
- Extend Phase 1 to 4 weeks
- Skip some DSP theory depth (focus on practical understanding)
- Don't worry about hardware practice in Week 11

**The key metric:** Can you read a section of [REDACTED] code and explain to yourself what it's doing and roughly why? That's the goal, not perfect mastery.

---

## Cost Summary

| Resource | Cost |
|----------|------|
| Coursera courses | Free (audit) |
| Nand to Tetris | Free |
| Microchip documentation | Free |
| Codecademy | Free tier sufficient |
| MIT OpenCourseWare | Free |
| **Optional:** Ben Eater kit | ~$100 |
| **Optional:** Curiosity board | ~$30-50 |

**Minimum cost: $0** (all core resources are free)

---

## Final Note

[REDACTED] decades of embedded systems experience encoded in that assembly code. You won't reach [REDACTED] level in 12 weeks—but you can develop enough literacy to appreciate what [REDACTED] built, ask meaningful questions, and potentially contribute to maintenance or documentation. The goal is bridging the communication gap, not becoming an expert.

When you hit walls, remember: every concept you don't understand is just something that hasn't been explained to you yet in terms you recognize. Your programming background gives you a huge advantage—you understand control flow, data structures, and algorithms. You're just learning a new notation and some domain-specific concepts.
