PIC18F4550 First Project in PICSimLab (McLab2 / PICGenios)
The PIC18F4550 is one of the six microcontrollers officially supported by the McLab2 and PICGenios boards in PICSimLab, and moving from the PIC16F877A to it is a natural second step: the workflow is identical, only the chip family, configuration words and port registers change. This tutorial takes you from an empty project to a running LED blink on the PIC18F4550 — and is honest about where it stops.
What you need
- PICSimLab 0.9.3 — see the download page.
- MPLAB X IDE and the XC8 compiler. As with the PIC16F, the Code Project Wizard generates an MPLAB X project for PIC18F boards.
- Board: McLab2 or PICGenios, microcontroller PIC18F4550.
- One LEDs spare part connected to RB0.
What is different from the PIC16F877A
- LAT registers: on PIC18 you write outputs through
LATBand read inputs throughPORTB. Writing to PORTB directly (PIC16 style) causes read-modify-write surprises on loaded pins. - Configuration words: PIC18F4550 uses several CONFIG registers; the example sets the essential ones (oscillator, watchdog off, low-voltage programming off). USB-related configuration is deliberately left at defaults because this tutorial does not use USB.
- Analog defaults: several pins power up as analog inputs; the example sets
ADCON1so PORTB pins behave as digital I/O.
Steps
1. Select the board and the PIC18F4550
Start PICSimLab, choose the McLab2 board (or PICGenios) and set the microcontroller to PIC18F4550. Generating the project after this selection is what makes the wizard target the right chip.
2. Generate and build the project
Use the Code Project Wizard to generate the MPLAB X project, paste in the example code, and build. MPLAB X produces the .hex file as usual. The official documentation also points to board example sources in MPLAB X + XC8 from Help → Examples if you want a larger starting point.
3. Add the LED and load the hex
Open Modules → Spare parts, add Outputs → LEDs and connect the first LED to RB0 in Properties. Load the hex file and start the simulation: the LED blinks once per second.
4. Know the scope: no USB in this tutorial
The PIC18F4550 is famous for its USB peripheral, so be precise about expectations: the official PICSimLab documentation for these boards describes the chip and the MPLAB X/XC8 example flow, and does not document USB simulation for it. This tutorial therefore covers the core digital I/O workflow only. If your goal is a real USB device, plan to develop and test that part on physical hardware; use PICSimLab for the surrounding logic (buttons, displays, ADC, serial-style state machines) where simulation genuinely helps.
Example code (XC8, PIC18F4550)
// Example: first PIC18F4550 project, blink on RB0 - XC8
#pragma config FOSC = HS // High-speed oscillator (example)
#pragma config WDT = OFF // Watchdog off
#pragma config PBADEN = OFF // PORTB pins digital on reset
#pragma config MCLRE = ON // MCLR enabled
#pragma config LVP = OFF // Low-voltage programming off
#pragma config XINST = OFF // Extended instruction set off
#include <xc.h>
#define _XTAL_FREQ 20000000 // Example: match the board clock
void main(void) {
ADCON1 = 0x0F; // all analog pins digital
TRISBbits.TRISB0 = 0; // RB0 output
LATBbits.LATB0 = 0; // LED off (write via LATB on PIC18)
while (1) {
LATBbits.LATB0 = 1;
__delay_ms(500);
LATBbits.LATB0 = 0;
__delay_ms(500);
}
}
Try next
- PIC16F877A blink — compare the same project across the two families.
- HD44780 LCD — port the LCD driver to LAT registers on the 4550.
- UART serial — the 4550 USART follows the same pattern as the 877A.
Troubleshooting
The project builds for the wrong chip. The device selected in MPLAB X must be PIC18F4550 and the hex must be loaded after selecting the PIC18F4550 on the board in PICSimLab. A PIC16F877A hex will not run correctly on the 4550 configuration.
RB0 does nothing. Check the two PIC18 traps first: pins left as analog inputs (fix with ADCON1/PBADEN as in the example) and output writes done to PORTB instead of LATB.
