PIC18F4520 8-bit PIC Microcontroller
PIC18F4520 is a low-cost, low-power, high-speed 8-bit, fully-static Microcontroller unit with 40 pins, 36 of which can be used as I / O pins. It has power-on-reset (POR) and the WDT circuitry (Extended Watchdog Timer), which can be programmed for 4 ms to 131 s.
PIC18F4520 Pin Configuration
Pin Number |
Pin Name |
Description |
1 |
MCLR / VPP / RE3 |
MCLR[Master Clear (Reset) input] is used during programming, mostly connected to a programmer like PicKit / Programming voltage input or 3rd pin of PORTE |
2 |
RA0 / AN0 |
0th pin of PORTA or Analog pin 0 |
3 |
RA1 / AN1 |
1st pin of PORTA or Analog pin 1 |
4 |
RA2 / AN2 / VREF- / CVREF |
2nd pin of PORTA or Analog pin 2 or A/D reference voltage(low) input or Comparator reference voltage output |
5 |
RA3 / AN3 / VREF+ |
3th pin of PORTA or Analog pin 3 or A/D reference voltage (high) input |
6 |
RA4 / T0CKI / C1OUT |
4th pin of PORTA or Timer0 external clock input or Comparator 1 output |
7 |
RA5 / AN4 / SS / HLVDIN / C2OUT |
5th pin of PORTA or Analog pin 4 or SPI slave select input or High/Low-Voltage Detect input or Comparator 2 output |
8 |
RE0 / RD / AN5 |
0th pin of PORTE or Read control for Parallel Slave Port or Analog pin 5
|
9 |
RE1 / WR / AN6 |
1st pin of PORTE or Write control for Parallel Slave Port or Analog pin 6 |
10 |
RE2 / CS / AN7 |
2nd pin of PORTE or Chip Select control for Parallel Slave Port or Analog pin 7 |
11 |
Vdd |
Positive Pin of MCU (+5V) |
12 |
Vss |
Ground Pin of MCU |
13 |
OSC1 / CLKI / RA7 |
7th pin of PORTA or Oscillator crystal or external clock input |
14 |
OSC2 / CLKO / RA6 |
6th pin of PORTA or Oscillator crystal or external clock output |
15 |
RC0 / T1OSO / T13CKI |
0th pin of PORTC or Timer1 oscillator output or Timer1/Timer3 external clock input |
16 |
RC1 / T1OSI / CCP2 |
1st pin of PORTC or Timer1 oscillator input or Capture 2 input / Compare 2 output / PWM2 output |
17 |
RC2 / CCP1 / P1A |
2nd pin of PORTC or Capture 1 input / Compare 1 output / PWM1 output or Enhanced CCP1 output |
18 |
RC3 / SCK / SCL |
0th pin of PORTC or Serial Clock In/Out for SPI & I2C |
19 |
RD0 / PSP0 |
0th pin of PORTD or Parallel Slave Port data |
20 |
RD1 / PSP1 |
1st pin of PORTD or Parallel Slave Port data |
21 |
RD2 / PSP2 |
2nd pin of PORTD or Parallel Slave Port data |
22 |
RD3 / PSP3 |
3th pin of PORTD or Parallel Slave Port data |
23 |
RC4 / SDI / SDA |
4th pin of PORTC or SPI data in or I2C data in/out |
24 |
RC5 / SDO |
5th pin of PORTC or SPI data out |
25 |
RC6 / TX / CK |
6th pin of PORTC or USART asynchronous transmit or USART synchronous clock |
26 |
RC7 / RX / DT |
7th pin of PORTC or USART asynchronous receive or USART synchronous data
|
27 |
RD4 / PSP4 |
4th pin of PORTD or Parallel Slave Port data |
28 |
RD5 / PSP5 / P1B |
5th pin of PORTD or Parallel Slave Port data or Enhanced CCP1 output. |
29 |
RD6 / PSP6 / P1C |
6th pin of PORTD or Parallel Slave Port data or Enhanced CCP1 output. |
30 |
RD7 / PSP7 / P1D |
7th pin of PORTD or Parallel Slave Port data or Enhanced CCP1 output. |
31 |
Vss |
Ground Pin of MCU |
32 |
Vdd |
Positive Pin of MCU (+5V) |
33 |
RB0 / IN0 / FLT0 / AN12 |
0th pin of PORTB or External interrupt 0 or PWM Fault input for Enhance CCP1 or Analog pin 12 |
34 |
RB1 / INT1 / AN10 |
1st pin of PORTB or External interrupt 1 or Analog pin 10 |
35 |
RB2 / INT2 / AN8 |
2nd pin of PORTB or External interrupt 2 or Analog pin 8 |
36 |
RB3 / AN9 / CCP2 |
3th pin of PORTB or Analog pin 9 or Capture 2 input / Compare 2 output / PWM2 output |
37 |
RB4 / KBI0 / AN11 |
4th pin of PORTB or Interrupt-on-Change pin or Analog pin 11 |
38 |
RB5 / KBI1 / PGM |
5th pin of PORTB or Interrupt-on-Change pin or Low-Voltage ICSP™ Programming enable |
39 |
RB6 / KBI2 / PGC |
6th pin of PORTB or Interrupt-on-Change pin or In-Circuit Debugger and ICSP programming data pin. |
40 |
RB7 / KBI3 / PGD |
7th pin of PORTB or Interrupt-on-Change pin or In-Circuit Debugger and ICSP programming data pin. |
Features and Specification of the PICPIC18F4520 Microcontroller
PIC18F4520 - Simplified Features and Specification |
|
CPU |
High performance 8-bit |
Number of Pins |
40 |
Operating Voltage (V) |
2-5.5V |
Number of I/O pins |
36 |
ADC Module |
10-bit, 13-channel |
Timer Module |
1 x 8-bit 3 x 16-bit |
Capture/Compare/PWM Peripherals |
2 x Capture module 2 x Compare module, 2 x PWM module, |
DAC Module |
Nil |
Communication Peripherals |
1 x USART 1 x SPI 1 x I2C |
External Oscillator |
Up to 40Mhz |
Internal Oscillator |
8Mhz, 32Khz |
Program Memory (KB) |
32KB |
CPU Speed (MIPS) |
10 MIPS |
RAM (byte) |
1536 |
Data EEPROM (byte) |
256 |
Note: Complete technical details can be found in the PIC18F4520 Datasheet linked at the bottom of this page.
Alternative for PIC18F4520:
Introduction toPIC18F4520
PIC18F4520 is a low-cost, low-power, high-speed 8-bit, fully-static Microcontroller unit that has 40 pins out of which 36 pins can be used as I/O pins. It has Power-on-Reset (POR) as well as the Extended Watchdog Timer (WDT) circuitry, which can be programmed for 4ms to 131s.
It has Power Management Features, which is useful for low-power applications. It has 3 power management modes.
1. RUN mode
2. SLEEP mode
3. IDLE mode
PIC18F4520 also comes with 3 programmable external interrupts & 4 Interrupts-On-Change (IOC) pins, which are reliable features for interrupts related applications. Also, the system has a 13-channel 10-bit ADC converter module.
It has a wide operating voltage range, from 2V to 5.5V., Thus it can be used in 3.3V or 5.0V logic level operations. The below image is showing the detailed pin diagram of the PIC18F4520.
Detailed Features of PIC18F4520
PIC18F4520 –Detailed Features |
|
CPU |
High performance 8-Bit |
Architecture |
8 |
Program Memory Size (Kbytes) |
32 |
RAM (bytes) |
1536 |
EEPROM/HEF |
256 |
Pin Count |
40 |
Max. CPU Speed (MHz) |
40 |
Peripheral Pin Select (PPS) |
No |
Internal Oscillator |
8Mhz, 32Khz |
No. Of comparators |
2 |
No. Of Operational Amplifier |
0 |
No. Of ADC channels |
13 |
Max ADC Resolution (bits) |
10 |
ADC with Computation |
2 |
Number of DAC Converter |
0 |
Max DAC resolution |
- |
Internal Voltage Reference |
No |
Zero Cross Detect |
No |
No. Of 8-bit timers |
1 |
No. Of 16-bit Timers |
3 |
Signal Measurement Timer |
0 |
Hardware Limit Timer |
0 |
No. Of PWM outputs |
2 |
Max PWM resolution |
10 |
Angular Timer |
0 |
Math Accelerator |
No |
No. Of UART module |
1 |
No. Of SPI Module |
1 |
No. Of I2C module |
1 |
No. Of USB Module |
0 |
Windowed Watchdog Timer (WWDT) |
Yes |
CRC/Scan |
No |
Numerically Controlled Oscillator |
No |
Cap. Touch Channels |
0 |
Segment LCD |
0 |
Minimum Operating Temperature (°C) |
-40 |
Maximum Operating Temperature (°C) |
125 |
Minimum Operating Voltage (V) |
2 |
Maximum Operating Voltage (V) |
5.5 |
High Voltage Capable |
No |
Programming PIC Microcontroller
PIC microcontrollers can be programmed with different software that is available in the market. There are people who still use Assembly language to program PIC MCUs. The below details is for the most advanced and common software and compiler that has been developed by Microchip itself.
In order to program the PIC microcontroller, we will need an IDE (Integrated Development Environment), where the programming takes place. A compiler, where our program gets converted into MCU readable form called HEX files. An IPE (Integrated Programming Environment), which is used to dump our hex file into our PIC MCUs.
IDE: MPLABX v3.35
IPE: MPLAB IPE v3.35
Compiler: XC8
Microchip has given all these three software for free. They can be downloaded directly from their official page. I have also provided the link for your convenience. Once downloaded, install them on your computer. If you have any problem doing so, you can post them on the comment below.
To dump or upload our code into PIC, we will need a device called PICkit 3. The PICkit 3 programmer/debugger is a simple, low-cost in-circuit debugger that is controlled by a PC running MPLAB IDE (v8.20 or greater) software on a Windows platform. The PICkit 3 programmer/debugger is an integral part of the development engineer's tool suite. A basic programming circuit for PIC18F4520 is given below.
In addition to this, we will also need other hardware like a Perf board or breadboard, Soldering station, PIC ICs, Crystal oscillators, capacitors, etc.
Components associated with PIC
PICkit3, PIC Development Board, Crystal Oscillators, Capacitors, 12V Adapter, 7805 Voltage Regulator.
Application of PIC18F4520
This is a basic Mid-range 8-bit microcontroller unit that can be used in the following applications-
1. Input-Output operations
2. Control Applications
3. Analog data Processing
4. Sensors integration and data logging
5. Small scale, low cost embedded application based production
2D Model
The dimensions of the PIC18F4520 are shown below-