0% found this document useful (0 votes)
73 views

New Chapter 2 Micro Architecture

Here are the steps: 1) 38H in binary is 0011 1000 2) 2FH in binary is 0010 1111 3) Adding the two binary numbers gives 0100 1101 4) This result is 41H in hexadecimal 5) There is no carry out of the most significant bit, so the C flag is 0 6) There is a carry out of the 4th bit, so the DC flag is 1 7) The result is not zero, so the Z flag is 0 Therefore, the status of the flags after the ADDLW instruction is: C flag = 0 DC flag = 1 Z flag = 0

Uploaded by

Amzar Shukri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

New Chapter 2 Micro Architecture

Here are the steps: 1) 38H in binary is 0011 1000 2) 2FH in binary is 0010 1111 3) Adding the two binary numbers gives 0100 1101 4) This result is 41H in hexadecimal 5) There is no carry out of the most significant bit, so the C flag is 0 6) There is a carry out of the 4th bit, so the DC flag is 1 7) The result is not zero, so the Z flag is 0 Therefore, the status of the flags after the ADDLW instruction is: C flag = 0 DC flag = 1 Z flag = 0

Uploaded by

Amzar Shukri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

DJM 50122

EMBEDDED SYSTEM APPLICATION

CHAPTER 2
MICROCONTROLLER
ARCHITECTURE

PENSYARAH:

NORHANIZA AZREEN BT MOHAMED MOKHTAR


PIC MICROCONTROLLER ???

• PIC stands for Peripheral Interface Controller


• It is the brain child of Microchip Technology,USA.
• A microcontroller is a compact microcomputer
designed to govern the operation of embedded
systems in motor vehicles, robots, office machines,
medical devices, mobile radios, vending machines,
home appliances, and various other devices
• A typical microcontroller includes a processor,
memory, and peripherals.
• One of the earlier versions of PIC Microcontrollers is
PIC16C6x/7x. The 7x family has an enhancement of
Analog to Digital converter capability.
• These are available in 28 pin DIP, 40 pin DIP ,44 pin
surface mount package…etc..some of PIC controllers
contain the letter A in their number. The presence of A
indicates the brown-out reset feature, which causes a
reset of the PIC when the Power Supply voltage drops
below 4.0v.
• The PIC16F8XX 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.
• There are four devices in 16F8xx family, PIC16F873,
PIC16F874, PIC16F876 and PIC16F877.
PIC Microcontrollers from Microchip Company are divided into 4
large families

• First family:
PIC10 (10FXXX) called Low End
• Second family:
PIC12 (PIC12FXXX) called Mid-Range
• Third family:
PIC16 (16FXXX)
• Fourth family:
PIC 17/18 (18FXXX)

Each family has a variety of components along with built in


special features. It offers a lot of memory sizes and pin packages
and different clock ratings.
PIC 16 ARCHITECTURE’S BLOCK DIAGRAM
PIC 16F877
• PIC 16F877 is a 40-pin 8-Bit CMOS FLASH
Microcontroller .
• The core architecture is high- performance RISC CPU .
Since it follows the RISC architecture, all single cycle
instructions take only one instruction cycle except for
program branches which take two cycles.
• 16F877comes with 3 operating speeds with 4, 8, or 20
MHz clock input. Since each instruction four operating
clock cycles, each instruction takes 0.2 μs when 20MHz
oscillator is used.
PIC16F877
SALIENT FEATURES

• Speed :
When operated at its maximum clock rate a PIC executes most of its
instructions in 0.2 µs or five instructions per microsecond.
• Instruction set Simplicity :
The instruction set is so simple that it consists of only just 35 instructions
• Integration of operational features:
Power-on-reset (POR) and brown-out protection ensure that the chip
operates only when the supply voltage is within specifications. A watch
dog timer resets the PIC if the chip malfunctions or deviates from its
normal operation at any time.
• Programmable timer options:
Three timers can characterize inputs, control outputs and provide
internal timing for the program execution.
• Interrupt control:
Up to 12 independent interrupt sources can control then the CPU deal
with each sources.

• Powerful output pin control:


A single instruction can select and drive a single output pin high or low in
its 0.2µs instruction execution time. The PIC can drive a load of up to 25µA.

• I/O port expansion:


With the help of built in serial peripheral interface the number of I/O ports
can be expanded. EPROM/DIP/ROM options are provided.
• Operating speed: DC – 20 MHz clock • 10-bit multi-channel Analog-to-
input DC – 200 ns instruction cycle Digital converter
• Eight level deep hardware stack • Selectable oscillator options
• Direct, indirect and relative
addressing modes • One USART /SCI port with 9-bit
address detection.
• Power-up Timer (PWRT) and
Oscillator Start-up Timer (OST) • Low-power, high-speed CMOS
• Three Timers Timer0,Timer 1 and EPROM/ROM technology
Timer 2.
• Fully static design
• Watchdog Timer (WDT) with its own
on-chip RC oscillator for reliable • Wide operating voltage range: 2.5V
operation to 6.0
• Programmable code-protection • Commercial, Industrial and
• Power saving SLEEP mode Extended temperature ranges
• Low-power consumption: <2mA
@5V, 4MHz, 15µA typical @ 3V, 32
kHz, <1 Atypical standby current
PIC MICROCONTROLLER’S CPU

• Arithmetic logic unit (ALU)- arithmetic operations


