SlideShare a Scribd company logo
PIC18 Microcontrollers -1
Introduction to Microcontroller
PIC18F4550
ARCHITECTURE
PIC18F4550
BLOCK
ARCHITECTURE
Components in PIC18 Microcontroller
 Arithmetic and Logic Unit (ALU),
 Working Register in PIC Microcontrollers,
 Machine Cycles and Execution of Instructions,
 Pipelining for Instruction Execution,
 Oscillators,
 Configuration Bits,
 Reset Options,
 Low Power Consumption Mode,
 Watchdog Timer,
 Program Counter,
 RISC, CISC
 Compare Harvard architecture with von Neumann architecture.
Main Characteristics of PIC Microcontrollers
 The ALU executes the arithmetic and logic operations available in the instruction
set.
Arithmetic and Logic Unit (ALU)
(a) ALU in microprocessors (b) ALU in microcontrollers
 STATUS or FLAG Register:
 The ALU also has bits to indicate specific characteristics of the resulting value, such as if the result is
zero, the sign of the resulting value, or the existence of carryover. These bits are normally part of the
STATUS register.
 Carry flag (D0 bit of status reg) =1 or else 0.
 Digital Carry from the 4th bit (D3) to the 5th bit (D4) after an arithmetic or logical operation the DC flag
(D1 bit of status reg) =1 or as 0.
 Result of any arithmetic or logical operation is a zero it is the zero flag (D2 bit of status reg) = 1 or else
0.
 Signed number exceeds the range (00-7F for positive numbers and FF-80 for negative numbers) then
the overflow (D3 bit of status reg) = 1 or else 0.
 D4 bit of the status register is Negative flag . If D7 bit is 1 then the result is interpreted as –ve and if
D7 bit is 0 then the result is interpreted as +ve .
Arithmetic and Logic Unit (ALU)
 WREG:
 8-bit Register, Same as ACC in Microprocessor
 In PIC microcontrollers, an operation’s result can be placed in the W register or any data memory
register.
Arithmetic and Logic Unit (ALU)
Sample program: add two 8 bit numbers:
ORG 0X00
GOTO START
START
MOVLW 0XFE
MOVWF 0X30
MOVLW 0X06
MOVWF 0X31
MOVF 0X30,W
ADDWF 0X31,W
MOVWF 0X32
END
 ALU is associated with two registers- WREG and status.
 Result may be stored in WREG register.
 Status register gives the status of the current
arithmetic and logical operation.
 One of the input to the ALU has to be the WREG
 A machine cycle (MC) is defined as four pulses from the main oscillator (OSC1).
 These signals synchronize fetching, decode, and execute of instructions. TMC is the
duration of a machine cycle
Machine Cycles and Execution of Instructions
 In the fetching phase, the microcontroller reads the instruction in the program
memory and brings it to the CPU.
 During the decoding phase, the CPU determines the operation to carry out as
described by the instruction.
 Finally, the operation is executed during the execution phase.
 Instructions are executed in one machine cycle.
Machine Cycles and Execution of Instructions
 Overlap two or more instructions as they are being executed. This introduces some
parallelism in the execution of instructions, thus reducing the required execution
time.
 In an n-stage pipeline, each instruction spends a time equal to TMC for any stage,
with TMC being the time length of a machine cycle. Therefore, the time needed to
move through all the stages is n × TMC. The average time to execute any instruction
is TMC.
 Some instructions, such as control transfer instructions, require additional machine
cycles, the average instruction execution time for these instructions is slightly longer
than TMC.
Pipelining for Instruction Execution
Pipelining for Instruction Execution
 Overlap two or more instructions as they are being executed. This introduces some
parallelism in the execution of instructions, thus reducing the required execution
time.
Pipelining for Instruction Execution
 The main oscillator in PIC microcontrollers can be a crystal oscillator, an RC oscillator,
or an external clock. Some devices also have an internal RC oscillator at 4 MHz.
Oscillators
 Increasing the oscillator frequency shortens the length of the machine cycles and
therefore the time needed for executing instructions but also increases power
consumption.
 The type of oscillator can be selected by the configuration bits.
 These also select specific modes of operation for crystal or ceramic oscillators: LP,
