You are on page 1of 16

PIC18f452 1

INTRO
 PIC18f452 features and Pin Description
 Bit and Byte addressing in MPLAB C18 and MIKROC
 PRAGMA directive and oscillator settings

2
 32KB Program ROM (Code ROM/Memory)

 1536 bytes of data RAM (Data RAM)

 256 bytes of EEPROM (To store critical data that doses not need to be changed very often)

 34 I/O pins.

 13 channel, 10 bit ADC

 4 Timers (1x 8 bit and 3x16-bit)

 One serial interface

3
4
Main Difference between AVR, ARM, 8051 and PIC Microcontrollers
8051 PIC AVR ARM
32-bit mostly also available in
Bus width 8-bit for standard core 8/16/32-bit 8/32-bit
64-bit

UART, USART, SPI, I2C, (special UART, USART, LIN, I2C, SPI, CAN,
PIC, UART, USART, LIN, CAN,
Communication Protocols UART, USART,SPI,I2C purpose AVR support CAN, USB, USB, Ethernet, I2S, DSP,
Ethernet, SPI, I2S
Ethernet) SAI (serial audio interface), IrDA

Speed 12 Clock/instruction cycle 4 Clock/instruction cycle 1 clock/ instruction cycle 1 clock/ instruction cycle

Memory ROM, SRAM, FLASH SRAM, FLASH Flash, SRAM, EEPROM Flash, SDRAM, EEPROM
ISA CLSC Some feature of RISC RISC RISC

Memory Architecture Von Neumann architecture Harvard architecture Modified Modified Harvard architecture

Power Consumption Average Low Low Low

PIC16,PIC17, PIC18, PIC24, Tiny, Atmega, Xmega, special


Families 8051 variants ARMv4,5,6,7 and series
PIC32 purpose AVR
Community Vast Very Good Very Good Vast

NXP, Atmel, Silicon Labs, Dallas, Apple, Nvidia, Qualcomm,


Manufacturer Microchip Average Atmel
Cyprus, Infineon, etc. Samsung Electronics, and TI etc.

Cost (as compared to


Very Low Average Average Low
features provide)
High speed operation
Other Feature Known for its Standard Cheap Cheap, effective Vast

PIC18fXX8, PIC16f88X, Atmega8, 16, 32, Arduino LPC2148, ARM Cortex-M0 to 5


Popular Microcontrollers AT89C51, P89v51, etc.
PIC32MXX Community ARM Cortex-M7, etc.
8051 PIC18F452
8051 PIC18f452

• Von Neumann architecture • Harvard architecture (separate memory space for


• Complex instruction set computer (CISC) data & instruction
instruction set • Reduced instruction set computer (RISC)
• Developed by Intel in 1980 instruction set
• PIC (Peripheral Interface Controller) developed
by Microchip
Ram = 128 bytes Ram=1536 bytes (1.5kb)
Rom = 4k Rom = 32k
Timers = 2 Timers = 4
Serial Ports Serial Ports
• 1 - UART • 1 - USART
• 1 – MSSP (Two modes  SPI , I2C)

I/0 Ports = 4 (P0, P1, P2, P3) I/0 Ports = 5 (PORTA - PORTE)
Interrupt Sources = 6 Interrupt Sources =18
6
ADC = 8 (10-bit resolution)
CCP modules = 2
 I/O ports
 7-bit PORTA (RA0 – RA6)
 8-bit PORTB (RB0 – RB7)
 8-bit PORTC (RC0 – RC7)
 8-bit PORTD (RD0 – RD7)
 3-bit PORTE (RE0 – RE2)
 Analog channels (AN0 – AN7)
 Vdd , Vss
 External Interrupts
 INT0
 INT1
 INT2

7
8
9
10
11
12
COMPILER USED TO PROGRAM
 MPLAB C-18
 Mikro-C

Very minor
difference in
syntax!!!

13
REGISTER ADDRESSING SYNTAX
• How to move a data in any particular register of PIC???

MPLAB C-18 Mikro - C

Syntax: REGNAME = data; Same as MPLAB

e.g. TRISA = 0b10001011;


PORTC = 0xff;

14
BIT ADDRESSING SYNTAX
• How to play with particular bit of PIC???

MPLAB C-18 Mikro - C


Syntax: REGNAMEbits.BITNAME = data; Syntax: REGNAME.BITNAME = data;

e.g. TRISAbits.TRISA0 = 0; e.g. TRISA.TRISA0 = 0;


PORTCbits.RC5 = 1; PORTC.RC5 = 1;
Syntax: REGNAMEbit#_bit=data;

e.g. LATA2_bit=1; //move 1 to bit#2 of LATA


Syntax: BITNAME_bit= data;

e.g. TMR0ON_bit=1; //set TMR0ON bit of T0CON reg


RA0_bit=1; // make RA0 =1
Syntax: REGNAME.Fn=data; REGNAME.Bn=data;

e.g. PORTA.F0=1; //move 1 to bit#0 of PORTA reg.


TRISB.F6=0; //move 0 to bit#6 of TRISB reg.
INTCON.B3=1; //move 1 to bit#3 of INTCON reg. 15
 In Mikro-C following all commands does same operation

PORTA.RA2=1;
PORTA.F2=1;
PORTA.B2=1; They all
are same
PORTA2_bit=1;
RA2_bit=1;

16

You might also like