Design of the PIC16x8x
PIC16CXX uses a Harvard architecture, with separate data and program storage. This allows faster access, as well as program and data to have different word width. Opcodes are 14 bits wide, versus data, which is 8-bit. The figure below is PIC16x8X block diagram showing ALU (Arithmetic Logic Unit) which is a general purpose arithmetic unit, memory, timers, oscillator in/out, master clear, 5-bit PORTA, 8-bit PORTB, voltages. Note the separate data, program, direct, indirect, and RAM address buses. Note also the 8-level 13-bit stack, the RAM file registers, and FSR register.
The ALU is a general purpose arithmetic unit. It performs arithmetic and Boolean functions between data in the working register and any register file. The ALU is 8-bits wide and capable of addition, subtraction, shift and logical operations. Unless otherwise mentioned, arithmetic operations are two’s complement in nature. In two-operand instructions, typically one operand is the working register (W register), and the other operand is a file register or an immediate constant. In single operand instructions, the operand is either the W register or a file register.
The W register is an 8-bit working register used for ALU operations. It is not an addressable register. Depending on the instruction executed, the ALU may affect the values of the Carry (C), Digit Carry (DC), and Zero (Z) bits in the STATUS register. The C and DC bits operate as a borrow and digit borrow out bit, respectively, in subtraction.
PIC 16x8x Block Diagram
The PIC16XXX devices have only 35 instructions, whereas the PIC17XXX devices have only 58 instructions. There is a substantial amount of program code compatibility amongst different devices in the PIC family. A program written for one PIC device can easily be assembled and used in another device type with a minimum number of modifications.
Instruction Pipeline Flow
The PIC family are fully static devices, meaning that they preserve the contents of their registers when the clock frequency is reduced to zero. In PIC microcontrollers, each instruction takes four clock periods to execute.
Instructions are pipelined in a way where one instruction is executing, another is being fetched from memory so that the instruction fetch/execution cycle takes only one clock cycle.
If a 1MHz clock frequency is used, the corresponding clock period is 1µsec, so each instruction will take 4µsec this time is called the instruction cycle time ti. The fastest devices in the PIC family can operate at clock frequencies up to 33MHz, with corresponding instruction cycle times of 121nsec. Most instructions execute in one instruction cycle, but some require two cycles because they need to branch to some destination other than the next address in the PC. Instructions that need two cycles to execute are btfsc, btfss, call, decfsz, goto, incfsz, retfie, retlw and return.
Microchip characterises PIC microcontrollers according to their instruction word lengths. The low-end PICs, such as the eight pin 12C5XX series, have 12 bit word length instructions. The midrange PICs, such as the PIC16XXX, have 14 bit instructions and the high-end 17XXX PICs have 16 bit instructions. All PIC microcontrollers are, however, classified as eight bit microcontrollers as they all manipulate data in byte units on an eight bit wide data bus. A detailed knowledge or understanding of these concepts is not essential to actually use PIC microcontrollers; all that is needed is practice in writing programs and some experimentation with microcontroller circuits to gain experience.
PIC 16F84 Pin Diagram.