XT, and HS. The LP mode selects oscillator frequencies between 32 kHz and 200 kHz,
and is used in very low power-consumption applications. The XT mode selects
oscillator frequencies between 100 kHz and 4 MHz. The HS mode selects oscillator
frequencies between 8 MHz and 20 MHz.
 The RC oscillator is the least expensive option for the main oscillator in the
microcontroller. used when frequency accuracy and stability are not critical.
medium-end PIC.
Oscillators
Oscillator type Frequency range
LP 32khz to 200khz
XT 100khz-4Mhz
HS 8Mhz -20 Mhz
Oscillator or Resonator Start UP
 All PIC microcontrollers have specific bits for their configuration.
 stored in non-volatile memory (EEPROM) when the device is being programmed.
 microcontroller to better fit the intended application.
 Configuration bits can modify
• Type of oscillator
• Watchdog timer on or off
• Program memory protection
• Protection of EEPROM data if available
• Specifications for reset and power supply
 Configuration bits in a medium-end PIC make up a word stored in address 2007h in
program memory. This address is only accessible during the programming of the
microcontroller. Once the program is executed, it cannot access this address.
Configuration Bits
 the microcontroller is temporarily paralyzed and not executing any program
instructions. Following this transient state, the device moves to a predetermined
state.
 In PIC microcontrollers, reset sets the program counter to zero. After the reset has
finished, the first instruction executed is the one located at this memory address.
 most PIC microcontrollers Reset Sources :
• External reset - An external reset occurs when the pin MCLR# is set to 0
• Power-on reset - MCLR# is connected to the microcontroller’s power supply.
detects the triggering of VDD it creates a reset signal.
• Watchdog reset - Program running in the microcontroller cannot clear the internal
counter of the watchdog time before reaching its maximum value. regular working
mode or when it is in the low-power consumption mode.
• Brown-out reset - transient or glitch in the voltage (VDD).
Reset Options
Fig: Reset signal due to brown-out in several situations. The timer PWRT
guarantees that VDD will be at its nominal value once it leaves the reset state.
 this circuit needs to guarantee that the microcontroller will only leave the reset
state if the voltage has reached a stable and high enough value. This is the task of
the blocks associated with the VDD signal.
Reset Options
 The OST/PWRT, oscillator start-up timer (OST), and power-up timer (PWRT). It takes
a certain amount of time for the main oscillator to reach stable values for its
frequency and amplitude after it has been turned on.
 power-up timer (PWRT): An internal RC oscillator, independent of the main
oscillator, introduces a 72 ms delay to the signal PWRT after the oscillator has been
powered. ]
 oscillator start-up timer (OST): The OST introduces an additional delay of 1024
pulses. This delay is long enough for the oscillator to reach stable amplitude and
frequency values. The OST starts its operation only after the PWRT has reached its
maximum value.
Reset Options
Figure: Time diagrams showing the sequence of signals
associated with the OST/PWRT block. (a)
Power-on reset—MCLR# pin connected to VDD
Reset Options
Figure: Reset signal due to brown-out in several situations. The
timer PWRT guarantees that VDD will be at its nominal value
once it leaves the reset state.
 Special function registers such as STATUS and PCON. register STATUS in which the bit
TO# is set to 0 when the watchdog timer produces a reset.
Reset Options
Figure: Two bits in the special function registry PCON in
PIC18F4550 are used to determine the origin of a reset
signal.
 Power consumed less than 1 μA, In low-power consumption mode (sleep mode) all
functions are stopped including oscillator.
 The instruction sleep, values stored in the data memory registers are not changed.
 The microcontroller will wake up leaving the low-consumption mode in any of these three
events:
• Reset
• Overflow of watchdog timer counter (if not disabled)
• Interrupt, either external or from its internal peripherals
 instruction after sleep has already entered the CPU, this same instruction will be executed
once the microcontroller wakes up.
 Reset - it will execute the instruction stored at address 0 in the program memory.
 Watchdog timer - it will continue running the program, executing the instruction after the
sleep instruction.
 External interrupt with the interrupt system enabled - it will execute the instruction
immediately after the sleep instruction, and then the program counter will jump to address
4 in the program memory searching for the interrupt routine.
Low-Power Consumption Mode
Low-Power Consumption Mode
• The interrupt system can be enabled or disabled by modifying the
global interrupt enable (GIE) bit.
• GIE = 1 the interrupt system is enabled;
• GIE = 0 it is disabled.
• GIE is bit number 7 in the special function register INTCON.
 Pulse counter, Timer, Internal Oscillator.
 If the pulse counter reaches its maximum value (overflows) -- the WDT times out --