and for logical decisions.
• Memory unit (MU)- for storing the instructions after
processing.
• Control unit (CU)- used to control the internal and
external peripherals which are connected to the CPU
• Accumulator - used for storing the results.
DATA RAM FILE REGISTER
• WREG register
- Registers are used to store information temporarily..
- WREG stand for working register . The WREG register is the
same as the accumulator in other microprocessor.
- WREG registers are used to store information temporarily.
- The data memory space in PIC is a read/write (static RAM)
memory
- the WREG register is used for ALU operation .

D7 D6 D5 D4 D3 D2 D1 D0
MSB LSB
• EXAMPLE : MOVLW Instruction
MOVLW 25H;
In the instruction, MOVLW , the letter L ( Literal ) comes first and then the
letter W ( WREG ), which means “move a literal value to WREG” to the
destination. Which is load the 25H of literal value to WREG register.
MOVLW 25H; move value 25H into WREG

What the solution!!

MOVLW 25H;
ADDLW 34H;
WHAT DO YOU UNDERSTAND?
• File register
- The file register is read/write memory used by the CPU for data
storage, scratch pad, and registers for internal use and functions.
- The memory of the PIC is divided into a series of registers. Each of
the registers has its own address and memory locations.
- These addresses are normally denoted by using hexadecimal
numbers.
- According to the type of working and usage, the registers in PIC
are classified into two categories.
1. Special Function Registers (SFR)
2. General-Purpose Registers (GPR) or General Purpose RAM
(GP RAM)
1.Special function register (SFRs)

- Special function registers are also memory registers which is


used for special dedicated functions.
- Each special function inside this PIC chip is controlled by using
these registers
- The PIC SFRs are 8 bit registers. The number of locations in the
file register set aside for SFR depends on the pin numbers and
peripheral functions supported by that chip.
2. The general purpose registers (GPR )
- are a group of RAM locations in the file register that are used for
data storage and scratch pad.
- Each location is 8 bits wide and can be used to store any data we
want as long as it is 8 bit.
- In the PIC micro-controllers, the space that is not allocated to the
special function registers is used for general purpose registers.
- That means in a PIC chip with a thousand-byte file register, no
more than 100 bytes are used for special function registers are the
rest are used for general purpose registers. A larger GPR size
means more difficulties in managing these registers if you use
assembly language programming.
• Status register
- Status register is an eight bit register that contains the arithmetic
status of the arithmetic logic unit (ALU), the reset status and the
bank select bits for the data memory.
- If the STATUS register is the destination for an instruction that
affects the Z, DC or C bits, then the write to these three bits is
disabled.
- Furthermore, the TO and PD bits are not writable.

For example, CLRF STATUS will clear the upper-three bits and set the
Z bit. This leaves the STATUS register as 000u u1uu (where u =
unchanged).
Bit 7
IRP - Bit selects register bank. It is used for indirect addressing.
1 - Banks 0 and 1 are active (memory locations 00h-FFh)
0 - Banks 2 and 3 are active (memory locations 100h-1FFh)

Bit6 , Bit5
RP1,RP0 - Bits select register bank. They are used for direct
addressing.
Bit4
TO - Time-out bit.
1 - After power-on, after executing the CLRWDT
instruction which resets the watch-dog timer or
the SLEEP instruction which sets the microcontroller
into low-consumption mode.
0 - After watch-dog timer time-out has occurred.

Bit3
PD - Power-down bit.
1 - After power-on or after executing the CLRWDT
instruction which resets the watchdog timer.
0 - After executing the SLEEP instruction which sets the
microcontroller into low-consumption mode.
Bit2
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

Bit1
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

Bit0
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
TRY YOUR BEST!!!!

Show the status of the C , DC and Z flags after the addition of 38H and 2FH in the
following instruction:

MOVLW 38H
ADDLW 2FH ; ADD 2FH TO WREG

UNDERSTAND !!!
bit 7:
bit 3:
IRP: Register Bank Select bit (used for indirect addressing) PD: Power-down bit
0 = Bank 0, 1 (00h - FFh) 1 = After power-up or by the CLRWDT instruction
0 = By execution of the SLEEP instruction
1 = Bank 2, 3 (100h - 1FFh)
The IRP bit is not used by the PIC16F8X. IRP should be maintained clear. bit 2:
Z: Zero bit
1 = The result of an arithmetic or logic operation is zero
bit 6-5: 0 = The result of an arithmetic or logic operation is not zero
RP1:RP0: Register Bank Select bits (used for direct addressing) bit (for ADDWF and ADDLW instructions) (For borrow the polarity is reversed)
00 = Bank 0 (00h - 7Fh)
bit 1:
01 = Bank 1 (80h - FFh) DC: Digit carry/borrow
10 = Bank 2 (100h - 17Fh) 1 = A carry-out from the 4th low order bit of the result occurred
11 = Bank 3 (180h - 1FFh) 0 = No carry-out from the 4th low order bit of the result
bit (for ADDWF and ADDLW instructions)
Each bank is 128 bytes. Only bit RP0 is used by the PIC16F8X. RP1 should be maintained clear.
bit 0:
C: Carry/borrow
bit 4:
1 = A carry-out from the most significant bit of the result occurred
TO: Time-out bit 0 = No carry-out from the most significant bit of the result occurred
1 = After power-up, CLRWDT instruction, or SLEEP instruction Note: For borrow the second operand the polarity is reversed. A subtraction is executed by
0 = A WDT time-out occurred adding the two’s complement of. For rotate (RRF, RLF) instructions, this bit is loaded with either
the high or low order bit of the source register
IQ TEST

• How many pin for PIC 16F877?

• Type of File register ?

You might also like