EE6008 Unit 1
EE6008 Unit 1
EE6008 Unit 1
net
www.AUNewsBlog.net
www.AUNewsBlog.net
www.AUNewsBlog.net
www.AUNewsBlog.net
11. What are the types of instruction set used in PIC microcontroller?
There are three types of instruction set used in PIC microcontroller.
1. Bit oriented instruction 2. Byte oriented instruction 3. Literal instructions.
12. What is bit and byte oriented instruction?
The byte oriented instructions that require two parameters (For example, movf f, F(W)) expect the f to be
replaced by the name of a special purpose register (e.g., PORTA) or the name of a RAM variable (e.g., NUM1),
which serves as the source of the operand. 'f' stands for file register. The F(W) parameter is the destination of the
result of the operation. It should be replaced by:F, if the destination is to be the source register.
W, if the destination is to be the working register (i.e., Accumulator or W register).
The bit oriented instructions also expect parameters (e.g., btfsc f, b). Here 'f' is to be replaced by the name of a
special purpose register or the name of a RAM variable. The 'b' parameter is to be replaced by a bit number
ranging from 0 to 7.
For example:
Z equ 2
btfsc STATUS, Z
Z has been equated to 2. Here, the instruction will test the Z bit of the STATUS register and will skip the next
instruction if Z bit is clear.
PART-B
1. Explain with neat diagram the architecture of PIC16C6x and PIC16C7x microcontroller. (Nov/Dec 2016)
ARCHITECTURAL OVERVIEW
www.AUNewsBlog.net
www.AUNewsBlog.net
The high performance of the PIC16CXX family can be attributed to a number of architectural features com-monly found
in RISC microprocessors. To begin with, the PIC16CXX uses a Harvard architecture, in which, program and data are
accessed from separate memories using separate buses. This improves bandwidth over traditional von Neumann
architecture where pro-gram and data may be fetched from the same memory using the same bus. Separating program
and data bus-ses further allows instructions to be sized differently than 8-bit wide data words. Instruction opcodes are
14-bits wide making it possible to have all single word instructions. A 14-bit wide program memory access bus fetches
a 14-bit instruction in a single cycle. A two-stage pipeline overlaps fetch and execution of instruc-tions (Example 3-1).
Consequently, all instructions exe-cute in a single cycle (200 ns @ 20 MHz) except for program branches.
The PIC16C61 addresses 1K x 14 of program memory. The PIC16C62/62A/R62/64/64A/R64 address 2K x 14 of
program memory, and the PIC16C63/R63/65/65A/R65 devices address 4K x 14 of program memory. The PIC16C66/67
address 8K x 14 program memory. All program memory is internal.
The PIC16CXX can directly or indirectly address its register files or data memory. All special function reg-isters
including the program counter are mapped in the data memory. The PIC16CXX has an orthogonal (symmetrical)
instruction set that makes it possible to carry out any operation on any register using any addressing mode. This
symmetrical nature and lack of “special optimal situations” makes programming with the PIC16CXX simple yet efficient,
thus significantly reducing the learning curve.
The PIC16CXX device contains an 8-bit ALU and work-ing register (W). The ALU is a general purpose arithme-tic 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, sub-traction, shift, and logical operations. Unless otherwise mentioned,
arithmetic operations are two's comple-ment in nature. In two-operand instructions, typically one operand is the working
register (W register), the other operand is a file register or an immediate con-stant. 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 upon the instruction executed, the ALU may affect the values of the Carry (C), Digit Carry (DC), and Zero
(Z) bits in the STATUS register. Bits C and DC operate as a borrow and digit borrow out bit, respec-tively, in subtraction.
See the SUBLW and SUBWF instructions for examples.
www.AUNewsBlog.net
www.AUNewsBlog.net
2. Explain with neat diagram the block diagram of PIC16C6x and PIC16C7x microcontroller
www.AUNewsBlog.net
www.AUNewsBlog.net
3. With a neat diagram discuss in detail about memory organization of a PIC microcontroller.
www.AUNewsBlog.net
www.AUNewsBlog.net
4. Explain in detail the register file structure and addressing modes of PIC microcontroller.
REGISTER FILE STRUCTURE
In PIC Microcontrollers the Register File consists of two parts namely
a) General Purpose Register File
b) Special Purpose Register File
a) General Purpose Register File:
The general purpose register file is another name for the microcontroller’s RAM . Data can be written to each 8-bit
location updated and retrieved any number of times.
b) Special Purpose Register File:
The special function register file consists of input, output ports and control registers used to configure each 8-bit port
either as input or output. It contains registers that provide the data input and data output to a chip resources like Timers,
Serial Ports and Analog to Digital converter and also the registers that contains control bits for selecting the mode of
operation and also enabling or disabling its operation.
ADDRESSING MODES.
The PIC microcontrollers support only TWO addressing modes .They are
(i) Direct Addressing Mode
(ii) Indirect Addressing mode
Direct Addressing Mode :
In direct addressing mode 7 bits (0-6) of the instruction identify the register file address and the 8 th bit of the
register file address register bank select bit(RP0).
www.AUNewsBlog.net
www.AUNewsBlog.net
The above diagram explains the method of accessing register file address 13H by direct addressing method.
Indirect Addressing Mode
In the indirect addressing mode the 8-bit register file address is first written into a Special Function Register(SFR)
which acts as a pointer to any address location in the register file.A subsequent direct access of INDF will actually
access the register file using the content of FSR as a pointer to the desired location of the operand.
• Byte-oriented operations
• Bit-oriented operations
All instructions are executed within one single instruction cycle, unless a conditional test is true or the pro-gram counter
is changed as a result of an instruction. In this case, the execution takes two instruction cycles with the second cycle
executed as a NOP. One instruc-tion cycle consists of four oscillator periods. Thus, for an oscillator frequency of 4
MHz, the normal instruction execution time is 1 μs. If a conditional test is true or the program counter is changed as a
result of an instruc-tion, the instruction execution time is 2 μs.
: GENERAL FORMAT FOR INSTRUCTIONS
13 8 7 6 0
OPCO f (FILE
DE d #)
d = 0 for
destination W
d = 1 for
destination f
= 7-bit file register
f address
Bit-oriented file register operations
13 10 9 7 6 0
OPCO b (BIT f (FILE
DE #) #)
www.AUNewsBlog.net
www.AUNewsBlog.net
b = 3-bit
= 8-bit immediate
k value
CALL and GOTO
instructions only
1 1
13 1 0 0
OPCOD
E k (literal)
= 11-bit
k immediate value
www.AUNewsBlog.net
www.AUNewsBlog.net
C,DC,
ADDLW k Add literal and W 1 11 111x kkkk kkkk Z
ANDLW k AND literal with W 1 11 1001 kkkk kkkk Z
CALL k Call subroutine 2 10 0kkk kkkk kkkk
CLRWD 010 T P
T - Clear Watchdog Timer 1 00 0000 0110 0 O ,D
GOTO k Go to address 2 10 1kkk kkkk kkkk
IORLW k Inclusive OR literal with W 1 11 1000 kkkk kkkk Z
MOVLW k Move literal to W 1 11 00xx kkkk kkkk
100
RETFIE - Return from interrupt 2 00 0000 0000 1
RETLW k Return with literal in W 2 11 01xx kkkk kkkk
RETUR 100
N - Return from Subroutine 2 00 0000 0000 0
001 T P
SLEEP - Go into standby mode 1 00 0000 0110 1 O ,D
C,DC,
SUBLW k Subtract W from literal 1 11 110x kkkk kkkk Z
XORLW k Exclusive OR literal with W 1 11 1010 kkkk kkkk Z
Note 1: When an I/O register is modified as a function of itself ( e.g., MOVF PORTB, 1), the value used will be that
value present on the pins themselves. For example, if the data latch is '1' for a pin configured as input and is
driven low by an external device, the data will be written back with a '0'.
2: If this instruction is executed on the TMR0 register (and, where applicable, d = 1), the prescaler will be cleared
if assigned to the Timer0 Module.
3: If Program Counter (PC) is modified or a conditional test is true, the instruction requires two cycles. The
second cycle is executed as a NOP.
An “Instruction Cycle” consists of four Q cycles (Q1, Q2, Q3, and Q4). The instruction fetch and execute are pipelined
such that fetch takes one instruction cycle while decode and execute takes another instruction cycle. However, due to
www.AUNewsBlog.net
www.AUNewsBlog.net
the pipelining, each instruction effectively executes in one cycle. If an instruction causes the program counter to change
(e.g. GOTO) then two cycles are required to complete the instruction (Example 3-1).
A fetch cycle begins with the program counter (PC) incrementing in Q1.
In the execution cycle, the fetched instruction is latched into the “Instruction Register (IR)” in cycle Q1. This instruction
is then decoded and executed during the Q2, Q3, and Q4 cycles. Data memory is read during Q2 (operand read) and
written during Q4 (destination write).
CLOCK/INSTRUCTION CYCLE
Instruction Flow/Pipelining
An “Instruction Cycle” consists of four Q cycles (Q1, Q2, Q3, and Q4). The instruction fetch and execute are pipelined
such that fetch takes one instruction cycle while decode and execute takes another instruction cycle. However, due to
the pipelining, each instruction effectively executes in one cycle. If an instruction causes the program counter to change
(e.g. GOTO) then two cycles are required to complete the instruction (Example 3-1).
A fetch cycle begins with the program counter (PC) incrementing in Q1.
In the execution cycle, the fetched instruction is latched into the “Instruction Register (IR)” in cycle Q1. This instruction
is then decoded and executed during the Q2, Q3, and Q4 cycles. Data memory is read during Q2 (operand read) and
written during Q4 (destination write).
CLOCK/INSTRUCTION CYCLE
Q Q Q Q
1 2 Q3 Q4 1 Q2 Q3 Q4 Q1 2 Q3 Q4
OSC1
Q1
Q2 Internal
Q3 Phase
Clock
Q4
P
PC C PC+1 PC+2
(Program
counter)
OSC2/CLKOU
T
(RC mode)
Fetch
INST (PC)
Execute Fetch INST
INST (PC-1) (PC+1)
Execute Fetch INST
INST (PC) (PC+2)
www.AUNewsBlog.net
www.AUNewsBlog.net
Execute INST
(PC+1)
INSTRUCTION PIPELINE
FLOW
Tcy0 Tcy1 Tcy2 Tcy3 Tcy4 Tcy5
MOV
1. LW 55h Fetch 1 Execute 1
CAL SUB
3. L _1 Fetch 3 Execute 3
All instructions are single cycle, except for any program branches. These take two cycles
since the fetch
instruction is “flushed” from the pipeline while the new instruction is being fetched and then
executed.
www.AUNewsBlog.net