PIC18FXXX Architecture- MCU

PIC18Fxxxx Architecture


pic18 architecture

Arithmetic Logic Unit

  •  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

alu unit

PIC Status Register

Structure

BitD7D6D5D4D3D2D1D0
Field---NOVZDCC

Explanation of Flag bits

  •  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 a carry 

BitDescription
7-6-5Reserved
4N: Negative Flag bit
  • 1 = Indicates result of Signed Arithmetic Operation generated Negative result (Sign bit of result=1)
  • 0 =  Indicates result of Signed Arithmetic Operation generated Positive result (Sign bit of result=0)
3OV: Overflow flag bit
  • 1 = Indicates result of Signed Arithmetic operation generated carry from D6 to D7 bit
  • 0 = Indicates result of Signed Arithmetic operation not generated carry from D6 to D7 bit
2Z: Zero flag bit
  • 1 = Indicates result of Signed or Unsigned Arithmetic operation is ZERO
  • 0 = Indicates result of Signed or Unsigned Arithmetic operation is NON-ZERO
1DC: Digital Carry bit
  • 1 = Indicates result of Unsigned Arithmetic operation generated carry from D3 to D4 bit i.e. Lower nibble to Higher nibble
  • 0 = No carry from Lower nibble to Higher nibble
0C: Carry bit
  • 1 = Indicates result of Unsigned Arithmetic operation generated carry from D7 bit i.e. Carry out of MSB
  • 0 = Indicates result of Unsigned Arithmetic operation generated NO carry from D7 bit i.e. No carry

 Internal Registers of PIC18 Microcontroller

WREG (W)
  • Working Register , same as that of Accumulator in 8051
  • Size - 8 bits
  • Function - Used to store Result of Arithmetic and Logical operations performed by CPU
Program Counter (PC)
  • Size- 21-bit register
  • function- Used as a pointer to program memory during program execution  or Stores  the address of next instruction to be executed 
Table Pointer
  • Size- 21-bit register
  • Function - used as a memory pointer to copy bytes between program memory and data registers
Stack Pointer (SP)
  • Size- 5-bit register
  • used to point to the Stack memory Locations (32 entries can be stored on stack)
Stack
  • 31 registers used for temporary storage of memory addresses during execution of a program  
BSR:  Bank Select Register  (0 to F)
  • 4-bit Register
  • Function - used to select perticular Memory Bank of data memory (16 Memory Banks i.e. BANK0 to Bank15)
FSR:  File Select Registers
  • FSR0, FSR1, and FSR2
  • FSR: composed of two 8-bit registers
  • FSRH and FSRL
  • Used as pointers for FILE registers OR Register files
  • Holds 12-bit address of data register 
Special Function Registers

SFRs:   

Data registers associated with I/O ports, support devices, and processes of data transfer

  •  I/O Ports (A to E)
  • Interrupts
  • EEPROM
  • Serial I/O
  • Timers
  • Capture/Compare/PWM (CCP)
  • Analog-to-Digital (A/D) Converter 

SRF in pic18

MPU and Memory

memory protection unit and memory

PIC18F Programming Model

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

pic 18 programming model

References

  • Created, Edited, and Notes by Prof. Sujit Wagh, SKNCOE, Pune
  • WikiNote Foundation

Last modified: Tuesday, 17 September 2019, 12:26 PM