Sei sulla pagina 1di 10

PIC18f452

COURSE: Microprocessors and Microcontrollers-II


CONTACT: atiq@mail.au.edu.pk
INTRO
 PIC18f452 features and Pin Description
 Bit and Byte addressing in MPLAB C18 and MIKROC
 PRAGMA directive and oscillator settings
8051 PIC AVR ARM
Main Difference 32-bit mostly also
Bus width 8-bit for standard core 8/16/32-bit 8/32-bit
between AVR, ARM, available in 64-bit
UART, USART, LIN, I2C,
8051 and PIC UART, USART, SPI, I2C,
SPI, CAN, USB,
Communication PIC, UART, USART, LIN, (special purpose AVR
Microcontrollers Protocols
UART
CAN, Ethernet, SPI, I2S support CAN, USB,
Ethernet, I2S, DSP,
SAI (serial audio
Ethernet)
interface), IrDA

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

Flash, SDRAM,
Memory ROM, SRAM, FLASH SRAM, FLASH Flash, SRAM, EEPROM
EEPROM
ISA CISC RISC RISC RISC
Modified Harvard
Memory Architecture Harvard architecture Harvard architecture Harvard
architecture
Power Consumption Average Low Low Low
PIC16,PIC17, PIC18, Tiny, Atmega, Xmega,
Families 8051 variants ARMv4,5,6,7 and series
PIC24, PIC32 special purpose AVR
Community Vast Very Good Very Good Vast
NXP, Atmel, Silicon Labs, Apple, Nvidia,
Manufacturer Dallas, Cyprus, Infineon, Microchip Average Atmel Qualcomm, Samsung
etc. Electronics, and TI etc.
Cost (as
compared to features Very Low Average Average Low
provide)
High speed operation
Other Feature Known for its Standard Cheap Cheap, effective Vast

LPC2148, ARM Cortex-


Popular PIC18fXX2, PIC16f88X, Atmega8, 16, 32,
AT89C51, P89v51, etc. M0 to ARM Cortex-M7,
Microcontrollers PIC32MXX Arduino Community
etc.
8051 PIC18F452
8051 PIC18f452

• Harvard architecture (separate memory space for • Harvard architecture


data & instruction) • Reduced instruction set computer (RISC)
• Complex instruction set computer (CISC) instruction set
instruction set • PIC (Peripheral Interface Controller) developed
• Developed by Intel in 1980 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
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
COMPILER USED TO PROGRAM
 MPLAB C-18
 Mikro-C

Very minor
difference in
syntax!!!
REGISTER ADDRESSING SYNTAX
• How to move data in any particular register of PIC???

MPLAB C-18 Mikro - C

Syntax: REGNAME = data; Same as MPLAB

e.g. TRISA = 0b10001011;


PORTC = 0xff;
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.
 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;
 State of pins
 Analog  All pins multiplexed with ADC’s are by default Analog inputs.
 Digital  Rest all pins are by default digital inputs.

 PIC I/O registers


1. TRISx
2. PORTx
3. LATx

 sbit and #define directives in MPLAB and MikroC


 #pragma directives in MPLAB
 BOR, WDT etc
 I/O ports codes All were
explained
on board

Potrebbero piacerti anche