LEARNING OUTCOMES
Part 1:
⚫Understand the PIC18 Architecture
Part 1 : PIC18 Microcontroller Architecture
At the end of this session you should be able to
explain:
⚫ PIC18 Microcontroller families
⚫ PIC18 architecture
⚫ Data RAM file Register
INTRODUCTION
⚫PICis afamilyof modified Harvard
architecture microcontrollersmade byMicrochip
T
echnology
, derived from the PIC1650originally
developed byGeneral Instrument's
Microelectronics Division.
⚫ The name PIC initially referred to "Peripheral
Interface Controller”
⚫PICs are popular with both industrial
developers and hobbyists alike due to their:
1. low cost,
2. wide availability,
3. large user base,
4. extensive collection of application notes,
5. availability of low cost or free development
tools,
6. serial programming (and re-programming
with flash memory) capability.
PIC Families
PIC18 PIC® Microcontrollers
⚫The PIC18 family use an 8-bit architecture.
⚫ With up to 16 MIPSofprocessingpower,PIC18
Microcontrollers feature advancedperipherals,such asCAN,
USB,Ethernet, LCD and CTMU.
29 March, 2013
9 mfauzi
Basic Upgrade
USB CAN
PIC18 Architecture
⚫PIC microcontrollers are based on advanced RISC
architecture.
⚫RISCstandsfor Reduced Instruction SetComputing. In
this architecture, the instruction set of hardware gets
reduced which increases the execution rate (speed) of
system.
⚫
⚫PIC microcontrollersfollow Harvard architecture for
internal data transfer
RISC vs CISC
⚫Reduced instruction set computing, or RISCis
a CPU design strategy based on the insight that
simplified instructions can provide higher
performance if this simplicity enables much faster
execution of each instruction.
⚫A complex instruction set computer (CISC), is
a computer where single instructions can execute
several low-level operations
PIC18 Architecture (cont’d)
⚫PIC microcontrollersare designed using
the HarvardArchitecture which includes:
⚫Microprocessor unit (MPU)
⚫Program memoryfor instructions
⚫Data memoryfor data
⚫I/O ports
⚫Support devices such astimers
Harvard Architecture vs Von Neumann
Architecture
• Von Neumann
Architecture:
– Used single memory space
for program and data.
– Limits operating bandwidth
• Harvard Architecture:
– Uses two separate memory
spaces for program
instructions and data
– Improved operating
bandwidth
– Allows for different bus
Von Neumann
Architecture
8-bit Bus
CPU
Program
& Data
Memory
CPU
Harvard
Architecture
Data
Memory
Program
Memory
8-bit Bus
16-bit Bus
PIC18 Architecture
PIC18Architecture Block Diagram
PIC18 Features:
⚫CPU core
⚫The function of the CPU is to execute
(process) information stored in memory
.
⚫Program ROM
⚫The ROM use to store program.
PIC18 Features (cont’d)
⦿Data Memory
The data memory is SRAMand EEPROM.
provides aplace to store data asapplication executes
and is lost when power is removed from the system.
⦿EEPROM
also anonvolatile memory which is used to store
data like values of certain variables. PIC18F4550 has
256 Bytesof EEPROM.
PIC18 Features (cont’d)
⚫I/O Ports:
⚫The I/O ports are used to interface the microprocessor
to the outside world.
PIC18F4550 pin diagram.
Other internal Devices
⚫Oscillator
⚫8x8 Multiplier
⚫ADC Interface
⚫Timers/Counter
s
⚫USB
PIC18 Registers
⚫CPUs use many registers to store data
temporarily.
⚫To program in assembly language, we must
understand the registers and architecture of
given CPU and the role they play in processing
data.
PIC18 Registers
⚫ PIC microcontroller contains an 8-bit ALU (Arithmetic
Logic Unit) and an 8-bit Working Register (WREG).
⚫ There are different GPRs (General Purpose
Registers) and SFRs (Special Function Registers) in
a PIC microcontroller.
⚫ The overall system performs 8-bit arithmetic and logic
functions.
PIC registers
WREG Register
⚫Stand forW
orkingregister
⚫8-bit register
⚫ Use for all arithmetic and logic instructions.
⚫used bymanyinstructions as:
⚫the source of an operand.
⚫the destination for the result of the
instruction execution.
PIC File Register
⚫The file register is read/write memory used by
CPU for data storage, scratch pad, and
register for internal use and functions.
⚫Divided into two sections:
a) Special Function Registers (SFR)
b) General Purpose Registers (GPR)
General Purpose Register (GPR)
⚫8-bit registers
⚫are a group of RAM locations in the file
register that are used for data storage and
scratch pad.
⚫the space that is not allocated to the SFRs
typically used for general-purpose registers.
Special Function Register (SFR)
⚫SFR are dedicated to specific functions such
as ALU status, timers, serial communication,
I/O ports, ADC and so on.
⚫The function of each SFR is fixed by the CPU
designer at the time of design.
⚫8-bit registers
Special
Function
Register
of PIC18
family
SFR(cont’d)
⦿Examples of SFRregister:
1. PORTx
2. LA
Tx
3. TRISx
4. TIMER0
5. ADCON0,ADCON1
6. ADRESH
7. INTCON
8. etc
Review Questions
1. What do RISC an CISC stand for?
2. True or false. Harvard architecture uses the
same address and data busses to fetch both
code and data.
3. Register WREG is -bit wide.
4. True or false. Data space is SRAM memory,
whereas program (code) space is of the ROM
type.
5. The general-purpose RAM and SFRs together
are called .
6. The SFR registers in PIC are -bit.
STATUS Register
⚫8-bit register
⚫referred to asthe flagregister.
⚫only5 bits of it are used bythe PIC18.
⚫ called conditional flags
⚫The three unused bits are unimplemented
and read as0.
STATUSRegister (cont’d)
Flags in Status Register
b7 b6 b5 b4 b3 b2 b1 b0
Negative Overflow Zero Digit Carry Carry
⚫ C (Carry/Borrow Flag) set when an addition generates a carry and a
subtraction generates a borrow.
⚫ DC(Digit Carry Flag):also called Half Carry flag;set when carry generated
from Bit3 to Bit4 an arithmetic operatio.n
⚫ Z(Zero Flag):set when result of an operation is zero.
⚫ OV(Overflow Flag):set when result of an operation of signed numbers goes
beyond seven bits-if the results fall outside 127(0x7F)and -128(0x80).
⚫ N(Negative Flag):set when bit B7 is one of the result of an arithmetic/logic
operation.
- - - N OV Z DC C
Example 1
⚫Show the status of the C, DC and Z flag after the
addition of 38H and 2FH.
⚫Solution:
38H 00111000
+ 2FH + 00101111
67H 01100111
C = 0
DC = 1
Z = 0
Review Questions
1. The flag register in PIC is called the .
2. What is the size of the flag register in PIC?
3. Which bits of the status register are unused?
4. Which bits of the status register are used for the
C and DC flag bit respectively?
5. Show the status of the C, DC and Z flag after the
addition of 9CH and 64FH.

