PIC18F2550 : Blink LED using XC8 Compiler

Welcome to another chapter of PIC18F programming Tutorial. In this chapter we are going to program a simple 28 pin PIC18F2550 microcontroller using mplabx IDE and XC8 Compiler.

The concepts for programming a pic18f2550 microcontroller is still going to be almost same as previous tutorials on pic18f4550 microcontroller, however since pic18f2550 is a different microcontroller in the same pic18F family, so little modification is required with the way it is coded.PIC18F2550 Blink LED using XC8 Compiler

In this tutorial we are going to blink few simple led using pic18f2550. Two source codes are posted here which basically does the same thing, but the motive is to project the various style of coding the same thing in different ways. The method posted here are some of the most common methods for coding a PIC18F2550 microcontroller.

Unlike the traditions c18, here we choose to use the xc8 compiler which happened to be the most recent compiler introduced by microchip. PIC18F2550 is a 28 pin Microcontroller, which also supports USB communication. Always download a copy of pic18F2550 Datasheet from the manufacturer’s website before experimenting with the respective microcontroller.

Components Required

Breadboard
PIC18F2550 Microcontroller
-LED
IC 7805 (if necessary)

Blinking a led is comparatively is simple, we just have to define the ports output and Set the pins to high or low with enough delay in between the High and low for a visible blink. If the power source for input to microcontroller is more than 5V then add a IC 7805 before proving the Input voltage to avoid damage to the microcontroller.

-Source Code – 1

-Source Code – 2 PIC18F2550 Blink LED using XC8 Compiler schematich

Source Code 1

As mentioned above, that the Source code here is compiled with mplabx ide and XC8 compiler however you can use the traditional c18 compiler as well, if you prefer the old Mplab IDE.  The code below blinks the led with delay of few seconds. Without using any predefined delay routines. For delay we would use a simple for loop, the next example shows without using an for loop which is much more simple and short.

 

 

For more detail: PIC18F2550 : Blink LED using XC8 Compiler

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter