MPLAB v8, MPLAB X, Proteus, and board
So far you learned what to write in assembly (MPASM), how the configuration word works (config bits), and the PIC minimum system. This page closes Foundations: which tools you use to build, simulate, and test in the UNEXPO course.
The academic workflow focuses on MPLAB v8 + MPASM + Proteus. You will also see MPLAB X so you recognize the modern IDE on another machine.
What MPLAB is (and what it is not)
Section titled “What MPLAB is (and what it is not)”Reports and labs mix three names. Keep them separate:
| Tool | What it is | Course role |
|---|---|---|
| MPLAB v8 / X | IDE — development environment | Edit .ASM, create project, run build, program with PICkit |
| MPASM | Assembler | Translates .ASM → .HEX (program + configuration word) |
| Proteus ISIS | Simulator | Runs .HEX in a virtual circuit — does not compile |
| PICkit / programmer | Burner | Writes .HEX to real PIC Flash |
MPLAB is not the assembler. MPLAB is the workspace; when you click Build, MPLAB calls MPASM for you.
Step 1 — Write the .ASM in MPLAB
Section titled “Step 1 — Write the .ASM in MPLAB”Create a PIC18F4550 project and edit source using the sandwich layout: LIST, #include, CONFIG, ORG, subroutines, programa: at the bottom.
The file on disk is plain text (.ASM / .asm). MPLAB saves and highlights it — there is no .HEX yet.
Step 2 — Build with MPASM
Section titled “Step 2 — Build with MPASM”Project → Build All invokes MPASM. If there are no errors, you get the .HEX:
your_program.ASM ↓ MPASM (from MPLAB) your_program.HEX ← Flash program + config bits your_program.COD ← listing (optional, debug)If END is missing, a symbol lacks #include, or a label is wrong, the build fails — do not simulate until you fix the Output window.
Step 3 — Simulate in Proteus
Section titled “Step 3 — Simulate in Proteus”Wire the minimum system + LED, load the same .HEX into the virtual PIC, and press Play. Proteus interprets .HEX bytes; it does not read your .ASM directly.
Step 4 — Physical board
Section titled “Step 4 — Physical board”With the same .HEX (rebuilt if you changed code), connect PICkit, Program in MPLAB, and validate the LED or peripheral on the breadboard.
What the .HEX file contains
Section titled “What the .HEX file contains”The .HEX is the bridge between software and hardware. It is not readable .ASM — Intel HEX format with two conceptual blocks:
.HEX content | Source in your .ASM | Destination |
|---|---|---|
| Program (instructions) | ORG, GOTO, MOVLW, BSF… | Executable Flash |
| Configuration word | CONFIG directives | Config memory (startup) |
One file feeds Proteus and the programmer: both need program and config bits matching the 20 MHz crystal and course template.
Full chain — from text to the PIC
Section titled “Full chain — from text to the PIC” MPLAB editor (.ASM) ↓ Build / assemble MPASM → .HEX file (+ optional .cod) ↓ ┌────────────────┴────────────────┐ ↓ ↓Proteus (simulation) PICkit / programmer ↓ ↓Virtual LED, logic pins UNEXPO physical board| Stage | Tool | Input | Output |
|---|---|---|---|
| Write | MPLAB v8 / X | Your source code | .ASM |
| Assemble | MPASM | .ASM | .HEX (program + config bits) |
| Simulate | Proteus ISIS | .HEX + schematic | Virtual behavior |
| Program | PICkit 2/3, etc. | .HEX | PIC18F4550 Flash |
Full walkthrough — minimal example (First LED)
Section titled “Full walkthrough — minimal example (First LED)”Suppose you turn on RB0. The full flow:
1. Source in MPLAB — minimal fragment (see Assembly — LED):
LIST P=18F4550 #include <P18F4550.INC> CONFIG FOSC = HS, WDT = OFF, LVP = OFF, PBADEN = OFF
ORG 0x0000 GOTO programa ; jump to main
programa: BCF TRISB, 0 BSF LATB, 0loop: GOTO loop ; jump → destination loop: (above)
END2. Build in MPLAB → project.hex appears with no errors in Output.
3. Proteus — PIC18F4550 + 20 MHz crystal + LED on RB0 → Program File = that .HEX → Clock Frequency = 20 MHz → Play.
4. Board — same .HEX, PICkit, Program → LED on if wiring and config bits match.
If you change one .ASM line, go back to step 2 before Proteus or the board. An old .HEX is the #1 cause of “simulation does not show my change”.
MPASM — what happens when you build
Section titled “MPASM — what happens when you build”MPASM reads your assembly file and:
- Translates mnemonics (
MOVLW,BSF…) into machine code. - Resolves labels,
#includesymbols, andCONFIGdirectives. - Generates the
.HEXfor programmer or Proteus. - Reports errors if
ENDis missing, labels duplicate, or symbols are undefined.
Files you see after a build
Section titled “Files you see after a build”| File | Purpose |
|---|---|
.HEX | Load into Proteus or programmer — the important one |
.COD | Listing with addresses and machine code (debug) |
.LST | Source mixed with listing (if enabled) |
.ERR | Assembly errors (if build fails) |
If the build fails, there is no useful .HEX — fix errors in the output window before simulating.
MPASM errors you will see in MPLAB
Section titled “MPASM errors you will see in MPLAB”| Output message | Common cause | Review |
|---|---|---|
Symbol not defined | Missing #include <P18F4550.INC> or typo (TRISB) | Assembly — directives |
Label required | Label without : (programa vs programa:) | Labels |
END directive required | Missing END at end | Sandwich layout |
Bank select error | Variable in another bank without BSR | Registers — banks |
Argument out of range | Literal outside 0–255 | Literals |
MPLAB v8 project — what the wizard creates
Section titled “MPLAB v8 project — what the wizard creates”The Project Wizard does not write code for you; it organizes files and tells MPASM which MCU and tool to use:
| Project element | Function |
|---|---|
| PIC18F4550 device | MPASM generates correct opcodes for that chip |
| MPASM toolchain | Not XC8 if the course is pure assembly |
Added .asm file | Source you build |
| Project folder | Where .HEX appears after Build All |
After building, find the .HEX in the project folder (sometimes Debug/, sometimes root). That path is what you load in Proteus → Program File.
MPLAB v8 — main course IDE
Section titled “MPLAB v8 — main course IDE”MPLAB v8 is Microchip’s classic IDE. UNEXPO labs often use it because it fits MPASM and pure .ASM projects well.
Create a project
Section titled “Create a project”- Project → Project Wizard
- Select PIC18F4550
- Tool: MPASM (not XC8 if you only use assembly)
- Project name and folder
- Add your
.asmfile to the project
- Project → Build All (or hammer icon)
- Check Output — should say Build succeeded
- Find the
.hexin the project folder (e.g.Debug/or root)
Config bits in MPLAB v8
Section titled “Config bits in MPLAB v8”You can edit them via Configure → Configuration Bits, but in the course it is better to declare them in .ASM (config bits) so report and .HEX match.
Typical build errors
Section titled “Typical build errors”| Message | Common cause |
|---|---|
Symbol not defined | Missing #include <P18F4550.INC> or typo in TRISB |
Label required | Label without : (start vs start:) |
END directive required | Missing END at file end |
Bank select error | Variable in another bank without correct BSR |
When to use it
Section titled “When to use it”MPLAB X is the modern IDE (NetBeans-based). Microchip promotes it for new XC8 projects, but it can assemble .ASM with the right toolchain.
Summary steps
Section titled “Summary steps”- File → New Project → Standalone Project
- Device: PIC18F4550
- Pick a toolchain compatible with assembly
- Add your
.asmto the project - Production → Build Main Project
- Check Output and locate the
.hex
If your instructor requires MPLAB v8, do not mix v8 and X projects in the same folder — paths and settings differ.
Build the circuit
Section titled “Build the circuit”- Place PIC18F4550 on the schematic
- Wire minimum system: 20 MHz crystal, capacitors, MCLR pull-up, VDD/VSS, decoupling
- Add LED + resistor on RB0 (or your lab pin)
- Check common ground and LED polarity
Load the .HEX
Section titled “Load the .HEX”- Double-click the PIC → Program File tab
- Select the
.hexfrom MPASM - Set Clock Frequency to 20 MHz (matches
FOSC = HSand crystal) - OK and save schematic
Run simulation
Section titled “Run simulation”- Play (Run simulation)
- Watch virtual LED and RB0 levels
- Use Debug to inspect registers if your version allows
- If it does not start: check loaded
.HEX, clock frequency, and config bits
Proteus does not assemble — it only runs the .HEX you built in MPLAB.
Before programming
Section titled “Before programming”- Stable 5 V supply and decoupling cap
- 20 MHz crystal + caps + MCLR 10 kΩ (minimum system)
- Check LED wiring (220–330 Ω resistor)
- No shorts on the breadboard
Program the MCU
Section titled “Program the MCU”- Connect PICkit 2/3 (or lab programmer) to ICSP
- In MPLAB: Programmer → Select Programmer
- Program with the same
.HEXused in Proteus - Confirm Programming/Verify complete
Validate
Section titled “Validate”- LED on/off per your code
- Multimeter on output pins if something fails
- Compare with simulation — Proteus OK but board not → suspect hardware (wiring, supply, wrong config bits)
MPLAB vs Proteus vs board — who does what
Section titled “MPLAB vs Proteus vs board — who does what”| Task | MPLAB + MPASM | Proteus | Physical board |
|---|---|---|---|
| Write code | ✅ | ❌ | ❌ |
Build .HEX | ✅ | ❌ | ❌ |
| Simulate without hardware | ❌ | ✅ | ❌ |
| Real crystal timing | ❌ | Approximate | ✅ |
| Noise, contacts, bounce | ❌ | Limited | ✅ |
| Program PIC Flash | With programmer | Simulates only | ✅ |
Course rule: build without errors first, then simulate in Proteus, then breadboard.
Cross-tool consistency — checklist
Section titled “Cross-tool consistency — checklist”Before saying “it does not work”, verify everything matches:
- Device: PIC18F4550 in MPLAB, Proteus, and board
-
CONFIG FOSC = HSand 20 MHz crystal in schematic and Proteus - Same
.HEXin Proteus and programmer (rebuild after every change) -
PBADEN = OFF,LVP = OFF,WDT = OFF(course template) - LED pin matches code (
RB0→BCF TRISB,0andBSF LATB,0) - Rebuilt after editing
.ASM
Ejercicio · Parcial
Order the workflow
Correct order for the First LED practice:
- Write
.ASMwithLIST,#include,CONFIG,ORG, GPIO code - Build in MPLAB → get
.HEX - Build schematic in Proteus with 20 MHz crystal
- Load
.HEXinto Proteus PIC - Simulate and verify LED
- Breadboard and program with PICkit
Typical mistake: loading an old .HEX in Proteus after changing code without rebuilding — simulation does not reflect your latest changes.
Common mistakes
Section titled “Common mistakes”- Proteus without loaded
.HEX: PIC simulates empty memory or old program. - Proteus clock not 20 MHz: timing and some peripherals won’t match the board.
- Mixing MPLAB X and v8 projects: conflicting paths and toolchains.
- Simulation OK, board not: check supply, MCLR, crystal, PIC orientation, LVP/PBADEN.
- Board OK, simulation not: outdated
.HEXor wrong Proteus frequency. - Treating Proteus as compiler: Proteus does not replace MPASM — it only runs
.HEX.
Exam-style questions
Section titled “Exam-style questions”What is the difference between MPLAB and MPASM?
MPLAB is the environment (editor, project, programmer). MPASM is the assembler that translates .ASM → .HEX when you Build.
What file does MPASM produce on a successful build?
A .HEX file with program and config bits for programming or simulation.
What is Proteus used for in the course?
To simulate circuit and program before the physical board, loading the .HEX from MPLAB.
Does MPLAB assemble directly or use another tool?
MPLAB invokes MPASM (for pure assembly projects in the course).
Why must Proteus clock frequency match the crystal?
Execution time and peripherals depend on Fosc; with FOSC = HS and 20 MHz crystal, Proteus should use 20 MHz.
MPLAB and Proteus
0 of 0 answered
Sign in with CALETAS to sync this result across devices.
Sign in with CALETAS