chapter2-part1-140329134839-phpapp02.pptx

  • 2.
  • 3.
    Part 1 :PIC18 Microcontroller Architecture At the end of this session you should be able to explain: ⚫ PIC18 Microcontroller families ⚫ PIC18 architecture ⚫ Data RAM file Register
  • 4.
    INTRODUCTION ⚫PICis afamilyof modifiedHarvard architecture microcontrollersmade byMicrochip T echnology , derived from the PIC1650originally developed byGeneral Instrument's Microelectronics Division. ⚫ The name PIC initially referred to "Peripheral Interface Controller”
  • 5.
    ⚫PICs are popularwith both industrial developers and hobbyists alike due to their: 1. low cost, 2. wide availability, 3. large user base, 4. extensive collection of application notes, 5. availability of low cost or free development tools, 6. serial programming (and re-programming with flash memory) capability.
  • 6.
  • 7.
    PIC18 PIC® Microcontrollers ⚫ThePIC18 family use an 8-bit architecture. ⚫ With up to 16 MIPSofprocessingpower,PIC18 Microcontrollers feature advancedperipherals,such asCAN, USB,Ethernet, LCD and CTMU.
  • 8.
    29 March, 2013 9mfauzi Basic Upgrade USB CAN
  • 9.
    PIC18 Architecture ⚫PIC microcontrollersare based on advanced RISC architecture. ⚫RISCstandsfor Reduced Instruction SetComputing. In this architecture, the instruction set of hardware gets reduced which increases the execution rate (speed) of system. ⚫ ⚫PIC microcontrollersfollow Harvard architecture for internal data transfer
  • 10.
    RISC vs CISC ⚫Reducedinstruction set computing, or RISCis a CPU design strategy based on the insight that simplified instructions can provide higher performance if this simplicity enables much faster execution of each instruction. ⚫A complex instruction set computer (CISC), is a computer where single instructions can execute several low-level operations
  • 11.
    PIC18 Architecture (cont’d) ⚫PICmicrocontrollersare designed using the HarvardArchitecture which includes: ⚫Microprocessor unit (MPU) ⚫Program memoryfor instructions ⚫Data memoryfor data ⚫I/O ports ⚫Support devices such astimers
  • 12.
    Harvard Architecture vsVon Neumann Architecture • Von Neumann Architecture: – Used single memory space for program and data. – Limits operating bandwidth • Harvard Architecture: – Uses two separate memory spaces for program instructions and data – Improved operating bandwidth – Allows for different bus Von Neumann Architecture 8-bit Bus CPU Program & Data Memory CPU Harvard Architecture Data Memory Program Memory 8-bit Bus 16-bit Bus
  • 13.
  • 14.
    PIC18 Features: ⚫CPU core ⚫Thefunction of the CPU is to execute (process) information stored in memory . ⚫Program ROM ⚫The ROM use to store program.
  • 15.
    PIC18 Features (cont’d) ⦿DataMemory The data memory is SRAMand EEPROM. provides aplace to store data asapplication executes and is lost when power is removed from the system. ⦿EEPROM also anonvolatile memory which is used to store data like values of certain variables. PIC18F4550 has 256 Bytesof EEPROM.
  • 16.
    PIC18 Features (cont’d) ⚫I/OPorts: ⚫The I/O ports are used to interface the microprocessor to the outside world. PIC18F4550 pin diagram.
  • 17.
    Other internal Devices ⚫Oscillator ⚫8x8Multiplier ⚫ADC Interface ⚫Timers/Counter s ⚫USB
  • 18.
    PIC18 Registers ⚫CPUs usemany registers to store data temporarily. ⚫To program in assembly language, we must understand the registers and architecture of given CPU and the role they play in processing data.
  • 19.
    PIC18 Registers ⚫ PICmicrocontroller contains an 8-bit ALU (Arithmetic Logic Unit) and an 8-bit Working Register (WREG). ⚫ There are different GPRs (General Purpose Registers) and SFRs (Special Function Registers) in a PIC microcontroller. ⚫ The overall system performs 8-bit arithmetic and logic functions.
  • 20.
  • 21.
    WREG Register ⚫Stand forW orkingregister ⚫8-bitregister ⚫ Use for all arithmetic and logic instructions. ⚫used bymanyinstructions as: ⚫the source of an operand. ⚫the destination for the result of the instruction execution.
  • 22.
    PIC File Register ⚫Thefile register is read/write memory used by CPU for data storage, scratch pad, and register for internal use and functions. ⚫Divided into two sections: a) Special Function Registers (SFR) b) General Purpose Registers (GPR)
  • 23.
    General Purpose Register(GPR) ⚫8-bit registers ⚫are a group of RAM locations in the file register that are used for data storage and scratch pad. ⚫the space that is not allocated to the SFRs typically used for general-purpose registers.
  • 24.
    Special Function Register(SFR) ⚫SFR are dedicated to specific functions such as ALU status, timers, serial communication, I/O ports, ADC and so on. ⚫The function of each SFR is fixed by the CPU designer at the time of design. ⚫8-bit registers
  • 25.
  • 26.
    SFR(cont’d) ⦿Examples of SFRregister: 1.PORTx 2. LA Tx 3. TRISx 4. TIMER0 5. ADCON0,ADCON1 6. ADRESH 7. INTCON 8. etc
  • 27.
    Review Questions 1. Whatdo RISC an CISC stand for? 2. True or false. Harvard architecture uses the same address and data busses to fetch both code and data. 3. Register WREG is -bit wide. 4. True or false. Data space is SRAM memory, whereas program (code) space is of the ROM type. 5. The general-purpose RAM and SFRs together are called . 6. The SFR registers in PIC are -bit.
  • 28.
    STATUS Register ⚫8-bit register ⚫referredto asthe flagregister. ⚫only5 bits of it are used bythe PIC18. ⚫ called conditional flags ⚫The three unused bits are unimplemented and read as0.
  • 29.
    STATUSRegister (cont’d) Flags inStatus Register b7 b6 b5 b4 b3 b2 b1 b0 Negative Overflow Zero Digit Carry Carry ⚫ C (Carry/Borrow Flag) set when an addition generates a carry and a subtraction generates a borrow. ⚫ DC(Digit Carry Flag):also called Half Carry flag;set when carry generated from Bit3 to Bit4 an arithmetic operatio.n ⚫ Z(Zero Flag):set when result of an operation is zero. ⚫ OV(Overflow Flag):set when result of an operation of signed numbers goes beyond seven bits-if the results fall outside 127(0x7F)and -128(0x80). ⚫ N(Negative Flag):set when bit B7 is one of the result of an arithmetic/logic operation. - - - N OV Z DC C
  • 30.
    Example 1 ⚫Show thestatus of the C, DC and Z flag after the addition of 38H and 2FH. ⚫Solution: 38H 00111000 + 2FH + 00101111 67H 01100111 C = 0 DC = 1 Z = 0
  • 31.
    Review Questions 1. Theflag register in PIC is called the . 2. What is the size of the flag register in PIC? 3. Which bits of the status register are unused? 4. Which bits of the status register are used for the C and DC flag bit respectively? 5. Show the status of the C, DC and Z flag after the addition of 9CH and 64FH.