SlideShare a Scribd company logo
Introduction to the PIC Microcontroller BEE 3213: Microprocessor & Microcontroller
Outline What is Microcontroller? µC  vs General-Purpose  µ P A Brief History of PIC µC PIC16F84 Features PIC Clock Generator Reset PORTS Center Processing Unit (CPU) MEMORY ORGANIZATION Timer & Prescalar Flash Memory RAM ROM EEPROM
What is Microcontroller? Integrated chip that  contains  CPU, RAM, some form of ROM, I/O ports, and timers Designed for a very  specific task  to control a particular system reduce production cost
µC  vs General-Purpose  µ P Microcontroller Microprocessor Devices Microchip’s PIC’s series, Atmel’s AVR series Intel’s x86 family (8086, 80286, 80386, 80486 & the Pentium) or (Motorola’s PowerPC family) Components Internal CPU, RAM, ROM, I/O ports and timers External RAM, ROM, and I/O ports Application Perform specific function: A small set of signal processing functions for digital signal processor Perform more tasks that related to general requirements:  calculations of software, personal computer
µC  vs General-Purpose  µ P Cont… CPU /  μ P Register Control Unit ALU DATA BUS CPU /  μ P Register Control Unit ALU ADDRESS BUS CONTROL BUS μ C RAM ROM I/O Timer Serial COM
µC  vs General-Purpose  µ P Cont… Microprocessor-based System Microcontroller-based System
A Brief History of PIC µC In 1989, Microchip Technology Corporation introduced an 8-bit µC called PIC (Peripheral Interface Controller). This 8 pins chip contains a small amounts of data RAM, a few hundred bytes of on-chip ROM for program, one timer, and a few pins for I/O ports. The family of 8-bit µC: 10xxx, 12xxx, 14xxx, 16xxx, 17xxx, and 18xxx
A Brief History of PIC µC Cont… http://www.microchip.com
A Brief History of PIC µC They are all 8-bit processors that the CPU can work on only 8 bits of data a time. Problem: not all 100% upwardly compatible in terms of software when going from one family to another family. Ex.: 12xxx - 12-bit wide instructions   16xxx- 14-bit wide instructions   PIC18xxx - 16-bit wide with many    new instructions Cont…
A Brief History of PIC µC Advantages of PIC: 30 to 100 times faster than other µCs (program memory is integrated to the chip) Smaller size (on-board memory) Easy to program, reusable and inexpensive Cont…
A Brief History of PIC µC Architecture: Cont… CPU Program &  Data Memory Von Neumann architecture CPU Program Memory Data Memory Harvard architecture
Review A   C normally has which of the following devices on-chip? (a) RAM (b) ROM (c) I/O (d) all of the above A general-purpose microprocessor normally needs which of the following devices to be attached to it? (a) RAM (b) ROM (c) I/O (d) all of the above 3. The PIC16 has a(n) ___-bit   P.
PIC16F84 Features 18 pins, DIP18 type (Dual in Package) or SMD type Remarks: RA0 - RA3 :  Pins on port A. No additional function RA4  :  TOCK1 which functions as a timer RB0  :  Interrupt input is an additional function. RB1 - RB5 :  Pins on port B. No additional function. RB6  :  'Clock' line in program mode. RB7  :  'Data' line in program mode MCLR  :  Reset input and Vpp programming voltage Vss  :  Ground of power supply. Vdd  :  Positive power supply pole. OSC1 - OSC2 :  Pins for connecting with oscillator.
PIC16F84 Features Cont… Block  diagram of  PIC16F84
PIC Clock Generator To provide a clock for executing a program or program instructions of   C. Types of PIC clock generator: A crystal & two capacitors Resonators or external resistor-capacitor pair Built-in resistor-capacitor
PIC Clock Generator PIC16F84 can operate in four different oscillation modes: - LP low power crystal - XT crystal/resonator - HS high speed crystal/resonator - RC resistor/capacitor Two configuration bits, FOSC1 & FOSC0 are used to select one of these four modes Cont…
PIC Clock Generator Crystal Oscillator/Ceramic Resonators For XT, LP or HS OSC configurations Crystal or ceramic resonator is connected to the OSC1/CLKIN & OSC2/CLKOUT pins Cont…
PIC Clock Generator A parallel cut crystal is used to design PIC16F84A The use of a series cut crystal may give a freq. out of the crystal manufacturer’s specifications Cont… External clock input operations
PIC Clock Generator Cont… Capacitor selection for ceramic resonators Capacitor selection for crystal resonators
PIC Clock Generator RC Oscillator Reduce cost for timing insensitive applications Variation of the oscillator frequency: - operating temperature - process parameter variation - difference in lead frame capacitance between package types (low  CEXT values) - tolerance of the external R & C components Cont…
Reset Power-on Reset (POR) MCLR during normal operation MCLR during SLEEP WDT Reset (during normal operation) WDT Wake-up (during SLEEP) Value registers upon reset Register Reset value (hex) PC 000000 WREG 00 SP 00 TRISA-TRISB FF
Review Which pin is used to reset the PIC16F84 chip? Upon power-up, the program counter (PC) has a value of ____. Upon power-up, the PIC16F84 fetches the first opcode from ROM address location _____. MCLR is an active-_____ (LOW, HIGH) pin. How many Vdd and Gnd pins are in the PIC16F84 chip? In the PIC16, the program counter is ____ bits wide.
PORTS Physical connection of CPU and outside world – monitor @ control other components @ devices A group of pins which can be accessed simultaneously @ set the desired combination of zeros and ones All port pins can be designated as input @ output
PORTS:  PORTA & TRISA PORTA is a 5-bit wide, bi-directional port TRISA: data direction register of PORTA TRISA = 1, PORTA is an input (output driver in HI-impedance mode) TRISA = 0, PORTA is an output (contents of the output latch on the selected pin)
PORTS:  PORTB & TRISB PORTB is a 8-bit wide, bi-directional port TRISB: data direction register of PORTB TRISB = 1, PORTB is an input (output driver in HI-impedance mode) TRISB = 0, PORTB is an output (contents of the output latch on the selected pin)
Review There are total of ____ ports in the PIC16F84. True or false.  All of the PIC16F84 ports have 8 pins. List the PIC16F84 port that has 8 pins. True or false. Upon power-up, the I/O pins are configured as output ports. To make Port B an output port, we must place ____ in register _____. To make Port B an input port, we must place ____ in register _____.
Center Processing Unit (CPU) The brain of the   C Connect all parts of the   C through a data bus & and an address bus Find, fetch, decode & execute the right instruction CPU resources: Registers : store temporary information ALU : performing arithmetic functions Program counter : point to the address of the next instruction to be executed Instruction decoder : interpret the instruction fetched into the CPU
Center Processing Unit (CPU) execute Memory Assembler (translator) Decoder MOVLW 0x20 Program  Memory Temporary  storage 11 00xx 0010 0000 opcode Fetch  instruction Fetch  instruction
Center Processing Unit (CPU) Arithmetic Logic Unit (ALU) Add, subtract, move (left @ right within a register) and logic operations PIC16F84 contains an 8-bit ALU & 8-bit working registers (WREG) ALU instructions: two operands @ one operand Two operands: WREG + file register @ immediate constant Registers: GPR (General Purposes Registers) & SFP (Special Function Registers) One operand: WREG @ a file register Execution of ALU instructions can affect STATUS bits which are carry (C), digit carry (DC), and zero (Z). Cont…
Center Processing Unit (CPU) Cont… ALU STATUS  register 8-bit literal (from instruction word) WREG  register 8-bit 8-bit 8-bit Z, DC, C flags Carry bit
MEMORY ORGANIZATION PIC16F84 has two separate memory blocks: data & program Data block: GPR and SFP registers in RAM memory (read/write memory- static memory), EEPROM memory Program block: FLASH memory
Memory organization of PIC16F84
MEMORY ORGANIZATION:   Program Memory Used for storing programs (opcodes), directly under control of program counter (PC) Wake up memory (address 0000H) when PIC is powered up. Has been carried out in FLASH technology  (indicated by the letter F in the part number, C for one-time programmable (OTP)) : possible to program a   C many times Size of 1024 locations, 14 bits width Locations 0000h & 0004h are reserved for reset & interrupt vector, respectively The 1 st  1Kx14 (0000h-03FFh) are physically implemented address Accessing a location of physically implemented address will cause a wraparound
MEMORY ORGANIZATION:   Program Memory
MEMORY ORGANIZATION:   Data Memory Also known as file register:  data storage, scratch pad & registers for internal use and functions Special Function Registers (SFR) - 8-bit wide  - ALU status, timers, serial communication, I/O ports, ADC, & etc. - function of each SFR is fixed in design, used to control   C or peripheral -  access either directly (names @ addresses) or indirectly (FSR – File Select  Register) - classified into core and peripheral sets -  control bits (RP1, RP0) in STATUS register are used for bank selection General Purpose Registers (GPR) - 8-bit wide -  also called general purpose RAM (GP RAM) -  used for data storage & scratch pad -  accessed directly - addresses in Bank 0 & Bank 1 are mapped together Location of SFR and GPR vary from chip to chip, even among members of the same family
Data Memory Organization
SFR File Memory Legend:  x = unknown,  u = unchanged,  - = unimplemented,  read as '0',  q = value depends on condition Note  1:  The upper byte of the program counter is not directly accessible. PCLATH is a slave register for PC<12:8>. The contents of PCLATH can be transferred to the upper byte of the program counter, but the contents of PC<12:8> are never transferred to PCLATH. 2:  The TO and PD status bits in the STATUS register are not affected by a MCLR Reset. 3:  Other (non power-up) RESETS include: external RESET through MCLR and the Watchdog Timer Reset. 4:  On any device RESET, these pins are configured as inputs. 5:  This is the value that will be in the port output latch.
Review True or false.  Every member of the PIC16 family, regardless of the program ROM size, wakes up at memory 0000H when it is powered up. What is the main difference between the PIC16Fxxx and PIC16Cxxx   C? The GPR and SFR together are called ____. The SFR registers in PIC are ___-bit. The data memory in PIC16 is divided into  ____-byte banks.
Timer & Prescalar Establish relation between a real dimension such as “time” and a variable which represents status of a time within a microcontroller PIC16F84 has an 8-bit timer, whose its value is continually increasing to 255 and then it starts all over again: 0, 1, 2, 3, …, 255, 0, 1,… etc Prescaler divides oscillator clock before it reaches logic that increases timer status. The first three bits in OPTION register defines divisor 256 is the highest divisor, means timer clock would increase by one at every 256 th  clock
Timer & Prescalar Cont…
Flash Memory Store permanent information on some palm-sized computers (operating system & core applications) Unlike RAM (random-access memory), flash memory can continue to store information in the absence of a power source. Unlike ROM (read-only memory), we can write/update to flash memory More expensive than ROM
RAM Random-access memory The most common computer memory to perform necessary tasks while the computer is on An integrated circuit memory chip allows information to be stored or accessed in any order and all storage locations are equally accessible.
ROM Read Only Memory Non-volatile: hold programs and data that must be retained even the computer is turned off data cannot be easily written to ROM; depending on the technology used in the ROM, writing may require special hardware, or may be impossible.  A computer's BIOS may be stored in ROM.
EEPROM Electrically Erasable Programmable Read Only Memory  ROM that can be erased electronically and reprogrammed in-circuit (or with a device programmer).  EEPROM is very similar to flash memory. The biggest difference is that the bytes (words) of an EEPROM can be erased individually.