generates a reset signal for the microcontroller.
Watchdog Timer
Figure: Block diagram of the circuits associated with a watchdog timer in medium-
end PICs. PSA and PS2:PS0 are bits from the special function registry OPTION. WDTE
is the configuration bit that enables the watchdog timer.
 Once the program is running normally, the WDT cannot be disabled.
 The WDT times out every 18 ms. to avoid the WDT timing out and generating the
reset signal for the microcontroller, the internal pulse counter needs to be set to 0
before the 18 ms have elapsed. The instruction clrwdt is used for this purpose. It is
possible to extend the 18 ms timeout up to 2.3 s by assigning an additional counter
to the WDT. This counter is called Prescaler.
Watchdog Timer
 The program counter is used by the CPU to point to the address in ROM of the next
instruction to be executed.
 As the CPU fetches the opcode from the program ROM, the program counter is
incremented automatically to point to the next instruction.
 The wider the program counter, more the memory locations.
14-bit program counter - (214 = 16K) of code - addresses 0000-3FFFH – PIC 16F
16-bit program counter - (216 = 64K) of code
21-bit program counter - (221 = 2M) of code in ROM
PIC 18 family can access program HEX addresses
000000 to IFFFFFH
0 0000 0000 0000 0000 B – Min Address
1 1111 1111 1111 1111 B – Max Address
 PCL is readable and writable while PCH and PCU are not directly readable or writable.
 Updates to PCH and PCU are provided by PCLATH and PCLATU registers resp.
Program counter in the PIC – 21 bit – 2 MB
Program ROM in the PIC
 Each location 1 byte or
8 bits
Program memory (ROM) for PIC18 family
[1] Fernando E. Valdes-Perez, Ramon Pallas-Areny, “Microcontrollers - Fundamentals and Applications with PIC”, CRC Press, 1st Edition, 2009
[2] Mazidi M. A., McKinlay R. D., Causey D., “PIC Microcontroller And Embedded Systems.”, Pearson Education International, 2008
[3] https://ww1.microchip.com/downloads/en/devicedoc/39632c.pdf

More Related Content

Similar to Lecture on PIC-1.pptx

Pic full note
Pic full notePic full note
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)
Sahil Gupta
 
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
MeghdeepSingh
 
Computer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationComputer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organization
AmrutaMehata
 
conrol_Unit_part_of_computer_architecture.pptx
conrol_Unit_part_of_computer_architecture.pptxconrol_Unit_part_of_computer_architecture.pptx
conrol_Unit_part_of_computer_architecture.pptx
jbri1395
 
n5acb0f1c011fb.pdf
n5acb0f1c011fb.pdfn5acb0f1c011fb.pdf
n5acb0f1c011fb.pdf
sharathkumar299627
 
Overview of LPC213x MCUs
Overview of LPC213x MCUsOverview of LPC213x MCUs
Overview of LPC213x MCUs
Premier Farnell
 
Ajal mod 1
Ajal mod 1Ajal mod 1
Ajal mod 1
AJAL A J
 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
vlkumashankardeekshi th
 
embedded system
embedded systemembedded system
embedded system
Vivek Ranjan
 
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summaryAtmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Rajan Gautam
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
Ankita Tiwari
 
ESD III UNIT.pptx
ESD III UNIT.pptxESD III UNIT.pptx
ESD III UNIT.pptx
ECEHOD19
 
UNIT-IV.ppt
UNIT-IV.pptUNIT-IV.ppt
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller
pavihari
 
EE6008 MBSD
EE6008  MBSDEE6008  MBSD
EE6008 MBSD
rmkceteee
 
Control Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitControl Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unit
abdosaidgkv
 
Atmega8u2 mur
Atmega8u2 murAtmega8u2 mur
Atmega8u2 mur
Nickyhoney
 

Similar to Lecture on PIC-1.pptx (20)

Pic full note
Pic full notePic full note
Pic full note
 
8051 microcontroller and embedded training (sahil gupta 9068557926)
8051 microcontroller and embedded training  (sahil gupta   9068557926)8051 microcontroller and embedded training  (sahil gupta   9068557926)
8051 microcontroller and embedded training (sahil gupta 9068557926)
 
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
 
