In the previous tutorial, I have explained Getting Started with PIC microcontrollers and the software etc. Today, I am going to explain the hardware of PIC18F452 i.e. the functions available in PIC18F452. In other words, working of pins. We have total 40 pins in 18F452 microcontroller. Different PIC microcontrollers have different pins and different functions. Some of the PIC Microcontrollers lack the below functions and some of them have much more functions then these. So, here I am just discussing the PIC Microcontroller 18F452, because its the moderate one and mostly used in engineering projects. Its an 8bit microcontroller. So now we are gonna have a look on the functions available in PIC18F452 microcontroller. In the next tutorial, I have discussed How to install MPLAB software in Windows and have also discussed How to Install MPLAB C18 Compiler.


There are total five ports in PIC18F452.Each port is of 1byte (8bits) and so each port has 8 pins of microcontroller except the portE it has 3 pins.These ports are named as :

  • PORTA ( Pin # 2 to Pin # 10 )
  • PORTB ( Pin # 33 to Pin # 40 )
  • PORTC ( Pin # 15 to Pin # 18 & Pin # 23 to Pin # 26 )
  • PORTD ( Pin # 19 to Pin # 22 & Pin # 27 to Pin # 30 )
  • PORTE ( Pin # 8 to Pin # 10 )

You can access any pin of any port. Ports' pins are assigned as 0,1,2,3,4,5,6,7 and 7 being the most significant bit and 0 the least so suppose if I want to use pin number 3 of port B then I will write RB2. We will see it in more detail in the coding section and as its just the hardware section so I am not going in detail of this.

Timers in PIC18F452

We have total four built in timers in the PIC18F452. These timers are also used as counters. We can set them to count anything or to set delays etc. For example we want to make a digital watch on LCD using PIC, in that case we will use timers to count. Four timers used in PIC18F452 are :

  • Timer0
  • Timer1
  • Timer2
  • Timer3

Serial Port Interfacing

PIC18F452 also supports serial interfacing using TX & RX pins. Suppose weare using any sensor and wants to make a graph of its output on the PC, then we will attach the sensor to any of the input pin and then send its data to the computer using TX and RX pins. In PIC18F452:
  • TX pin is pin # 25
  • RX pin is pin # 26
We use TX pin of PIC when we want to transmit data from PIC to computer and RX when we want to receive data into the PIC.

Some Other Fucntions

These are some advance level functions which I will explain in the advance section but readers have interest can ask in comments or can contact me. However sooner or later , I will post about all of them in detail.
  • Interrupts in PIC18F452
  • A/D converter
  • EEPROM storage
  • CCP and ECCP Programming
  • SPI Protocol
  • I2C Protocol