More Related Content

What's hot (20)

PPT
Introduction to msp430
Harsha herle
 
PPT
Architecture of 8051 microcontroller))
Ganesh Ram
 
PDF
Introduction to ESP32 Programming [Road to RIoT 2017]
Alwin Arrasyid
 
PDF
Pic microcontroller architecture
Jamia Hamdard
 
PPTX
Watch-dog Timer in LPC1768
Srishti Kakade
 
PPTX
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
Moe Moe Myint
 
DOCX
Training report on embedded sys_AVR
Galgotias College of Engg. & Tech.
 
PPTX
30. 8086 microprocessor pipelined architecture
sandip das
 
PPTX
PIC 16F877 micro controller by Gaurav raikar
GauravRaikar3
 
PDF
Embedded C - Lecture 2
Mohamed Abdallah
 
PDF
Timers in Arduino
VEDANSH SHARMA
 
PPTX
Microprocessors
Spitiq
 
PDF
Interrupts of microcontroller 8051
Nilesh Bhaskarrao Bahadure
 
PPTX
Comparison of pentium processor with 80386 and 80486
Tech_MX
 
PPTX
VHDL summer training (ppt)
HoneyKumar34
 
PPT
Serial Communication In Atmega 16
Suren Kumar
 
PPTX
I2C Protocol
Sudhanshu Janwadkar
 
