Processor Architecture 2
Processor Architecture 2
UNIT I
PIC MICROCONTROLLER
ARCHITECTURE
PRESENT BY :-
Sr.no Student Name Roll.no
PIC18FXXX:
Features and architecture, comparison of PIC 18 series microcontrollers; PIC18F458/452 Pin out
connection, Registers of PIC18F.
Addressing modes:
Addressing modes with instruction example, Oscillator configurations, Reset operations,
Brownout reset, Watchdog timer, Power down modes & Configuration registers
INTRODUCTION
MICROPROCESSOR :
A microprocessor is a computer processor for which the data processing logic and control is included on a single
integrated circuit (IC), or a small number of ICs.
The microprocessor contains the arithmetic, logic, and control circuitry required to perform the functions of a
computer's central processing unit (CPU).
COMPONENTS OF
MICROPROCESSOR:
2). Bus: Connection lines used to connect the internal parts of the microprocessor chip is called bus.
There are three types of buses in a microprocessor −
• Data Bus − Data Bus carries data to and from memory are called data bus. It is a bidirectional bus.
• Address Bus − It is a unidirectional Bus. It carryies address of a memory location or I/O port.
• Control Bus − It is used to carry control signals. like clock signals, interrupt signal or ready signal are called control
bus.
The microcontroller is essentially a simple mini-computer embedded on a single integrated chip, it requires many
of the same basic components as a larger and more complex computer.
A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system.
A typical microcontroller includes a processor, memory and input/output (I/O) peripherals on a single chip.
COMPONENTS OF
MICROCONTROLLER:
• The first computer system on a chip optimized for control applications micro - controller was the Intel 8048 released
in 1976, with both RAM and ROM on the same chip.
• Most microcontrollers at this time had two variants. One had an erasable EEPROM program memory, which was
significantly more expensive than the PROM variantwhich was only programmable once.
• The Evolution of Microcontrollers has undergone a significant change.
1980 8031 128 bytes RAM, Two 16-bit timers, One serial port and I/O
ports.
1980 Intel 8051 128 bytes RAM, 4 kB ROM, Two 16-bit timers, One serial port
and I/O ports.
1984 Atmel 89C51 128 bytes RAM, 4 kB ROM, Two 16-bit timers, One serial port
and I/O ports.
1985 Motorola 68HV11A8 256 bytes RAM, 8 kB ROM, 512 bytes EEPROM, 16-bit timer; 8
channel 8-bit A/D, SCI, SPI and I/O ports.
HISTORY OF MICROCONTROLLERS :
1. Intel Corporation developed the first microcontroller, the 4-bit i4004, in 1971 for BUSICOM's calculators.
2. The i4004's success led Intel to develop subsequent microcontrollers, including the 16-bit 8086, paving the way for
CPUs in personal computers.
3. Toshiba introduced the 12-bit TLCS-12 microcontroller in 1973, initially used as Ford's in-vehicle engine controller.
4. Intel's 8048, a system-on-a-chip optimized for control applications, became highly successful and found its way into
over a billion PC keyboards.
5. Erasable microcontrollers with EPROM program memory were more expensive due to ceramic packages and quartz
windows.
6. In 1993, EEPROM memory was introduced, allowing for quick electrical erasure without expensive packaging,
facilitating rapid prototyping.
7. Atmel introduced the first microcontroller with Flash memory in 1993, leading to the adoption of this memory type
in the industry.
DIFFERENCE BETWEEN MICROPROCESSOR AND MICROCONTROLLER :
Parameter Microprocessor Microcontroller
Microprocessors can be understood as the Microcontrollers can be understood as
Definition heart of a computer system. the heart of an embedded system.
A microprocessor is a processor where the A microcontroller is a controlling device
What is it? memory and I/O component are wherein the memory and I/O output
connected externally. component are present internally.
The circuit is complex due to external Microcontrollers are present on chip
Circuit complexity connection. memory. The circuit is less complex.
The memory and I/O components are to The memory and I/O components are
Memory and I/O components be connected externally. available.
Microprocessors can’t be used in compact Microcontrollers can be used with a
Compact system compatibility system. compact system.
Efficiency Microprocessors are not efficient. Microcontrollers are efficient.
Microprocessors have a zero status flag. Microcontroller doesn’t have a zero
Zero status flag status flag.
Microprocessors have less number of Microcontrollers have more number of
Number of registers registers. registers.
Microprocessors are generally used in Microcontrollers are generally used in
Applications personal computers. washing machines, and air conditioners.
CRITERIA FOR SELECTION OF MICROCONTROLLER :
System Requirement:
• Begin with application needs.
• Decide on 4-bit, 8-bit, 16-bit, or 32-bit microcontroller based on processing power requirements.
• 8-bit microcontrollers are popular for embedded applications due to availability and long-standing technology.
Memory Architecture:
• CoOn-chip or off-chip memory and size impact system cost and operation speed.
Availability:
• Check device nsider program memory (Flash, OTP, ROM), data memory (on-chip SRAM or external SDRAM), and
nonvolatile memory (EEPROM or Flash).
• availability in needed quantities for current and future use.
Size:
• Select an IC with the appropriate number of I/O pins to minimize size and physical space.
Compatibility:
• Ensure pin and function compatibility for easy system upgrades.
Functionality Testing:
• Test MCU function within the designed circuit before system development.
Power Management:
• Consider power consumption for battery life and heat dissipation.
• Evaluate power-down, idle, and sleep modes in microcontrollers.
Manufacturer's Support:
• Look for manufacturers with effective support through helplines, knowledgeable personnel, and after-sales
assistance.
Development Support:
• Consider development tools like assemblers, debuggers, C compilers, and emulators.
• Integrated Development Environments (IDEs) like Keil uVision or MPLAB are crucial.
Cost:
• Minimize costs by tactfully selecting components and optimizing features.
• ROM-based devices are preferred for high volume applications due to lower cost and code security.
PIC18FXXX
PIC MICROCONTROLLER INTRODUCTION :
It’s the popular line of microcontroller that is currently manufactured by Microchip Technology Inc.
The PIC microcontroller was introduced in 1993 by Microchip although the original chip design was created by General
Instruments in 1985. PIC microcontrollers are meant to enable simple programming and interfacing in embedded
system design.
Most of the PIC microcontrollers that hit the market are 8-bits microcontrollers, although Microchip did introduce some
16-bits and 32-bits PIC microcontrollers.
3. Register file architecture: The register files/data memory can be directly or indirectly addressed. All special function
registers, including the program counter, are mapped in the data memory.
Instruction set simplicity
8. Brown-out reset: PIC has a brown-out-reset. A brown-out-reset feature causes a reset of the PIC when the power
supply voltage drops below 4 V or so.
9. Watchdog Timer (WDT) : Watchdog timer is a special timer with specific function. It is used to prevent software
crashes, i.e. endless loop.
10. Power saving SLEEP mode: The PIC can put itself to sleep to save power during intervals when it has nothing to do.
Thus, PIC supr saving SLEEP mode.
12. Interrupt Control : The PIC can control up to 12 independent interrupt sources.
ALU is used for arithmetic operations and for logical decisions. Memory is used for storing the
instructions after processing. Control unit is used to control the internal and external peripherals which
are connected to the CPU and accumulator is used for storing the results.
2.MEMORY ORGANIZATION:
•PROGRAM MEMORY:
It contains the written program after we burned it in microcontroller. Program Counter executes
commands stored in the program memory, one after the other. Pic microcontroller can have 8K words
x 14 bits of Flash program memory that can be electrically erased and reprogrammed. Whenever we
burn program into the micro, we erase an old program and write a new one
•DATA MEMORY:
It is a RAM type which is used to store the data temporarily in its registers. The RAM memory is
classified into banks. Each bank extends up to 7Fh (128 bytes). Number of banks may vary depending
on the microcontroller. PIC16F84 has only two banks. Banks contain Special Function Registers (SFR)
and General Purpose Registers (GPR). The lower locations of each bank are reserved for the Special
Function Registers and upper locations are for General Purpose Registers.
These registers don’t have any special function. These are used for general purpose for multiplying,
addition or subtraction and then storing the results in other registers. CPU can easily access the data in
these registers.
This memory allows storing the variables as a result of burning the written program. It is readable and
writable during normal operation (over the full VDD range). This memory is not directly mapped in the
register file. It is indirectly addressed through the SFRs. There are six SFRs which are used to read and
write to this memory (EECON1, EECON2, EEDATA, EEDATH, EEADR, EEADRH).
3.SERIAL COMMUNICATION:
The transfer of one bit of data at time consecutively over a communication channel is called Serial
Communication. There are three protocols of serial communication:
•USART:
It stands for Universal synchronous and Asynchronous Receiver and Transmitter which provides a
serial communication in two devices. In this protocol data is transmitted and received bit by bit
through a single wire according to the clock pulses. To send and receive data serially the PIC
microcontroller has two pins TXD and RXD
SPI Protocol:
SPI stands for Serial Peripheral Interface. It is used to send data between PIC microcontrollers and
other peripherals like sensors, shift registers and SD cards. Three wire SPI communications is supported
in PIC microcontroller between two devices on a common clock source. SPI protocol has greater data
handling capability than that of the USART.
I2C Protocol:
I2C stands for Inter Integrated Circuit, and this protocol is used to connect low speed devices like
microcontrollers, EEPROMS and A/D converters. PIC microcontroller support two wire Interface or I2C
communication between two devices which can work as both Master and Slave device.
Serial Communication
4.INTERRUPTS:
There are 20 internal interrupts and three external interrupt sources in PIC microcontrollers which are
related with different peripherals like ADC, USART, Timers, and CCP etc.
5.I/O PORTS:
Let us take PIC16 series, it consists of five ports, such as Port A, Port B, Port C, Port D and Port E.
•Port A:This port is 7-bit wide and can be used for both input and output. The status of TRISA register
decided whether it is used as input or output port.
•Port B:It is an 8-bit port. This port also can be used as input and output. Moreover in input mode four of
its bits are variable according to the interrupt signals.
•Port C:It is also an 8-bit port and can be used as both input and output port which is determined by the
status of the TRISC register.
•Port D:This 8-bit port, unlike Port A, B and C is not an input/output port, but is used as acts as a slave
port for the connection to the microprocessor When in I/O mode Port D all pins should have Schmitt
Trigger buffers.
•Port E:It is a 3-bit port which is used as the additional feature of the control signals to the A/D converter.
6. CCP MODULE:
•Capture Mode: In this mode time is captured when a signal is arrived, or we can say that, when the
CCP pin goes high it captures the value of the Timer1.
•Compare Mode: It works same as an analog comparator, which means that when timer 1’s value
reaches some reference value it will give an output signal.
•PWM Mode: This mode provides a 10 bit resolution pulse and duty cycle that is programmable.
7.Timers:
Timers and counters are important as timers can tell the time and count. PIC microcontroller can have
up to four timers (depending upon the family) Timer0, Timer1, Timer2 and Timer3. Timer0 and Timer2
are of 8-bits while the Timer1 and Timer3 are of 16-bits, which can also be used as a counter. These
timers work according to the selected modes.
8.D/A CONVERTER:
There are no analog outputs in PIC Microcontroller. To get analog output we have to use external
Digital-to-Analog Converter (DAC). It can convert 8 bits of digital number from the eight digital outputs of
PIC microcontroller.
9.A/D CONVERTER:
It converts the analog voltage levels to digital voltage values. In PIC Microcontroller, ADC has 8-channels
and has resolution of 10-bit, which means that if we have to convert an analog voltage between 0V to 5V
the converter will divide it to 2^10 levels (1024 levels). The special function registers ADCON0 and
ADCON1 control the operation of ADC. The converter stores the lower 8 bits in ADRESL register and the
upper bits in the ADRESH register. Reference voltage of 5V is required for the operation of the converter.
comparison of PIC 18 series microcontrollers :
PIC18F458/452 PINOUT CONNECTION :
PIC18F452 PIC
Microcontroller
PIC18F452
PIC18F452 PIN CONFIGURATION :
Pin Number Pin Name Description
1 MCLR/VPP Master Clear (input) or High voltage ICSP programming enable pin mainly used for
programming purposes.
4 RA2/AN2/VREF- Bidirectional I/O pin of Port A bit 2 or Analog input 2 or A/D Reference (Low)
Voltage.
5 RA3/AN3/VREF+ Bidirectional I/O pin of Port A bit 3 or Analog input 3 or A/D Reference (High)
Voltage.
6 RA4/T0CKI Bidirectional I/O pin of Port A bit 4 or Timer 0 external clock input.
7 RA5/AN4/SS/LVDIN Bidirectional I/O pin of Port A bit 5 or Analog input 4 or SPI Slave Select input or
Low voltage Detect input.
8 RE0/RD/AN5 Bidirectional I/O pin of Port E bit 0 or Read control for parallel slave port or Analog
input 5
9 RE1/WR/AN6 Bidirectional I/O pin of Port E bit 1 or Write control for parallel slave port
or Analog input 6
10 RE2/CS/AN7 Bidirectional I/O pin of Port E bit 2 or Chip select control for parallel slave
port or Analog input 7.
14 OSC2/CLKO/RA6 Bidirectional I/O pin of Port A bit 6 or Oscillator crystal or clock output.
15 RC0/T1OSO/T1CKI Bidirectional I/O pin of Port C bit 0 or Timer 1 Oscillator output or Timer
1/Timer 3 external clock input.
16 RC1/T1OSI/CCP2 Bidirectional I/O pin of Port C bit 1 or Timer 1 Oscillator input or Capture 2
input, Capture 2 output, PWM 2 output.
17 RC2/CCP1 Bidirectional I/O pin of Port C bit 2 or Capture 1 input, Capture1 output,
PWM1 output
18 RC3/SCK/SCL Bidirectional I/O pin of Port C bit 3 or Synchronous serial clock input/output
for SPI mode or Synchronous serial clock input/output for 12C mode.
19 RD0/PSP0 Bidirectional I/O pin of Port D bit 0 or Parallel slave Port Data
20 RD1/PSP1 Bidirectional I/O pin of Port D bit 1 or Parallel slave Port Data.
21 RD2/PSP2 Bidirectional I/O pin of Port D bit 2 or Parallel slave Port Data
22 RD3/PSP3 Bidirectional I/O pin of Port D bit 3 or Parallel slave Port Data
23 RC4/SDI/SDA Bidirectional I/O pin of Port C bit 4 or SPI Data In or 12C data I/O.
28 RD5/PSP5 Bidirectional I/O pin of Port D bit 5 or Parallel slave Port Data
29 RD6/PSP6 Bidirectional I/O pin of Port D bit 6 or Parallel slave Port Data
30 RD7/PSP7 Bidirectional I/O pin of Port D bit 7 or Parallel slave Port Data
36 RB3/CCP2 Bidirectional I/O pin of Port B bit 3 or Capture 2 input, Compare 2 output,
PWM 2 output.
37 RB4 Bidirectional I/O pin of Port B bit 4 with IOC (Interrupt-on-change)
38 RB5/PGN Bidirectional I/O pin of Port B bit 5 with IOC (Interrupt-on-change) or Low
Voltage ICSP programming enable pin
39 RB6/PG Bidirectional I/O pin of Port B bit 6 with IOC (Interrupt-on-change) or In-
Circuit Debugger and ICSP programming clock pin.
40 RB7/PGD Bidirectional I/O pin of Port B bit 7 with IOC (Interrupt-on-change) or In-
Circuit Debugger and ICSP programming data pin
REGISTERS OF PIC18F :
The PIC18F microcontroller family has several types of registers that are used to control the operation of the device.
Here are some of the main registers:
Control Registers:
These registers control the operation of the microcontroller itself. For example, the Program Counter (PC) register
contains the address of the next instruction to be executed, while the Status register contains flags that indicate the
outcome of the most recent operation.
File Registers:
These are the most used registers in the PIC18F microcontroller. They are used to store data values, control flags, and other
information that is needed during program execution.
1. W register: This register is a temporary storage location used for arithmetic and logic operations.
2. BSR register: This register is used to select the bank of GPRs that will be accessed.
3. FSR register: This register is used to select the memory bank that will be accessed when reading or writing to memory.
Timer Registers:
The PIC18F has several timer registers, such as TMRO, TMR1, TMR2, and TMR3. These registers can be used for measuring
time intervals or generating timing signals.
Interrupt Registers:
These registers are used to enable and disable interrupts and to indicate the source of an interrupt.
Configuration Registers:
These registers are used to configure various settings of the microcontroller, such as clock frequency, oscillator type, and
other hardware parameters.
ADC registers:
The PIC18F has an Analog-to-Digital Converter (ADC) module, which has several registers for configuring and controlling the
ADC.
PROGRAM AND DATA MEMORY ORGANIZATION:
PIC microcontrollers have a Harvard architecture, which means they have separate memory spaces for program
memory and data memory.
Program memory: also known as Flash memory, is used to store the code that the microcontroller executes. It is non-
volatile, which means that the code remains in memory even when power is removed. The size of the program memory
varies depending on the specific PIC microcontroller, but it typically ranges from a few kilobytes to a few megabytes.
Data memory: on the other hand, is used to store data that the program manipulates during execution. There are
several types of data memory in a PIC microcontroller, including:
• RAM (Random Access Memory): This is volatile memory that is used to store data that is frequently accessed or
modified during program execution. The size of RAM also varies depending on the specific PIC microcontroller, but it
typically ranges from a few hundred bytes to a few kilobytes.
• EEPROM (Electrically Erasable Programmable Read-Only Memory): This is non- volatile memory that is used to
store data that needs to be retained even when power is removed, EEPROM memory is typically smaller than
program memory and RAM.
• Special Function Registers (SFRs): These are memory locations that are used to control the behaviour of the
microcontroller's peripherals, such as timers, interrupts, and input/output ports.
THE PROGRAM COUNTER IN THE PIC :
• A program counter is a register in a CPU that contains the address (location) of the instruction being executed at
the current time. After each instruction is fetched, the program counter is incremented to point to the next
instruction in the sequence.
• The PC can be accessed/modified by jump and branch instructions. Therefore, the destination address can be
loaded to the program counter via branch instructions.
• The width of the program counter decides how many memory locations CPU canaccess. More the width, more the
memory locations CPU can access.
• the width of program counter in various PIC families and code memory access by them.
• Program Counter (PC) - 21-bit register that holds the program memory address while executing programs. This
means that the PIC18 family can access program addresses 000000 to 1FFFFFH, a total of 2M bytes of code.
THE PROGRAMMABLE ROM SPACE IN THE PIC :
shows program ROM space for PIC18F458 and PIC18F8722. As shown in the Reset vector address is at 0000h and the
interrupt vector addresses are at 0008h and 0018h
• The PIC18F458 has 32 kbytes of flash program memory. This translates into 32768 single-word instructions, which can
be stored in the program memory.
• On the other hand, the PIC18F8722 has 128 kbytes of Flash program memory. Thistranslates into 131072 single-word
instructions, which can be stored in the program memory.
FILE REGISTER AND ACCESS BANK, BANK SWITCHING IN PIC18 :
• In PIC18 microcontrollers, the data (Read/Write) memory is implemented as staticRAM. It is also known as File
Register.
• Like WREG we can perform arithmetic and logic operations on many locations of the file register data RAM.
• PIC microcontroller's file register size ranges from 32 bytes to several thousands ofbytes depending on the chip.
• shows the file register organization for the PIC18FXXS devices. It is 4096 bytes of data memory with 12-bit address
for each register.
• The data memory map is divided into as many as 16 banks that contain 256 bytes. each. The lower 4 bits of the
Bank Select Register (BSR) select which bank will be accessed.
• When using direct addressing, the Bank Select Register (BSR) is used to select the desired bank.
• BSR<3:0> holds the upper 4 bits of the 12-bit RAM address. These 4 bits are used to select the desired bank. The
BSR<74> bits will always read U's and writes will have no effect.
• The file register data memory of PIC is divided into two sections:
Special Function Registers (SFRS): Used for control and status of the controller and peripheral functions.
General Purpose Registers (GPRs): Used for data storage and scratchpad operations in the user's application.
Data memory map
• The SFRs start at the last location of Bank 15 (FFFh) and grow downwards. GPRS start at the first location of Bank 0
and grow upwards.
• The entire data memory may be accessed directly or indirectly. Direct addressing may require the use of the BSR
register. Indirect addressing requires the use of the File Select Register (FSR). Each FSR holds a 12-bit address value
that can be used to access any location in the data memory map without banking.
• File Select Registers: FSRO, FSRI and FSR2. These registers are composed of two 8-bit registers: PSRH and FSRL.
• The Access Bank is comprised of the upper 160 bytes in Bank 15 (SFRs) and thelower 96 bytes in Bank 0. These two
sections will be referred to as Access Bank High and Access Bank Low, respectively.
• All the instructions without 'A' letter in instructions assume the access bank as adefault bank. Here, A 0. When 'A'
letter is included in the instruction, A is 1,the instruction use bank select register to select the bank.
• Upon reset BSR 0000H and by default Bank) is selected. We can load 0001H in. BSR to select Bank1, 0002H in BSR to
select Bank2 and so on.
ADDRESSING MODES:
Addressing Modes :
The term addressing modes refers to the way in which the operand of an instruction is specified. The addressing
mode specifies a rule for interpreting or modifying the address field of the instruction before the operand is actually
executed
In computer programming, addressing modes are primarily of interest to those who write in assembly languages and
to compiler writers. For a related concept see orthogonal instruction set which deals with the ability of any instruction
to use any addressing mode. The PIC18F Microcontroller has 4 addressing modes.
• In immediate addressing mode, the immediate data is specified in the instruction.Immediate data is also called literal
in PIC18.
• The immediate addressing mode is used to load the data into PIC registers and WREG register. However, we cannot
use immediate addressing mode to load data. into any of the file register.Examples:
1. MOVLW 0x50 :Load 50 H into WREG
2. ANDLW D ‘18’ :Logically AND WREG with 18 decimal
3. ADDLW B' 01100000 : Add 60 H in WREG.
• To load immediate data in file register data RAM, we have to load immediate data in WREG register and then it can
be copied to file register data RAM location.
• We can use the EQU directive to access immediate data as shown below.
• NUM EQU 0x50
In direct addressing mode, the operand data is in the file register (RAM) data memory. The address of this memory
location is specified in the instruction.
Examples:
1. MOVWF 0X10 Copy contents of WREG into File Register RAM location 10 H
2. MOVFF OX10, 0X20 Copy contents of location 10 H to 20 H
3. MOVFF OX30, PORTC Copy contents of location 30 H to PORTC.
• The letter 'F in the instruction means the address of the file register location.
• The letter FF in the instruction means the both source and destination addresses. are file register locations.
Direct Addressing Mode
REGISTER INDIRECT ADDRESSING MODE :
Register indirect addressing mode is used for accessing data stored in the fileregister (RAM) data memory.
In this addressing mode, three file select registers FSRO, FSR1, and FSR2 are usedas pointers to the memory locations
of the file register (RAM) data memory.
Each of the FSRO, FSRI, and FSR2 registers has an INDF register associated withit, and these are called INDFI, INDFI, and
INDF2 When we move data into INDFx we are moving data into a RAM location pointed to by the FSRx.
Examples:
• We use code space to store fixed data along with the code. This addressing mode is used for accessing the fixed
data from look up tables that reside in the PIC18 program ROM. This process is often called table processing.
• Directive DB is used to define an 8-bit fixed data in data ROM. Here, we have to use special function register to
point the data to be fetched from the code space.
• Two registers are used in the table processing TBLPTR (TaBLe PoinTR) and TABLAT (TABle LATch).
• The 21 bit register TBLPTR is used to access byte from PIC18 program ROM. With 21 bit register TBLPTR we can
cover the entire 2M program (code) space for PIC18.
• TBLPTR register in divided into three parts: TBLPTRL (Low), TBLPTRH (High),and TBLPTRU (Upper). These parts are
of the SFRS.
• TABLAT register is used for keeping the byte read from code space pointed byTBLPTR.
• Example:
MOVLW 0x0 : WREG 0 Look-up Table low-byte address
MOVWF TBLPTRL :Load Look-up Table low-byte address in TBLPTRL register
MOVLW 0x10 :WREG 10 Look-up Table high-byte address
MOVWF TBLPTRH :Load Look-up Table high-byte address in TBLPTRH register
MOVLW 0x0 :WREG 0 Look-up Table upper-byte address
Index Addressing Mode
OSCILLATOR CONFIGURATIONS :
Mid-Range devices can have up to eight different oscillator modes. The user can program up to three device
configuration bits (FOSC2, FOSC1 and FOSC0) to select one of these eight modes:
• LP Low Frequency (Power) Crystal
• XT Crystal/Resonator
• HS High Speed Crystal/Resonator
• RC External Resistor/Capacitor (same as EXTRC with CLKOUT)
• EXTRC External Resistor/Capacitor
• EXTRC External Resistor/Capacitor with CLKOUT
• INTRC Internal 4 MHz Resistor/Capacitor
• INTRC Internal 4 MHz Resistor/Capacitor with CLKOUT
The LP, XT, and HS modes differ in the gain of the internal inverter of the oscillator circuit, allowing for different
frequency ranges.
It is advisable to select the oscillator mode with the lowest gain that still meets specifications to minimize
dynamic currents (IDD).
The frequency range of each oscillator mode represents the recommended (tested) frequency cutoffs, but
choosing a different gain mode is acceptable with thorough validation, considering voltage, temperature, and
component variations.
• The PIC18FXX8 can be operated in one of eight oscillator modes, programmable by three configuration bits
(FOSC2, FOSC1 and FOSCO).
RESET OPERATIONS :
The reset logic is used to place the device into a known state. The source of the reset can be determined by using
the device status bits. The reset logic is designed with features that reduce system cost and increase system
reliability.
Reset Function :
Reset function is one of the most advanced features that is available on all modern microcontrollers. The PIC18
series have various kinds of resets. The various kinds of reset options that are available on PIC 18 series are given
below.
Time-out Sequence:
On power-up, the time-out sequence is as follows: the PWRT delay starts (if enabled) when a POR Reset occurs.
Then, OST starts counting 1024 oscillator cycles when PWRT ends (LP, XT, and HS). When the OST ends, the device
comes out of Reset. If MCLR is kept low long enough, the time-outs will expire. Bringing MCLR high will begin
execution immediately. This is useful for testing purposes or to synchronize more than one PIC16F87XA device
operating in parallel. Table shows the Reset conditions for the Status, PCON and PC registers, while Table shows the
Reset conditions for all the registers.
BROWNOUT RESET :
• A Brown-out Reset (BOR) is a circuit that monitors the Vpp level during operation by comparing it to a fixed
threshold level. When Vpo drops below the threshold level, the Brown-out Reset is activated.
• When Vpp rises again, the controller is restarted after a specified delay. This ensures that the device does not
continue program execution outside of its valid operation range, which can lead to improper code execution.
• Not all devices have BOR, but most do, and some have multiple voltage thresholds to select from.
• Many PIC microcontrollers have a BOR with configurable voltage levels. Devicefamilies, such as the PIC18F,
PIC24F and dsPIC30F series, support the BOR threshold levels. Table shows voltage thresholds for PIC18FXX8.
CONFIG2L: Configuration Register 2 Low (Byte Address 300002h)
• We can configure BOR threshold levels using BORV1 : BORVO bits in the CONFIG2L register.
• The watchdog timer is loaded with a timeout period which is dependent on the application. Whenever software
failed to clear the watchdog timer before its timeout period, the watchdog timer resets the system.
• In PIC18FXX8, the Watchdog Timer is a free running, on-chip RC oscillator which does not require any external
components. This RC oscillator is separate from the RC oscillator of the OSC1/CLKI pin.
• During normal operation, a WDT time-out generates a device Reset (Watchdog Timer Reset). If the device is in
Sleep mode, a WDT time-out causes the device to wake-up and continue with normal operation (Watchdog Timer
wake-up).
the Watchdog Timer is enabled/disabled by a device configuration bit. If the WDT is enabled, software execution
may not disable this function. When the WDTEN (Watchdog Timer Enable) configuration bit is cleared, the SWDTEN
(Software Controlled Watchdog Timer Enable) bit in the watchdog timer control register.(WDTCON) enables/disables
the operation of the WDT.
• The WDT has a postscaler that can extend the WDT Reset period. The postscaler is selected at the time of
device programming by the value written into WDTPS2:WDTPSO bits of the CONFIG2H Configuration register.
Power down modes & Configuration registers :
• By setting the PD bit of the PCON register from within the program, the microcontroller is set to Power down
mode.
• thus turning off its internal oscillator and reduces power consumption enormously.
• The microcontroller can operate using only 2V power supply in power- down mode, while a total power
consumption is less than 40uA.
• The only way to get the micro controller back to normal mode is by reset.
• While the microcontroller is in Power Down mode, the state of all SFR registers and I/O ports remains
unchanged.
• By setting it back into the normal mode, the contents of the SFR register is lost, but the content of internal
RAM is saved.
• Reset signal must be long enough, approximately 10mS, to enable stable operation of the quartz oscillator.