Menu

Adskeeper - header widge

728x90

Search This Blog

468x60

Navbar

AdsKeeper - IAB Display Standard Ad Unit

Saturday, October 17, 2026

PIC18F4550 LED and Switch Interfacing using MikroC

Introduction

PIC18F4550 is a high performance 8-bit PIC micro-controller produced by Microchip Technology nearly two decades now. It's a USB micro-controller since it has a USB interface that supports up to USB 2.0. It operates up to 48MHz by enable its Phase Lock Loop (PLL) with pre-scaler and post-scaler settings.

 

PIC18F4550 LED and Switch Interfacing using MikroC
A DIY PIC18F4550 Prototype Board

 

It has up to 5 I/O ports ranging from PORTA to PORTE. They are digital programmable input output ports. Some ports have an alternative functions such as ADC inputs, PWM output, SPI, I2C, interrupt capture, etc.

PIC18F4550 LED and Switch Interfacing using MikroC
PIC18F4550-I/P I stock and its pin diagram

 

This 8-bit chip is very easy to program since there are a lot of compilers including Assembly and C. Using Assembly is free since the manufacture offer this feature with it MPLABX IDE compiler.  

Today, using a high level programming language is common since modern micro-controllers have a large RAM and Flash memory space. The XC8 C compiler is free of charge with some limited C language features. Some commercial C compiler for this chip are CCS PICC, Mikroelektronika MikroC, IAR Embedded Workbench for PIC18, etc. 

However Mikroelektronika offers a free version of its compiler for evaluation without limiting any features. But the compiling code is not larger than 2KB. It's suitable for any small control project, students and hobbyists.

 

PIC18F4550 LED Blinking using MikroC

I test the oscillator and on-board LED of my DIY PIC18F4550 prototype board by blinking an LED connects to RD0.

The on-board crystal clock frequency is 20MHz. So need to do additional configurations to get a 48MHz clock frequency. It's useful to drive the USB hardware clock of this micro-controller. 

After creating a new project, go to Project menu and click on Edit Project as show in the picture below.

 

PIC18F4550 LED and Switch Interfacing using MikroC
Edit Project to set a 48MHz clock frequency.

Schematic

 

PIC18F4550 LED and Switch Interfacing using MikroC
Schematic

 

 

MikroC Source Code


  1. #define LED LATD0_bit

  2. void main() {
  3. PORTD = 0;
  4. LATD = 0;
  5. TRISD = 0;
  6. while(1){
  7. LED = 0;
  8. Delay_ms(1000);
  9. LED = 1;
  10. Delay_ms(1000);
  11. }
  12. }

 

 Hardware Test

 

PIC18F4550 LED and Switch Interfacing using MikroC
LED Blinking at RD0

 We can do the LED blinking using MPLABX XC8 or CCS PICC Compiler with the same chip.

 

 

 

 

 

 

No comments:

Post a Comment

Adskeep- Standard Ads

Electronics and Programming Tutorials

336x280

DIY Electronic Projects And Instruments

AdsKeeper - 2091654

Labels

23K256 (1) 24C16B (2) 25AA010A (2) 8051 (7) 93AA46B (1) ADC (40) Analog Comparator (1) Arduino (16) ARM (32) AT89C52 (7) ATMega32 (59) ATMega644P (27) AVR (88) AVR PCB (2) Bootloader (1) CCS PICC (31) Change Notify Interrupt (CNI) (2) DAC (2) DHT11 (5) Display (157) Distance Sensor (3) dot matrix (1) ds1307 (10) DS18B20 (6) ds3231 (2) ds3232 (2) dsPIC (16) dsPIC30F1010 (3) dsPIC30F2010 (15) EEPROM (5) Environment Sensor (6) ESP32 (1) esp8266 (1) Graphical LCD (3) HD44780 (12) I2C (40) ILI9341 (1) Input/Output (84) Interrupt (22) IoT PCB (1) Keil (5) Keypad (16) KS0108 (3) LCD (87) LM35 (4) Master/Slave (2) MAX7221 (1) MCP23017 (8) MCP23S17 (7) MCP4921 (1) MCP4922 (2) Meter (3) MikroC (2) MikroC ARM (1) MikroC dsPIC (11) MikroC PIC (1) Module PCB (2) Motor (15) MPLABX (73) Nokia 5110 LCD (5) OLED (2) One-Wire (7) Oscillator (8) PCB (13) PCD8544 (3) PCF8574 (13) PIC (121) PIC12F (3) PIC16 (105) PIC16F628A (3) PIC16F630 (2) PIC16F716 (4) PIC16F818 (11) PIC16F818/819 (3) PIC16F84A (16) PIC16F876A (2) PIC16F877A (9) PIC16F88 (2) PIC16F887 (60) PIC18 (19) PIC18F1220 (5) PIC18F2550 (5) PIC18F4550 (13) PICKit2 (1) PICMicro PCB (4) Pin Change Interrupt (1) PLL (1) PWM (12) RTC (13) SBN0064G (1) Sensor (15) SH1106 (3) Shift Register (15) Shift Registers (19) SN74HC595N (9) Software SPI (1) Software TWI (3) SPI (44) sprinf (3) ST7735 (1) STM32 (29) STM32 Black Pill (1) STM32 Blue Pill (12) STM32 HAL (23) STM32CubeIDE (32) STM32F103C8T6 (9) STM32F103R6 (18) STM32F401CCU6 (1) SysTick (7) temperature sensor (15) TFT (1) TG12864A (1) Thermometer (22) Timer/Counter (32) TM1637 (2) twi (10) UART (11) Ultrasonic (4) Voltmeter (7) WDT (1) XC16 (2) XC8 (96)