PPTX
PIC-18 Microcontroller
ASHISH RANJAN
 
Introduction to msp430
Harsha herle
 
Architecture of 8051 microcontroller))
Ganesh Ram
 
Introduction to ESP32 Programming [Road to RIoT 2017]
Alwin Arrasyid
 
Pic microcontroller architecture
Jamia Hamdard
 
Watch-dog Timer in LPC1768
Srishti Kakade
 
Ch 1 introduction to Embedded Systems (AY:2018-2019--> First Semester)
Moe Moe Myint
 
Training report on embedded sys_AVR
Galgotias College of Engg. & Tech.
 
30. 8086 microprocessor pipelined architecture
sandip das
 
PIC 16F877 micro controller by Gaurav raikar
GauravRaikar3
 
Embedded C - Lecture 2
Mohamed Abdallah
 
Timers in Arduino
VEDANSH SHARMA
 
Microprocessors
Spitiq
 
Interrupts of microcontroller 8051
Nilesh Bhaskarrao Bahadure
 
Comparison of pentium processor with 80386 and 80486
Tech_MX
 
VHDL summer training (ppt)
HoneyKumar34
 
Serial Communication In Atmega 16
Suren Kumar
 
I2C Protocol
Sudhanshu Janwadkar
 
PIC-18 Microcontroller
ASHISH RANJAN
 

