The PIC Workflow: MPLAB X + XC8 Projects for PICSimLab

PICSimLab has no source-code editor — by design, it emulates hardware, and you write code with the same tools you would use for a real board. For PIC microcontrollers that tool chain is MPLAB X IDE with the XC8 compiler, and PICSimLab’s Code Project Wizard is built around it: for boards based on PIC16F and PIC18F microcontrollers, the wizard generates projects that use MPLAB X. This guide walks the whole path from wizard to a debuggable simulation.

Prerequisite: install MPLAB X and XC8 first

The wizard’s PIC path assumes its tools already exist. Per the official software requirements, boards based on PIC16F and PIC18F need MPLAB X IDE and the XC8 compiler installed beforehand. Install both from Microchip before you generate a project; without XC8, the generated project opens but cannot build. (The AVR, STM32 and ESP32 boards use a different wizard path — VSCode + PlatformIO — covered in the PlatformIO / Arduino IDE workflow.)

Step 1: Select the board and chip in PICSimLab

Select your board and microcontroller first — for example McLab2 with a PIC16F877A, or the same board with a PIC18F4550. The wizard generates the project for the current selection, so changing the chip afterwards means regenerating. Board pages on this site list exactly which chips each board supports: see McLab2 and PICGenios.

Step 2: Generate the project with the Code Project Wizard

Run the Code Project Wizard for the selected board. For PIC16F/PIC18F boards it creates an MPLAB X project using XC8, with the official code templates as the starting point — the template list includes Blink examples (including a Blink FreeRTOS template) for the PIC boards. Save the generated project in your own working folder.

Step 3: Write code and build in MPLAB X

Edit the code in MPLAB X, not in PICSimLab. Two habits save debugging time later:

  • Set the clock define your code relies on (for example _XTAL_FREQ in XC8 delay calls) to the clock configured for the board in PICSimLab.
  • Build until the project compiles cleanly. A successful build produces the .hex file you will load — if the build fails, fix it here; PICSimLab can only run firmware that actually built.

Step 4: Load the .hex and run

Back in PICSimLab, with the same board and chip selected, load the built .hex and run. The full loading order and the mismatch checks are in the hex loading guide; the PIC16F877A blink tutorial and the PIC18F4550 first project show this exact workflow with complete example code.

Step 5 (optional): Debug from MPLAB X

The desktop version can be debugged from inside MPLAB X, the way you would debug a real board: install the PICSimLab plugin file com-picsim-picsimlab.nbm in MPLAB X, and MPLAB X connects to PICSimLab through a TCP socket on port 1234 (allow it through your firewall). The complete setup is in the MPLAB X plugin guide; if the connection fails, work through plugin connection fixes. Note this is a desktop-only feature — the online version has no debugging support.

Where does this fit in the bigger picture? This workflow is Step 4 material on the getting started path: install, first simulation, board choice, then your own compiled projects.

Similar Posts