Professional Documents
Culture Documents
AMC-Unit-I Notes
AMC-Unit-I Notes
With the help of built in serial peripheral interface the number of I/O ports can be expanded.
EPROM/DIP/ROM options are provided.
High performance RISC CPU
Operating speed: DC – 20 MHz clock input, DC – 200 ns instruction cycle
Eight level deep hardware stack
Direct, indirect and relative addressing modes
Power-up Timer (PWRT) and Oscillator Start-up Timer (OST)
Three Timers Timer0,Timer 1 and Timer 2.
Watchdog Timer (WDT) with its own on-chip RC oscillator for reliable operation
Programmable code-protection
Power saving SLEEP mode
10-bit multi-channel Analog-to-Digital converter
Selectable oscillator options
One USART /SCI port with 9-bit address detection.
Low-power, high-speed CMOS EPROM/ROM technology
Fully static design
Wide operating voltage range: 2.5V to 6.0V
Commercial, Industrial and Extended temperature ranges
Low-power consumption: <2mA @5V, 4MHz, 15 µA typical @ 3V, 32 kHz, <1 µA typical standby
current
4. What are PIC microcontrollers? Discuss the difference between PIC and 8051 microcontroller.
The PIC 16F8XX Microcontrollers are basically RISC microcontrollers with very small instruction set of only
35 instructions and a two-stage pipeline concept fetch and execution of instructions. As a result, all
instructions execute in a single cycle except for program branches.
It has two types of internal memories .One is program memory and the other is data memory. Program memory
is provided by 8K words (or 8K*14 bits) of FLASH Memory, and data memory has two sources. One type of
data memory is a 368-byte RAM (random access memory) and the other is256-byte EEPROM (Electrically erasable
programmable ROM). Power consumption is less than 2 mA in 5V operating condition.
Low-end Architectures
Microchip PIC microcontrollers are available in various types. When PIC − MicroCU first became available from
General Instruments in early 1980’s, the microcontroller consisted of a very simple processor executing 12-bit wide
instructions with basic I/O functions and limited program memory. These devices are known as low-end
architectures.
Example: PIC 12C5XX, PIC 16C5XX, PIC 16C505
Mid-range Architectures
Mid-range Architectures are built by upgrading low-end architecture with more number of peripherals, more
numbers of register and more data memory. Some of the mid-range devices are PIC 16C6X PIC16C7X,
PIC16F87X. C and F indicates the types of program memory.
Type C = EPROM F = Flash and RC = Mask ROM
8051 is a 8 bit microcontroller by Motorola. It contains 128 byte of RAM, 4KB of ROM, four I/O ports and two timers.
PIC refers to Peripheral Interface Control. PIC is a Harvard architecture microcontroller 8 bit and 16 bit by Microchip
Technology. It is based on RISC, 32 KB of ROM , five I/O ports and four timers.
5. Explain the difference between Harvard and Princeton architecture.
Harvard Architecture
The high performance of the PIC16CXX family can be attributed to a number of architectural features
commonly found in RISC microprocessors. To begin with, the PIC 16CXX 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 program and data may be fetched from the same
memory using the same bus.As the PIC 16c6x/7x family of micro-controllers uses Harvard Architecture it
enables the devices exceptionally fast execution speed for a given clock rate. In the Harvard Architecture
separate buses are used for Data and Instruction as shown in the diagram.
Instructions are fetched from program memory using buses that are distinct from the buses used for accessing
variables in data memory, I/O ports etc. Every instruction is coded as a single 14-bit word and fetched over a
14-bit wide bus Separating program and data buses further allows instructions to be sized differently than 8-
bit wide data words. Instruction op-codes 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
Point of
Harvard Architecture Von Neumann Architecture
Comparison
In Von-Neumann architecture, there is no
In Harvard architecture, the CPU is connected
separate data and program memory. Instead, a
Arrangement with both the data memory (RAM) and program
single memory connection is given to the
memory (ROM), separately.
CPU.
It requires more hardware since it will be In contrast to the Harvard architecture, this
Hardware
requiring separate data and address bus for each requires less hardware since only a common
requirements
memory. memory needs to be reached.
Space Von-Neumann Architecture requires less
This requires more space.
requirements space.
Speed of execution is slower since it cannot
Speed of Speed of execution is faster because the processor
fetch the data and instructions at the same
execution fetches data and instructions simultaneously .
time.
It results in wastage of space since if the space is
Space is not wasted because the space of the
left in the data memory then the instructions
Space usage data memory can be utilized by the
memory cannot use the space of the data memory
instructions memory and vice-versa.
and vice-versa.
Controlling becomes complex since data and Controlling becomes simpler since either data
Controlling
instructions are to be fetched simultaneously. or instructions are to be fetched at a time.
6. Write down various CPU registers of PIC microcontroller andexplain them.
CPU REGISTERS
The CPU registers are used in the execution of the instruction of the PIC microcontroller. The PIC PIC16F877 Microcontroller
has the following registers.
1. Working Register-W (Similar to Accumulator)
2. Status Register
3. FSR – File Select Register (Indirect Data memory address pointer)
4. INDF
5. Program Counter
1. Working Register:
Working Register is used by many instructions as the source of an operand. It also serves as the destination for the result of
instruction execution and it is similar to accumulator in other cs and ps.
2.Status Register:
This is an 8-bit register which denotes the status of ALU after any arithmetic operation and also RESET status and the bank
select bits for the data memory.
PCLATH (program counter Latch can be read or from or written to without affecting the Program Counter(PC).The upper 3 bits
of PCLATH remain zero.It is only when PCL is written to that PCLATH is automatically written into the PC at the same time.
7. Explain the structure of program memory in PIC microcontroller.
Program Memory:
A memory that contains the program , after the user write it. Program Counter executes commands stored in the program
memory, one after the other.
PIC16F87XA devices have a 13-bit program counter capable of addressing an 8K word x 14 bit program memory space. This
memory is used to store the program after we burn it to the microcontroller.
Program Counter (PC) keeps track of the program execution by holding the address of the current instruction. It is
automatically incremented to the next instruction during the current instruction execution.
PIC16F87XA family has a 13-bit wide hardware stack. The stack space is not part of either program or data space and the
stack pointer is not readable or writable. In the PIC microcontrollers, this is a special block of RAM memory used only for
this purpose.
The CALL instruction is used to jump to a subroutine, which must be terminated with the RETURN instruction. CALL has
the address of the first instruction in the subroutine as its operand. When the CALL instruction is executed, the destination
address is
copied to the PC. The PC is PUSHed onto the stack when a CALL instruction is executed, or an interrupt causes a branch.
The stack is POP‘ed in the event of a RETURN, RETLW or a RETFIE instruction execution.
The stack operates as a circular buffer. This means that after the stack has been PUSHed eight times, the ninth push
overwrites the value that was stored from the first push. The tenth push overwrites the second push (and so on).
Each time the main program execution starts at address 0000 - Reset Vector. The address 0004 is reserved‖ for the interrupt
service routine‖ (ISR). Program Memory is divided into pages, where the program is stored. Data Memory is divided into
banks. The banks are located inside the RAM, where the special registers and the data located
8. Explain the status Register of 16C61/71 microcontroller.
Status Register:
This is an 8-bit register which denotes the status of ALU after any arithmetic operation and also RESET status and the bank select bits
for the data memory.
C : Carry/borrow bit
DC : Digit carry/borrow bit
Z : Zero bit
NOT_PD : Reset Status bit (Power-down mode bit)
NOT_TO : Reset Status bit (tme- out bit)
RPO : Register bank Select
The bits 7 and 6 of Status Register are unused by 16c6x/7x. The ‗C‘ bit is set when two 8-bit operands are added together and a 9-bit
result occurs. This 9-bit is placed in the carry bit.The DC or Digit carry bit indicates that a carry from the lower 4 bits occurred
during an 8-bit addition.
The reset status bits NOT_TO and NOT_PD are used in conjunction with PIC‘s sleep mode. The micro controller can put itself to sleep
mode to save power during intervals when it has nothing to do. It can be reset by any of three kinds. Upon reset the
CPU can check these two reset status bits to determine which kind of event resettled it and then respond accordingly.
The Register bank select bit RPO is used to select either bank or bank.When RPO=0, select Bank 0, RPO=1, select Bank 1.
Example: bcf STATUS, RPO ; Select bank 0
bsf STATUS, RPO ; Select bank 1.
Such examples include sending a set of data via serial communication, working with buffers and indicators (which will be
discussed further in a chapter with examples), or erasing a part of RAM memory (16 locations) as in the following instance.
Reading data from INDF register when the contents of FSR register is equal to zero returns the value of zero, and writing to it
results in NOP operation (no operation).
(vi)Rotate Instructions
RLF ; Rotate Left f through carry
RRF ; Rotate Right f through carry
(vii). Branch Instructions : There are two types of Branch instructions.(i)Conditional Branch and (ii) Un conditional Branch
instructions.
The low byte comes from the PCL register, which is readable and writable register. The upper bits are not readable but are
indirectly writable through PCLATH register. On any reset, the upper bits of the PC will be cleared.
ii) Stack pointer(SP – 13 bit):
The Stack Pointer is not part of either program or data space. The Program counter is pushed on to the stack when a CALL
instruction is executed or an interrupt or branch instruction to store the return address. The stack is Popped in the event of return
instruction execution (retrieving return address from stack).
Block diagram of PIC 16C67 Microcontroller
Block diagram of PIC 16C77 Microcontroller
Execution:
iii) Arithmetic & logic Unit (ALU): (8-bit)
The ALU is a general purpose arithmetic unit. It performs arithmetic and boolean operation between the data in the working
register and any register file. The ALU is 8 bits wide and capable of addition, subtraction, shift and logical operations.
In two operand instructions, typically one operand is the working register (W register) the other operand is a file register or an
immediate constant. In a single operand instructions, the operand is either the W register or a file register.
BIT 7: IRP: Register Bank Select bit (used for indirect addressing)
0 = Bank 0, 1 (00h - FFh)
1 = Bank 2, 3 (100h - 1FFh)
The IRP bit is not used by the PIC16F8X. IRP should be maintained clear.
BIT 6-5: RP1:RP0: Register Bank Select bits (used for direct addressing)
00 = Bank 0 (00h - 7Fh)
01 = Bank 1 (80h - FFh)
10 = Bank 2 (100h - 17Fh)
11 = Bank 3 (180h - 1FFh)
BIT 4: NOT_TO: Time-out bit
1 = After power-up, CLRWDT instruction, or SLEEP instruction
0 = A WDT time-out occurred
BIT 3: NOT_PD: Power-down bit
1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction
BIT 2: Z: Zero bit
1 = The result of an arithmetic or logic operation is zero
0 = The result of an arithmetic or logic operation is not zero
BIT 1: DC: Digit carry/borrow
1 = A carry-out from the 4th low order bit of the result occurred
0 = No carry-out from the 4th low order bit of the result bit
BIT 0: C: Carry/borrow
1 = A carry-out from the most significant bit of the result occurred
0 = No carry-out from the most significant bit of the result occurred