Viewers also liked (9)

PPTX
Integrated circuits
dhawal mehta
 
PDF
Introduction to microcontrollers
Corrado Santoro
 
PPTX
Know About Different Types of Integrated Circuits
elprocus
 
PPT
Integrated Circuits
ANAND G
 
PPTX
Introduction of microcontroller
Engineer Maze
 
PPTX
Integrated circuits
Naveen Sihag
 
PPTX
Introduction to Microcontrollers
Venkata Sai Vamsi Penupothu
 
PPTX
Integrated circuit
Jessa Arnado
 
PPTX
Computer Integrated Manufacturing
suraj_21
 
Integrated circuits
dhawal mehta
 
Introduction to microcontrollers
Corrado Santoro
 
Know About Different Types of Integrated Circuits
elprocus
 
Integrated Circuits
ANAND G
 
Introduction of microcontroller
Engineer Maze
 
Integrated circuits
Naveen Sihag
 
Introduction to Microcontrollers
Venkata Sai Vamsi Penupothu
 
Integrated circuit
Jessa Arnado
 
Computer Integrated Manufacturing
suraj_21
 
Ad

Similar to Chp4 introduction to the pic microcontroller copy (20)

PPT
PIC Introduction and explained in detailed
Ankita Tiwari
 
PPTX
MICROCONTROLLER.pptx
fiqrie mohd
 
PDF
UNIT-V (PIC16F877-Microcontrollers).pdf
dhiyasrinivasan112
 
PPTX
PIC_Intro.pptx
LECO9
 
PPT
PICPICPICPICPICPICPICPICPICPICPICPIC .ppt
DrHamdyMMousa
 
PDF
Introduction to pic microcontroller
Siva Kumar
 
PPT
My seminar new 28
rajeshkvdn
 
PDF
PIC Microcontrollers: Powering Versatile Embedded Solutions"
aadithyaaa2005
 
PPT
Introduction2_PIC.ppt
AakashRawat35
 
PDF
Microcontroller pic 16 f877 registers memory ports
Nilesh Bhaskarrao Bahadure
 
PPT
8051c.ppt microcontroller hardware summary
anushkayadav3011
 
PPTX
435303149-PIC-ppt microcontroller introduct
sindhujam30
 
DOC
PIC MICROCONTROLLERS -CLASS NOTES
Dr.YNM
 
PPT
Microprocessors and Microcontrollers.ppt
Saravanan Pazapughal
 
PPTX
Seminar topic.on embeded system
SachinMaithani1
 
PPT
8051 Presentation
Sayan Chakraborty
 