Computer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organizationComputer Organization : CPU, Memory and I/O organization
Computer Organization : CPU, Memory and I/O organization
 
conrol_Unit_part_of_computer_architecture.pptx
conrol_Unit_part_of_computer_architecture.pptxconrol_Unit_part_of_computer_architecture.pptx
conrol_Unit_part_of_computer_architecture.pptx
 
n5acb0f1c011fb.pdf
n5acb0f1c011fb.pdfn5acb0f1c011fb.pdf
n5acb0f1c011fb.pdf
 
Overview of LPC213x MCUs
Overview of LPC213x MCUsOverview of LPC213x MCUs
Overview of LPC213x MCUs
 
Ajal mod 1
Ajal mod 1Ajal mod 1
Ajal mod 1
 
PLC.pdf
PLC.pdfPLC.pdf
PLC.pdf
 
Ee6008 mcbsd notes
Ee6008 mcbsd notesEe6008 mcbsd notes
Ee6008 mcbsd notes
 
embedded system
embedded systemembedded system
embedded system
 
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summaryAtmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
Atmel 42735-8-bit-avr-microcontroller-a tmega328-328-p_summary
 
PIC Introduction and explained in detailed
PIC Introduction and explained in detailedPIC Introduction and explained in detailed
PIC Introduction and explained in detailed
 
ESD III UNIT.pptx
ESD III UNIT.pptxESD III UNIT.pptx
ESD III UNIT.pptx
 
UNIT-IV.ppt
UNIT-IV.pptUNIT-IV.ppt
UNIT-IV.ppt
 
EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller EE6008 MCBSD - Introduction to PIC Micro controller
EE6008 MCBSD - Introduction to PIC Micro controller
 
EE6008 MBSD
EE6008  MBSDEE6008  MBSD
EE6008 MBSD
 
Control Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitControl Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unit
 
Atmega8u2 mur
Atmega8u2 murAtmega8u2 mur
Atmega8u2 mur
 
Basic plc
Basic plcBasic plc
Basic plc
 

Recently uploaded

Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
top1002
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 

Recently uploaded (20)

Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
Basic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparelBasic Industrial Engineering terms for apparel
Basic Industrial Engineering terms for apparel
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 

