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.
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.
–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.
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
For All Your PCB Need, One-stop PCB Solution Services Appear:
EasyEDA: free PCB design tool, 200,000+ engineers are using
PCBs: 10pcs 2-layer 10x10cm only $8.21, on-time global shipping
Components: save 50% on cost, save on freight if shipped with ordered PCBs