PDF
PIC1jjkkkkkkkjhgfvjitr c its GJ tagging hugg
HebaEng
 
PPT
Microcontroller 8051
guest70d48b1
 
PIC Introduction and explained in detailed
Ankita Tiwari
 
MICROCONTROLLER.pptx
fiqrie mohd
 
UNIT-V (PIC16F877-Microcontrollers).pdf
dhiyasrinivasan112
 
PIC_Intro.pptx
LECO9
 
PICPICPICPICPICPICPICPICPICPICPICPIC .ppt
DrHamdyMMousa
 
Introduction to pic microcontroller
Siva Kumar
 
My seminar new 28
rajeshkvdn
 
PIC Microcontrollers: Powering Versatile Embedded Solutions"
aadithyaaa2005
 
Introduction2_PIC.ppt
AakashRawat35
 
Microcontroller pic 16 f877 registers memory ports
Nilesh Bhaskarrao Bahadure
 
8051c.ppt microcontroller hardware summary
anushkayadav3011
 
435303149-PIC-ppt microcontroller introduct
sindhujam30
 
PIC MICROCONTROLLERS -CLASS NOTES
Dr.YNM
 
Microprocessors and Microcontrollers.ppt
Saravanan Pazapughal
 
Seminar topic.on embeded system
SachinMaithani1
 
8051 Presentation
Sayan Chakraborty
 
PIC1jjkkkkkkkjhgfvjitr c its GJ tagging hugg
HebaEng
 
Microcontroller 8051
guest70d48b1
 
Ad

More from mkazree (20)

PDF
Coal Fired Power Plant
mkazree
 
DOC
Contoh kertas kerja program
mkazree
 
DOC
Foster-seely and Ratio Detector (Discriminator )
mkazree
 
PPT
Communication Engineering - Chapter 6 - Noise
mkazree
 
PPT
Chapter 5 fm receivers
mkazree
 
PDF
The Electronic Hobby Kit
mkazree
 
PDF
Tutorial chapter 2 robotic
mkazree
 
PPT
Dek3223 chapter 2 robotic
mkazree
 
PPT
Chapter 3 am receivers
mkazree
 
PPT
Dek3223 chapter 3 industrial robotic
mkazree
 
DOC
Tutorial chapter 3 robotic
mkazree
 
DOC
Tutorial 2 amplitude modulation
mkazree
 
PPT
Chapter 3 am receivers
mkazree
 
PPT
Comm introduction
mkazree
 
PPT
Chapter2 cont
mkazree
 
PPT
Chapter 2 amplitude_modulation
mkazree
 
DOC
Chapter5 dek 3143 dae 32303 9 (nota tambahan)
mkazree
 
DOC
120102011
mkazree
 
DOC
Ii20102011
mkazree
 
DOC
Chapter 4 synchronous machine
mkazree
 
Coal Fired Power Plant
mkazree
 
Contoh kertas kerja program
mkazree
 
Foster-seely and Ratio Detector (Discriminator )
mkazree
 
Communication Engineering - Chapter 6 - Noise
mkazree
 
Chapter 5 fm receivers
mkazree
 
The Electronic Hobby Kit
mkazree
 
Tutorial chapter 2 robotic
mkazree
 
Dek3223 chapter 2 robotic
mkazree
 
Chapter 3 am receivers
mkazree
 
Dek3223 chapter 3 industrial robotic
mkazree
 
Tutorial chapter 3 robotic
mkazree
 
Tutorial 2 amplitude modulation
mkazree
 
Chapter 3 am receivers
mkazree
 
Comm introduction
mkazree
 
Chapter2 cont
mkazree
 
Chapter 2 amplitude_modulation
mkazree
 
Chapter5 dek 3143 dae 32303 9 (nota tambahan)
mkazree
 
120102011
mkazree
 
Ii20102011
mkazree
 
Chapter 4 synchronous machine
mkazree
 

Recently uploaded (20)

PDF
Horarios de distribución de agua en julio
pegazohn1978
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
PPTX
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
PDF
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
PPTX
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
Horarios de distribución de agua en julio
pegazohn1978
 
Introduction to Indian Writing in English
Trushali Dodiya
 
