PIC Microcontroller
PIC Microcontroller
CPU
Allows for different bus
16-bit Bus
widths
Program 3
Memory
Comparison of PIC Family
PIC
Family
Pins Flash/ Timers I/O pins/ Additional Features
RAM ADC
Memory channels
range
PIC 6 896 B/ 64B 8 bit(2), PWM 4/ 2ch. ---
10CXX (2) 8bit
5
Selection Criteria for PIC Microcontroller
1) Speed
2) Amount of RAM/ ROM
3) Number of I/O pins, Timers
4) Power consumption
5) Availability of tools
6) Added features like ADC/ DAC/ CCP, Bus support like
CAN, SPI, I2C, USB.
7) Watchdog timer, Timer modes, Data EEPROM etc.
6
PIC 18F458
High-Performance, Enhanced
Flash Microcontrollers with
CAN
7
Features of IC 18F452/458
It uses 16-bit wide instructions, 8-bit wide data path.
Program memory 2MBytes ROM [21 Address line]
4KBytes of Data RAM [12 Address lines]
32 KB flash ROM
256 bytes – Data EEPROM – for storing critical information
10 bit, 8 channel ADC
5 ports A[6], B,C,D[8], E[3] =33 IO lines
Capture/ Compare/ Pulse width modulation module.
8
Features of PIC 18F458
High-Performance RISC CPU:
9
PIC 18F452 General Architecture
10
Review: MPU and Memory
11
PIC18F Programming Model
The representation of the internal
architecture of a microprocessor, necessary
to write assembly language programs
Divided into two groups
Arithmetic Logic Unit (ALU) and Registers
From Microprocessor Unit (MPU)
Special Function Registers (SFRs)
From Data (File) Memory
12
PIC18F Programming Model
14
Arithmetic Logic Unit (ALU)
Instruction Decoder
16-bit Instructions
STATUS: Flag Register
5 individual bits called flags
WREG (W): Working Register
8-bit Accumulator
Product
16-bit Product of 8-bit by 8-bit Multiply
Arithmetic Logic Unit
Example
ADDWF F, d, a ;Add WREG to File (Data) Reg.
; S a v e r e s u l t i n W.E.,Piufnde. =0
Pro f . M . N . K a ka tk a r, S .C .O 16
;Save result in F if d = 1
Flags in Status Register
N (Negative Flag)
Set when bit B7 is one as the result of an arithmetic/logic operation
OV (Overflow Flag)
Set when result of an operation of signed numbers goes beyond 7-
bits
Z (Zero Flag)
Set when result of an operation is zero
DC (Digit Carry Flag) (Half Carry)
Set when carry generated from Bit3
to Bit4 in an arithmetic operation
C (Carry Flag)
Set when an addition generates carry
Registers
Program Counter (PC)
21-bit register functions as a pointer to program
memory during program execution
Table Pointer
21-bit register used as a memory pointer to copy
bytes between program memory and data registers
Stack Pointer (SP)
5-bit register used to point to the stack
Stack
31 registers used for temporary storage of memory