Lecture on PIC-1.pptx

  • 4. Components in PIC18 Microcontroller
  • 5.  Arithmetic and Logic Unit (ALU),  Working Register in PIC Microcontrollers,  Machine Cycles and Execution of Instructions,  Pipelining for Instruction Execution,  Oscillators,  Configuration Bits,  Reset Options,  Low Power Consumption Mode,  Watchdog Timer,  Program Counter,  RISC, CISC  Compare Harvard architecture with von Neumann architecture. Main Characteristics of PIC Microcontrollers
  • 6.  The ALU executes the arithmetic and logic operations available in the instruction set. Arithmetic and Logic Unit (ALU) (a) ALU in microprocessors (b) ALU in microcontrollers
  • 7.  STATUS or FLAG Register:  The ALU also has bits to indicate specific characteristics of the resulting value, such as if the result is zero, the sign of the resulting value, or the existence of carryover. These bits are normally part of the STATUS register.  Carry flag (D0 bit of status reg) =1 or else 0.  Digital Carry from the 4th bit (D3) to the 5th bit (D4) after an arithmetic or logical operation the DC flag (D1 bit of status reg) =1 or as 0.  Result of any arithmetic or logical operation is a zero it is the zero flag (D2 bit of status reg) = 1 or else 0.  Signed number exceeds the range (00-7F for positive numbers and FF-80 for negative numbers) then the overflow (D3 bit of status reg) = 1 or else 0.  D4 bit of the status register is Negative flag . If D7 bit is 1 then the result is interpreted as –ve and if D7 bit is 0 then the result is interpreted as +ve . Arithmetic and Logic Unit (ALU)
  • 8.  WREG:  8-bit Register, Same as ACC in Microprocessor  In PIC microcontrollers, an operation’s result can be placed in the W register or any data memory register. Arithmetic and Logic Unit (ALU) Sample program: add two 8 bit numbers: ORG 0X00 GOTO START START MOVLW 0XFE MOVWF 0X30 MOVLW 0X06 MOVWF 0X31 MOVF 0X30,W ADDWF 0X31,W MOVWF 0X32 END  ALU is associated with two registers- WREG and status.  Result may be stored in WREG register.  Status register gives the status of the current arithmetic and logical operation.  One of the input to the ALU has to be the WREG
  • 9.  A machine cycle (MC) is defined as four pulses from the main oscillator (OSC1).  These signals synchronize fetching, decode, and execute of instructions. TMC is the duration of a machine cycle Machine Cycles and Execution of Instructions
  • 10.  In the fetching phase, the microcontroller reads the instruction in the program memory and brings it to the CPU.  During the decoding phase, the CPU determines the operation to carry out as described by the instruction.  Finally, the operation is executed during the execution phase.  Instructions are executed in one machine cycle. Machine Cycles and Execution of Instructions
  • 11.  Overlap two or more instructions as they are being executed. This introduces some parallelism in the execution of instructions, thus reducing the required execution time.  In an n-stage pipeline, each instruction spends a time equal to TMC for any stage, with TMC being the time length of a machine cycle. Therefore, the time needed to move through all the stages is n × TMC. The average time to execute any instruction is TMC.  Some instructions, such as control transfer instructions, require additional machine cycles, the average instruction execution time for these instructions is slightly longer than TMC. Pipelining for Instruction Execution
  • 13.  Overlap two or more instructions as they are being executed. This introduces some parallelism in the execution of instructions, thus reducing the required execution time. Pipelining for Instruction Execution
  • 14.  The main oscillator in PIC microcontrollers can be a crystal oscillator, an RC oscillator, or an external clock. Some devices also have an internal RC oscillator at 4 MHz. Oscillators
  • 15.  Increasing the oscillator frequency shortens the length of the machine cycles and therefore the time needed for executing instructions but also increases power consumption.  The type of oscillator can be selected by the configuration bits.  These also select specific modes of operation for crystal or ceramic oscillators: LP, XT, and HS. The LP mode selects oscillator frequencies between 32 kHz and 200 kHz, and is used in very low power-consumption applications. The XT mode selects oscillator frequencies between 100 kHz and 4 MHz. The HS mode selects oscillator frequencies between 8 MHz and 20 MHz.  The RC oscillator is the least expensive option for the main oscillator in the microcontroller. used when frequency accuracy and stability are not critical. medium-end PIC. Oscillators Oscillator type Frequency range LP 32khz to 200khz XT 100khz-4Mhz HS 8Mhz -20 Mhz
  • 17.  All PIC microcontrollers have specific bits for their configuration.  stored in non-volatile memory (EEPROM) when the device is being programmed.  microcontroller to better fit the intended application.  Configuration bits can modify • Type of oscillator • Watchdog timer on or off • Program memory protection • Protection of EEPROM data if available • Specifications for reset and power supply  Configuration bits in a medium-end PIC make up a word stored in address 2007h in program memory. This address is only accessible during the programming of the microcontroller. Once the program is executed, it cannot access this address. Configuration Bits
  • 18.
  • 19.
  • 20.  the microcontroller is temporarily paralyzed and not executing any program instructions. Following this transient state, the device moves to a predetermined state.  In PIC microcontrollers, reset sets the program counter to zero. After the reset has finished, the first instruction executed is the one located at this memory address.  most PIC microcontrollers Reset Sources : • External reset - An external reset occurs when the pin MCLR# is set to 0 • Power-on reset - MCLR# is connected to the microcontroller’s power supply. detects the triggering of VDD it creates a reset signal. • Watchdog reset - Program running in the microcontroller cannot clear the internal counter of the watchdog time before reaching its maximum value. regular working mode or when it is in the low-power consumption mode. • Brown-out reset - transient or glitch in the voltage (VDD). Reset Options Fig: Reset signal due to brown-out in several situations. The timer PWRT guarantees that VDD will be at its nominal value once it leaves the reset state.
  • 21.  this circuit needs to guarantee that the microcontroller will only leave the reset state if the voltage has reached a stable and high enough value. This is the task of the blocks associated with the VDD signal. Reset Options
  • 22.  The OST/PWRT, oscillator start-up timer (OST), and power-up timer (PWRT). It takes a certain amount of time for the main oscillator to reach stable values for its frequency and amplitude after it has been turned on.  power-up timer (PWRT): An internal RC oscillator, independent of the main oscillator, introduces a 72 ms delay to the signal PWRT after the oscillator has been powered. ]  oscillator start-up timer (OST): The OST introduces an additional delay of 1024 pulses. This delay is long enough for the oscillator to reach stable amplitude and frequency values. The OST starts its operation only after the PWRT has reached its maximum value. Reset Options Figure: Time diagrams showing the sequence of signals associated with the OST/PWRT block. (a) Power-on reset—MCLR# pin connected to VDD
  • 23. Reset Options Figure: Reset signal due to brown-out in several situations. The timer PWRT guarantees that VDD will be at its nominal value once it leaves the reset state.
  • 24.  Special function registers such as STATUS and PCON. register STATUS in which the bit TO# is set to 0 when the watchdog timer produces a reset. Reset Options Figure: Two bits in the special function registry PCON in PIC18F4550 are used to determine the origin of a reset signal.
  • 25.  Power consumed less than 1 μA, In low-power consumption mode (sleep mode) all functions are stopped including oscillator.  The instruction sleep, values stored in the data memory registers are not changed.  The microcontroller will wake up leaving the low-consumption mode in any of these three events: • Reset • Overflow of watchdog timer counter (if not disabled) • Interrupt, either external or from its internal peripherals  instruction after sleep has already entered the CPU, this same instruction will be executed once the microcontroller wakes up.  Reset - it will execute the instruction stored at address 0 in the program memory.  Watchdog timer - it will continue running the program, executing the instruction after the sleep instruction.  External interrupt with the interrupt system enabled - it will execute the instruction immediately after the sleep instruction, and then the program counter will jump to address 4 in the program memory searching for the interrupt routine. Low-Power Consumption Mode
  • 26. Low-Power Consumption Mode • The interrupt system can be enabled or disabled by modifying the global interrupt enable (GIE) bit. • GIE = 1 the interrupt system is enabled; • GIE = 0 it is disabled. • GIE is bit number 7 in the special function register INTCON.
  • 27.  Pulse counter, Timer, Internal Oscillator.  If the pulse counter reaches its maximum value (overflows) -- the WDT times out -- generates a reset signal for the microcontroller. Watchdog Timer Figure: Block diagram of the circuits associated with a watchdog timer in medium- end PICs. PSA and PS2:PS0 are bits from the special function registry OPTION. WDTE is the configuration bit that enables the watchdog timer.
  • 28.  Once the program is running normally, the WDT cannot be disabled.  The WDT times out every 18 ms. to avoid the WDT timing out and generating the reset signal for the microcontroller, the internal pulse counter needs to be set to 0 before the 18 ms have elapsed. The instruction clrwdt is used for this purpose. It is possible to extend the 18 ms timeout up to 2.3 s by assigning an additional counter to the WDT. This counter is called Prescaler. Watchdog Timer
  • 29.  The program counter is used by the CPU to point to the address in ROM of the next instruction to be executed.  As the CPU fetches the opcode from the program ROM, the program counter is incremented automatically to point to the next instruction.  The wider the program counter, more the memory locations. 14-bit program counter - (214 = 16K) of code - addresses 0000-3FFFH – PIC 16F 16-bit program counter - (216 = 64K) of code 21-bit program counter - (221 = 2M) of code in ROM PIC 18 family can access program HEX addresses 000000 to IFFFFFH 0 0000 0000 0000 0000 B – Min Address 1 1111 1111 1111 1111 B – Max Address  PCL is readable and writable while PCH and PCU are not directly readable or writable.  Updates to PCH and PCU are provided by PCLATH and PCLATU registers resp. Program counter in the PIC – 21 bit – 2 MB
  • 30. Program ROM in the PIC  Each location 1 byte or 8 bits
  • 31.
  • 32. Program memory (ROM) for PIC18 family [1] Fernando E. Valdes-Perez, Ramon Pallas-Areny, “Microcontrollers - Fundamentals and Applications with PIC”, CRC Press, 1st Edition, 2009 [2] Mazidi M. A., McKinlay R. D., Causey D., “PIC Microcontroller And Embedded Systems.”, Pearson Education International, 2008 [3] https://ww1.microchip.com/downloads/en/devicedoc/39632c.pdf