Difference between write and update in odoo 18
Celine George
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
EDUCATIONAL MEDIA/ TEACHING AUDIO VISUAL AIDS
Sonali Gupta
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Exploring the Different Types of Experimental Research
Thelma Villaflores
 
How to Manage Allocation Report for Manufacturing Orders in Odoo 18
Celine George
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
How to Send Email From Odoo 18 Website - Odoo Slides
Celine George
 
Stokey: A Jewish Village by Rachel Kolsky
History of Stoke Newington
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
DAY 1_QUARTER1 ENGLISH 5 WEEK- PRESENTATION.pptx
BanyMacalintal
 
How to Create a Customer From Website in Odoo 18.pptx
Celine George
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
infertility, types,causes, impact, and management
Ritu480198
 

Chp4 introduction to the pic microcontroller copy

  • 1. Introduction to the PIC Microcontroller BEE 3213: Microprocessor & Microcontroller
  • 2. Outline What is Microcontroller? µC vs General-Purpose µ P A Brief History of PIC µC PIC16F84 Features PIC Clock Generator Reset PORTS Center Processing Unit (CPU) MEMORY ORGANIZATION Timer & Prescalar Flash Memory RAM ROM EEPROM
  • 3. What is Microcontroller? Integrated chip that contains CPU, RAM, some form of ROM, I/O ports, and timers Designed for a very specific task to control a particular system reduce production cost
  • 4. µC vs General-Purpose µ P Microcontroller Microprocessor Devices Microchip’s PIC’s series, Atmel’s AVR series Intel’s x86 family (8086, 80286, 80386, 80486 & the Pentium) or (Motorola’s PowerPC family) Components Internal CPU, RAM, ROM, I/O ports and timers External RAM, ROM, and I/O ports Application Perform specific function: A small set of signal processing functions for digital signal processor Perform more tasks that related to general requirements: calculations of software, personal computer
  • 5. µC vs General-Purpose µ P Cont… CPU / μ P Register Control Unit ALU DATA BUS CPU / μ P Register Control Unit ALU ADDRESS BUS CONTROL BUS μ C RAM ROM I/O Timer Serial COM
  • 6. µC vs General-Purpose µ P Cont… Microprocessor-based System Microcontroller-based System
  • 7. A Brief History of PIC µC In 1989, Microchip Technology Corporation introduced an 8-bit µC called PIC (Peripheral Interface Controller). This 8 pins chip contains a small amounts of data RAM, a few hundred bytes of on-chip ROM for program, one timer, and a few pins for I/O ports. The family of 8-bit µC: 10xxx, 12xxx, 14xxx, 16xxx, 17xxx, and 18xxx
  • 8. A Brief History of PIC µC Cont… http://www.microchip.com
  • 9. A Brief History of PIC µC They are all 8-bit processors that the CPU can work on only 8 bits of data a time. Problem: not all 100% upwardly compatible in terms of software when going from one family to another family. Ex.: 12xxx - 12-bit wide instructions 16xxx- 14-bit wide instructions PIC18xxx - 16-bit wide with many new instructions Cont…
  • 10. A Brief History of PIC µC Advantages of PIC: 30 to 100 times faster than other µCs (program memory is integrated to the chip) Smaller size (on-board memory) Easy to program, reusable and inexpensive Cont…
  • 11. A Brief History of PIC µC Architecture: Cont… CPU Program & Data Memory Von Neumann architecture CPU Program Memory Data Memory Harvard architecture
  • 12. Review A  C normally has which of the following devices on-chip? (a) RAM (b) ROM (c) I/O (d) all of the above A general-purpose microprocessor normally needs which of the following devices to be attached to it? (a) RAM (b) ROM (c) I/O (d) all of the above 3. The PIC16 has a(n) ___-bit  P.
  • 13. PIC16F84 Features 18 pins, DIP18 type (Dual in Package) or SMD type Remarks: RA0 - RA3 : Pins on port A. No additional function RA4 : TOCK1 which functions as a timer RB0 : Interrupt input is an additional function. RB1 - RB5 : Pins on port B. No additional function. RB6 : 'Clock' line in program mode. RB7 : 'Data' line in program mode MCLR : Reset input and Vpp programming voltage Vss : Ground of power supply. Vdd : Positive power supply pole. OSC1 - OSC2 : Pins for connecting with oscillator.
  • 14. PIC16F84 Features Cont… Block diagram of PIC16F84
  • 15. PIC Clock Generator To provide a clock for executing a program or program instructions of  C. Types of PIC clock generator: A crystal & two capacitors Resonators or external resistor-capacitor pair Built-in resistor-capacitor
  • 16. PIC Clock Generator PIC16F84 can operate in four different oscillation modes: - LP low power crystal - XT crystal/resonator - HS high speed crystal/resonator - RC resistor/capacitor Two configuration bits, FOSC1 & FOSC0 are used to select one of these four modes Cont…
  • 17. PIC Clock Generator Crystal Oscillator/Ceramic Resonators For XT, LP or HS OSC configurations Crystal or ceramic resonator is connected to the OSC1/CLKIN & OSC2/CLKOUT pins Cont…
  • 18. PIC Clock Generator A parallel cut crystal is used to design PIC16F84A The use of a series cut crystal may give a freq. out of the crystal manufacturer’s specifications Cont… External clock input operations
  • 19. PIC Clock Generator Cont… Capacitor selection for ceramic resonators Capacitor selection for crystal resonators
  • 20. PIC Clock Generator RC Oscillator Reduce cost for timing insensitive applications Variation of the oscillator frequency: - operating temperature - process parameter variation - difference in lead frame capacitance between package types (low CEXT values) - tolerance of the external R & C components Cont…
  • 21. Reset Power-on Reset (POR) MCLR during normal operation MCLR during SLEEP WDT Reset (during normal operation) WDT Wake-up (during SLEEP) Value registers upon reset Register Reset value (hex) PC 000000 WREG 00 SP 00 TRISA-TRISB FF
  • 22. Review Which pin is used to reset the PIC16F84 chip? Upon power-up, the program counter (PC) has a value of ____. Upon power-up, the PIC16F84 fetches the first opcode from ROM address location _____. MCLR is an active-_____ (LOW, HIGH) pin. How many Vdd and Gnd pins are in the PIC16F84 chip? In the PIC16, the program counter is ____ bits wide.
  • 23. PORTS Physical connection of CPU and outside world – monitor @ control other components @ devices A group of pins which can be accessed simultaneously @ set the desired combination of zeros and ones All port pins can be designated as input @ output
  • 24. PORTS: PORTA & TRISA PORTA is a 5-bit wide, bi-directional port TRISA: data direction register of PORTA TRISA = 1, PORTA is an input (output driver in HI-impedance mode) TRISA = 0, PORTA is an output (contents of the output latch on the selected pin)
  • 25. PORTS: PORTB & TRISB PORTB is a 8-bit wide, bi-directional port TRISB: data direction register of PORTB TRISB = 1, PORTB is an input (output driver in HI-impedance mode) TRISB = 0, PORTB is an output (contents of the output latch on the selected pin)
  • 26. Review There are total of ____ ports in the PIC16F84. True or false. All of the PIC16F84 ports have 8 pins. List the PIC16F84 port that has 8 pins. True or false. Upon power-up, the I/O pins are configured as output ports. To make Port B an output port, we must place ____ in register _____. To make Port B an input port, we must place ____ in register _____.
  • 27. Center Processing Unit (CPU) The brain of the  C Connect all parts of the  C through a data bus & and an address bus Find, fetch, decode & execute the right instruction CPU resources: Registers : store temporary information ALU : performing arithmetic functions Program counter : point to the address of the next instruction to be executed Instruction decoder : interpret the instruction fetched into the CPU
  • 28. Center Processing Unit (CPU) execute Memory Assembler (translator) Decoder MOVLW 0x20 Program Memory Temporary storage 11 00xx 0010 0000 opcode Fetch instruction Fetch instruction
  • 29. Center Processing Unit (CPU) Arithmetic Logic Unit (ALU) Add, subtract, move (left @ right within a register) and logic operations PIC16F84 contains an 8-bit ALU & 8-bit working registers (WREG) ALU instructions: two operands @ one operand Two operands: WREG + file register @ immediate constant Registers: GPR (General Purposes Registers) & SFP (Special Function Registers) One operand: WREG @ a file register Execution of ALU instructions can affect STATUS bits which are carry (C), digit carry (DC), and zero (Z). Cont…
  • 30. Center Processing Unit (CPU) Cont… ALU STATUS register 8-bit literal (from instruction word) WREG register 8-bit 8-bit 8-bit Z, DC, C flags Carry bit
  • 31. MEMORY ORGANIZATION PIC16F84 has two separate memory blocks: data & program Data block: GPR and SFP registers in RAM memory (read/write memory- static memory), EEPROM memory Program block: FLASH memory
  • 33. MEMORY ORGANIZATION: Program Memory Used for storing programs (opcodes), directly under control of program counter (PC) Wake up memory (address 0000H) when PIC is powered up. Has been carried out in FLASH technology (indicated by the letter F in the part number, C for one-time programmable (OTP)) : possible to program a  C many times Size of 1024 locations, 14 bits width Locations 0000h & 0004h are reserved for reset & interrupt vector, respectively The 1 st 1Kx14 (0000h-03FFh) are physically implemented address Accessing a location of physically implemented address will cause a wraparound
  • 34. MEMORY ORGANIZATION: Program Memory
  • 35. MEMORY ORGANIZATION: Data Memory Also known as file register: data storage, scratch pad & registers for internal use and functions Special Function Registers (SFR) - 8-bit wide - ALU status, timers, serial communication, I/O ports, ADC, & etc. - function of each SFR is fixed in design, used to control  C or peripheral - access either directly (names @ addresses) or indirectly (FSR – File Select Register) - classified into core and peripheral sets - control bits (RP1, RP0) in STATUS register are used for bank selection General Purpose Registers (GPR) - 8-bit wide - also called general purpose RAM (GP RAM) - used for data storage & scratch pad - accessed directly - addresses in Bank 0 & Bank 1 are mapped together Location of SFR and GPR vary from chip to chip, even among members of the same family
  • 37. SFR File Memory Legend: x = unknown, u = unchanged, - = unimplemented, read as '0', q = value depends on condition Note 1: The upper byte of the program counter is not directly accessible. PCLATH is a slave register for PC<12:8>. The contents of PCLATH can be transferred to the upper byte of the program counter, but the contents of PC<12:8> are never transferred to PCLATH. 2: The TO and PD status bits in the STATUS register are not affected by a MCLR Reset. 3: Other (non power-up) RESETS include: external RESET through MCLR and the Watchdog Timer Reset. 4: On any device RESET, these pins are configured as inputs. 5: This is the value that will be in the port output latch.
  • 38. Review True or false. Every member of the PIC16 family, regardless of the program ROM size, wakes up at memory 0000H when it is powered up. What is the main difference between the PIC16Fxxx and PIC16Cxxx  C? The GPR and SFR together are called ____. The SFR registers in PIC are ___-bit. The data memory in PIC16 is divided into ____-byte banks.
  • 39. Timer & Prescalar Establish relation between a real dimension such as “time” and a variable which represents status of a time within a microcontroller PIC16F84 has an 8-bit timer, whose its value is continually increasing to 255 and then it starts all over again: 0, 1, 2, 3, …, 255, 0, 1,… etc Prescaler divides oscillator clock before it reaches logic that increases timer status. The first three bits in OPTION register defines divisor 256 is the highest divisor, means timer clock would increase by one at every 256 th clock
  • 40. Timer & Prescalar Cont…
  • 41. Flash Memory Store permanent information on some palm-sized computers (operating system & core applications) Unlike RAM (random-access memory), flash memory can continue to store information in the absence of a power source. Unlike ROM (read-only memory), we can write/update to flash memory More expensive than ROM
  • 42. RAM Random-access memory The most common computer memory to perform necessary tasks while the computer is on An integrated circuit memory chip allows information to be stored or accessed in any order and all storage locations are equally accessible.
  • 43. ROM Read Only Memory Non-volatile: hold programs and data that must be retained even the computer is turned off data cannot be easily written to ROM; depending on the technology used in the ROM, writing may require special hardware, or may be impossible. A computer's BIOS may be stored in ROM.
  • 44. EEPROM Electrically Erasable Programmable Read Only Memory ROM that can be erased electronically and reprogrammed in-circuit (or with a device programmer). EEPROM is very similar to flash memory. The biggest difference is that the bytes (words) of an EEPROM can be erased individually.