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

Processor Architecture Unit-1 Notes (1)

The document provides an overview of microcontroller architecture, detailing its components such as the CPU, memory types, and I/O peripherals. It discusses the advantages and disadvantages of microcontrollers, their types based on architecture and memory, and their applications in various fields. Additionally, it highlights the history of microcontrollers, differences between microcontrollers and microprocessors, and criteria for selecting an appropriate microcontroller for specific applications.

Uploaded by

Vishal Sawant
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Processor Architecture Unit-1 Notes (1)

The document provides an overview of microcontroller architecture, detailing its components such as the CPU, memory types, and I/O peripherals. It discusses the advantages and disadvantages of microcontrollers, their types based on architecture and memory, and their applications in various fields. Additionally, it highlights the history of microcontrollers, differences between microcontrollers and microprocessors, and criteria for selecting an appropriate microcontroller for specific applications.

Uploaded by

Vishal Sawant
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Processor Architecture

Unit I-PIC Microcontroller Architecture


Introduction to Microcontroller:

A Microcontroller is a small computer on a single integrated circuit consisting of a


relatively simple central processing unit (CPU) combined with peripheral devices such as
memories, I/O devices, and timers. A Microcontroller contains one or more CPUs (processor
cores) along with memory and programmable input/output peripherals. Program memory in
the form of ferroelectric RAM, NOR flash or OTP ROM is also often included on chip, as well
as a small amount of RAM. Microcontrollers are designed for embedded applications, in
contrast to the microprocessors used in personal computers or other general-purpose
applications consisting of various discrete chips.

In modern terminology, a Microcontroller is like, but less sophisticated than, a system


on a chip (SoC). An SoC may connect the external Microcontroller chips as the motherboard
components, but an SoC usually integrates the advanced peripherals like graphics processing
unit (GPU) and Wi-Fi interface controller as its internal Microcontroller unit circuits.
Microcontrollers are used in automatically controlled products and devices, such as automobile
engine control systems, implantable medical devices, remote controls, office machines,
appliances, power tools, toys, and other embedded systems. By reducing the size and cost
compared to a design that uses a separate microprocessor, memory, and input/output devices,
Microcontrollers make it economical to digitally control even more devices and processes.

Mixed signal Microcontrollers are common, integrating analog components needed to


control non-digital electronic systems. In the context of the internet of things, Microcontrollers
are an economical and popular means of data collection, sensing and actuating the physical
world as edge devices. The core elements of a Microcontroller are:

• The processor (CPU): A processor can be thought of as the brain of the device. It
processes and responds to various instructions that direct the Microcontroller's function.
This involves performing basic arithmetic, logic and I/O operations. It also performs
data transfer operations, which communicate commands to other components in the
larger embedded system.
• Memory: A Microcontroller's memory is used to store the data that the processor
receives and uses to respond to instructions that it's been programmed to carry out. A
Microcontroller has two main memory types:
1. Program memory, which stores long-term information about the
instructions that the CPU carries out. Program memory is non-volatile
memory, meaning it holds information over time without needing a
power source.
2. Data memory, which is required for temporary data storage while the
instructions are being executed. Data memory is volatile, meaning the
data it holds is temporary and is only maintained if the device is
connected to a power source.
• I/O peripherals: The input and output devices are the interface for the processor to the
outside world. The input ports receive information and send it to the processor in the
form of binary data. The processor receives that data and sends the necessary
instructions to output devices that execute tasks external to the Microcontroller.
While the processor, memory and I/O peripherals are the defining elements of the
microprocessor, there are other elements that are frequently included. The term I/O
peripherals itself simply refers to supporting components that interface with the memory and
processor. There are many supporting components that can be classified as peripherals. Having
some manifestation of an I/O peripheral is elemental to a microprocessor because they are the
mechanism through which the processor is applied. Other supporting elements of a
Microcontroller include:
• Analog to Digital Converter (ADC): An ADC is a circuit that converts analog
signals to digital signals. It allows the processor at the centre of the Microcontroller
to interface with external analog devices, such as sensors.
• Digital to Analog Converter (DAC): A DAC performs the inverse function of an
ADC and allows the processor at the centre of the Microcontroller to communicate
its outgoing signals to external analog components.
• System bus: The system bus is the connective wire that links all components of the
Microcontroller together.
• Serial port: The serial port is one example of an I/O port that allows the
Microcontroller to connect to external components. It has a similar function to a
USB or a parallel port but differs in the way it exchanges bits.
Microcontrollers are commonly used in embedded systems and are found in a wide
range of electronic devices, such as consumer electronics, automotive systems, medical
devices, and industrial automation systems. They are ideal for controlling simple devices such
as sensors, actuators, and displays, as well as for executing more complex tasks such as
communication protocols and data processing.
• The programming of a Microcontroller is done using a specialized language such as C
or assembly language. The program is stored in the memory of the Microcontroller and
executed when the device is powered on. Microcontrollers can be programmed to
respond to various inputs, perform calculations, and interact with other electronic
devices.
• Microcontrollers are often used in situations where power consumption, size, and cost
are critical factors. They are designed to be low-power devices and are optimized for
use in battery-powered applications. They are also compact, making them suitable for
use in small devices.
• Overall, Microcontrollers are an essential component of modern electronics, and their
versatility and flexibility make them an excellent choice for a wide range of
applications.

Features of a Microcontroller:
1. The main advantage of a CISC (complex instruction set computer) architecture, with
which the modern Microcontrollers are built, is the macro-type instructions. A macro
instruction can be used in a program replacing several instructions.
2. Latest Microcontrollers are operated at lesser power consumption. Usually, they can
support a working voltage of 1.8-5.5 V.
3. Advanced memory is another feature of a Microcontroller. Use of ROM memories like
EEPROM and EPROM (flash memory) make it more reliable and user-friendly. While
EEPROM is a relatively slow memory, EPROM is faster. Fact that it allows more
erase/write cycles also makes it more usable.
Advantages:
• The main advantage of a Microcontroller is that the low cost with all the integral parts
mounted together on a single chip.
• The design makes it more compact and easier to use.
• The easiness of using a Microcontroller and the relatively easy maintenance process
also make it more reliable. Almost all the pins in a Microcontroller are programmable
and it makes the Microcontroller a lot user-friendly. Simplicity while interfacing ROM,
RAM, and I/O ports.
• Easiness of troubleshooting and a minimal time requirement for various operations are
other crucial advantages.
Disadvantages:
• Since it contains all the components on a single chip, Microcontrollers are having
relatively complex architecture.
• Microcontrollers are not suitable to interface high power devices directly and they can
only perform the limited number of operations simultaneously.
Types of Microcontrollers:
According to the architecture, memory, and word size, it can process, Microcontrollers
are divided into several categories.
1. Categorization Based on Bit Size: There is an 8-bit Microcontroller which executes
basic functions such as arithmetic and logic operations. Intel 8051 is an 8-bit
Microcontroller. Example for a 16-bit Microcontroller is Intel 8096. They are more
accurate and provide better performance compared to the 8-bit Microcontrollers. 32-bit
Microcontrollers are used to execute higher functions where precise automatic control
is required. The best example of such a Microcontroller application is implantable
medical appliances.
2. Categorization Based on Memory: According to the memory space inside the
Microcontroller, the Microcontrollers are classified as external memory
Microcontroller and embedded memory Microcontroller.
a. External memory Microcontroller: It does not have all the integral parts
fabricated on a single chip, especially the memory. Intel 8031 is such a device
which does not have the program memory on the chip.
b. Embedded memory: As the name indicates it has all the functioning bocks
including the program and data memory fabricated on a single chip. 8051 is an
example.
3. Based on memory architecture: Microcontrollers are divided into two:
a. Harvard memory architecture
b. Princeton memory architecture.
4. Categorization Based on Instruction Set: There are two classifications based on the
instruction set. They are CISC and RISC. CISC is the abbreviated form for complex
instruction set computer and RISC is the abbreviated form for reduced instruction set
computer. CISC is based on macro instruction sets which mean a single instruction is
used to replace a number of instructions. In reduced instruction architecture, the
operation time is reduced by minimizing the clock cycle per instruction.
5. 8051: It is the most universally used Microcontroller and was introduced by Intel in the
year of 1981. It has 40 kb internal ROM and 128-byte RAM. An additional 64 kb of
external memory can be interfaced with the Microcontroller. The four parallel 8-bit
ports of this Microcontroller can be easily programmed and addressed. There is a crystal
oscillator interfaced to the Microcontroller which generates a frequency of 12 MHz
Apart from these components, there is a serial port which is 8-bit sized, and two 16-bit
timers incorporated in the 8051 Microcontrollers.
Applications:
• Peripheral controller of a PC
• Robotics
• In bio-medical equipment
• In communication system
• In automobiles
• In fire detection devices
• In light and temperature sensing and controlling devices
• In measuring devices such as volt and current meters
Various Manufacturers of Microcontrollers:
• Analog devices: 8051 Microcontrollers with the 12-bit analog to digital
converter.
• Atmel: 8051, AT91, AVR, AVR32
• Freescale semiconductor: Family of Microcontrollers ranging from 8-bit to
32-bit.
• Infineon technologies: 8-bit Microcontrollers based on 8051 and 16-bit
ROM and OTP Microcontrollers.
• Maxim Integrated Products: 75 MHz single-cycle flash 8051
Microcontrollers, some low power 16-bit Microcontrollers
• Microchip: Wide array of 8-bit Microcontroller families including PIC12,
PIC16, PIC18, 16- bit PIC 24 Microcontroller and PIC32 which is 32-bit
Microcontrollers.
History of Microcontrollers:
Microcontroller was developed in 1971 by Intel Corporation in the United States. That
is the 4-bit Microcontroller called i4004. It was ordered by a Japanese company BUSICOM
for calculators. Later, the contract was changed, and it was sold as a general-purpose
Microcontroller with success. After that, Intel Corp. developed a 16-bit Microcontroller ‘8086,’
following the 8-bit Microcontrollers such as ‘i8008’, ‘i8080A,’ and ‘i8085.’ After developing
several Microcontrollers, they continue to develop the CPUs used in current personal
computers. Toshiba developed a 12-bit Microcontroller TLCS-12 in 1973. At that time, the
United States was considering electronic control units as a countermeasure of the exhaust gas
regulation law.
Against this background, Toshiba's 12-bit Microcontroller was developed as Ford's in-
vehicle engine controller. After that, Toshiba developed a wide range of high-level
Microcontrollers from 4 bit to 32 bit or higher. Intel developed a computer system on a chip
optimized for control applications, the Intel 8048, with commercial parts first shipping in 1977.
It combined RAM and ROM on the same chip with a microprocessor. Among numerous
applications, this chip would eventually find its way into over one billion PC keyboards. At
that time Intel's President, Luke J. Valenter, stated that the microcontroller was one of the most
successful products in the company's history, and he expanded the microcontroller division's
budget by over 25%. Most microcontrollers at this time had concurrent variants. One had
EPROM program memory, with a transparent quartz window in the lid of the package to allow
it to be erased by exposure to ultraviolet light. These erasable chips were often used for
prototyping. The other variant was either a mask programmed ROM or a PROM variant which
was only programmable once. For the latter, sometimes the designation OTP was used,
standing for "one-time programmable". In an OTP microcontroller, the PROM was usually of
identical type as the EPROM, but the chip package had no quartz window; because there was
no way to expose the EPROM to ultraviolet light, it could not be erased. Because the erasable
versions required ceramic packages with quartz windows, they were significantly more
expensive than the OTP versions, which could be made in lower-cost opaque plastic packages.
For the erasable variants, quartz was required, instead of less expensive glass, for its
transparency to ultraviolet light—to which glass is largely opaque—but the main cost
differentiator was the ceramic package itself. In 1993, the introduction of EEPROM memory
allowed microcontrollers (beginning with the Microchip PIC16C84 to be electrically erased
quickly without an expensive package as required for EPROM, allowing both rapid
prototyping, and in-system programming. (EEPROM technology had been available prior to
this time, but the earlier EEPROM was more expensive and less durable, making it unsuitable
for low-cost mass-produced microcontrollers.) The same year, Atmel introduced the first
microcontroller using Flash memory, a special type of EEPROM. Other companies rapidly
followed suit, with both memory types.
Difference between Microprocessor and Microcontroller:
S. No Microprocessor Microcontroller
1 Microprocessor acts as a heart of Microcontroller acts as a heart of
computer system. embedded system.
2 It is a processor in which memory and It is a controlling device in which memory
I/O output component is connected and I/O output component is present
externally. internally.
3 Since memory and I/O output is to be Since on chip memory and I/O output
connected externally. Therefore, the component is available. Therefore, the
circuit is more complex. circuit is less complex.
4 It cannot be used in compact system. It can be used in compact system.
Therefore, microprocessor is inefficient.
Therefore, microcontroller is more
efficient.
5 Microprocessor has a smaller number of Microcontroller has a greater number of
registers. Therefore, most of the registers. Therefore, a program is easier to
operations are memory based. write.
6 A microprocessor having a zero-status A microcontroller has no zero flag.
flag.
7 Microprocessor-based systems can run Microcontroller based systems run up to
at a very high speed because of the 200MHz or more depending on the
technology involved. architecture.
8 These are based on the von Neumann These are based on Harvard architecture
model where program and data are where program memory and data memory
stored in the same memory module. are separate.
9 It's useful for general purpose It's useful for application-specific systems.
applications that allow you to handle
loads of data.
10 It is mainly used in personal computers. It is mainly used in washing machines, air
conditioners etc.

Criteria for selection of microcontroller:


Choosing a microcontroller from several different microcontrollers is a very critical
decision for the designers. Three are the vital major criteria for selecting them. These are (a)
wide availability and reliable sources (b) meeting the requirements efficiently and cost
effectively (c) availability of the software development tools like compilers, Assemblers, and
debuggers etc. The main criteria in selecting a microcontroller are given below in the order
of importance.
1. System Requirement: The design should start with a blank sheet of paper specifying
the application needs if the system requires a single chip MCU or additional
peripherals are to be used with it. The selection process starts with a decision of
choosing either the 4-bit, 8-bit, 16-bit, or 32-bit microcontroller required by the
application. To develop code for 4-bit architectures is harder and handling 4-bit
instructions and data widths can limit arithmetic capabilities. Most of the embedded
applications are implemented using an 8-bit microcontroller as the technology has
been around a long time and a huge number of controllers are available in the market.
The on-chip peripherals available exhibit a heavy influence on component selection.
Check the availability of Timers, Serial interfaces, ROM, RAM, A/D converter, D/A
converter enough I/O ports. Too many I/O ports lead to bear the excessive
2. Memory Architecture: This is a very important factor while designing any
microcontroller-based system. Three different types of memory play an important role
in the selection process are (a) program memory i.e., Flash, OTP, ROM, and ROM
fewer components, (b) Data memory i.e., on-chip SRAM or external SDRAM and (c)
Non-volatile Memory i.e., EEPROM or Flash. Whether the memory is on-chip or off-
chip and how much the size is required may be a key factor that defines the cost of
building the system and speed of operation. For example, Atmel AVR family includes
Flash memory of 1KB to 128KB, on-chip SRAM for data storage, and for the storage
of configuration information and serial numbers, a few bytes of EEPROM are
reserved. These golden features make the AVR family more popular in different
applications. Flash gives the flexibility to make code changes and provides the facility
to use In-System-Programmed.
3. Availability: Before going to implement the system, the availability of the device
should be checked. The criteria in choosing a microcontroller are its ready availability
in needed quantities both now and the future. If sufficient quantities are available with
a bright future, then no need to be worried about the failure of the project.
4. Size: If IC of 15 I/O pins are required to develop the system there is no need to use 40
pin IC with 32 I/O pins. In this way, the size of the IC can be reduced, and thus physical
space required to implement the system is also reduced. So, the physical size of the IC
may well be a critical factor for specific applications.
5. Compatibility: The function of a system can be changed or upgraded by changing the
software or replacing one IC with another one without incurring a heavy additional
cost. The new one will be pin compatible as well as function compatible.
6. Functionality Testing: To check the function of the implemented system correctly
the function of the MCU should be checked within the test circuit designed earlier
before going to develop the overall system.
7. Power Management: More power means more heat dissipation which leads to a
waste of energy. Power consumed by the system determines the lifetime of the battery.
Due to a reduction in the size of the devices the size of the components is reduced and
their placement within the design is very compact. This phenomenon makes the
devices to be sensitive to the heat dissipated from the MCU and the other peripherals
connected with it. Most microcontrollers have the features of power down, idle &
sleep modes, and consideration needs to be given to maximize the use of intelligent
power management systems to reduce power consumption.
8. Cost: This is the most important factor. If the system is to be implemented within the
limit of the budget calculated earlier the cost of each and every component (selected
MCU along with supporting ICs) used to build the system should be minimized
tactfully to fulfil the requirements. On the chip, features will trade with inventory and
assembly cost of using extra supporting external components. They can also cut
development time and effort by providing a ready integrated solution.
PIC Microcontroller Introduction:
Peripheral Interface Controller (PIC) microcontroller was developed in the year 1993
by microchip technology. The term PIC stands for Peripheral Interface Controller. Initially this
was developed for supporting Programmed Data Processor (PDP) computers to control its
peripheral devices, and therefore, named as a peripheral interface device. These
microcontrollers are very fast and easy to execute a program compared with other
microcontrollers. PIC Microcontroller architecture is based on Harvard architecture. PIC
microcontrollers are very popular due to their ease of programming, wide availability, easy to
interface with other peripherals, low cost, large user base and serial programming capability
(reprogramming with flash memory). We know that the microcontroller is an integrated chip
which consists of CPU, RAM, ROM, timers, and counters, etc. In the same way, PIC
microcontroller architecture consists of RAM, ROM, CPU, timers, counters and supports the
protocols such as SPI, CAN, and UART for interfacing with other peripherals. At present PIC
microcontrollers are extensively used for industrial purpose due to low power consumption,
high performance ability and easy of availability of its supporting hardware and software tools
like compilers, debuggers, and simulators.

Different models of PIC Microcontrollers:

• PIC10: 6 to 8-bit microcontrollers with up to 512 bytes of program memory.

• PIC12: 8-bit microcontrollers with up to 3.5KB of program memory.

• PIC16: 8-bit microcontrollers with up to 64KB of program memory.

• PIC18: 8-bit microcontrollers with up to 128KB of program memory.


• PIC24: 16-bit microcontrollers with up to 256KB of program memory.

• dsPIC30: 16-bit digital signal controllers with up to 144KB of program memory.

• dsPIC33: 16-bit digital signal controllers with up to 512KB of program memory.

• PIC32: 32-bit microcontrollers with up to 2MB of program memory.

PIC18F458:

PIC18F458 is a microcontroller from the PIC18 family of 8-bit microcontrollers


produced by Microchip Technology. It is a high-performance microcontroller with advanced
features such as 32 KB flash program memory, 1536 bytes of data RAM, and 256 bytes of
EEPROM. It also includes features like multiple PWM modules, ADCs, timers, and serial
communication interfaces such as UART, SPI, and I2C.The PIC18F458 microcontroller is
widely used in a variety of applications, including automotive, industrial control, consumer
electronics, and medical equipment, among others. Its rich set of features, low power
consumption, and ease of use make it a popular choice among embedded system designers.
Features: The features of PIC18F458 are:
1. Architecture: It is based on the Harvard architecture, which means that it has
separate memory spaces for program and data.
2. CPU: It has a high-performance RISC CPU with a maximum clock frequency of
40 MHz.
3. Memory: It has 32KB of flash memory for program storage and 1536 bytes of data
EEPROM for non-volatile data storage. It also has 1536 bytes of RAM for volatile
data storage.
4. Peripherals: It has a wide range of on-chip peripherals, including analog-to-digital
converters (ADCs), digital-to-analog converters (DACs), timers, pulse width
modulation (PWM) modules, and communication modules such as UART, SPI, and
I2C.
5. Input/Output: It has up to 35 I/O pins that can be configured as either input or
output.
6. Power Management: It has multiple power-saving features, such as sleep mode
and idle mode, to conserve power when the device is not in use.
7. Operating Voltage: It operates on a voltage range of 2.0V to 5.5V.
8. Packaging: It is available in various packages, including PDIP, SOIC, SSOP,
TQFP, and QFN.
High-Performance RISC CPU:
• - Source code compatible with the PIC16 and PIC17 instruction sets
• - Linear data memory addressing to 1536 bytes
• - Linear program memory addressing to 32 Mbytes
• - DC - 40 MHz osc. /Clock input
• - 16-bit wide instructions, 8-bit wide data path
• - Priority levels for interrupts
• - 8 x 8 Single Cycle Hardware Multiplier
• - 16 Kbytes Flash Program Memory
• - 1536 Byte RAM Data Memory
• - 256 Byte RAM Data Memory
Peripheral Features:
• - High current sink/source 25mA/25mA
• - Two 16-bit timer/counter (TMR1, TMR3)
• - One 8-bit/16-bit timer/counter with prescaler
• - One 8-bit timer/counter with 8-bit period register
• - Capture 16-bit, max. resolution 6.25ns (TCY/16)
• - Compare 16-bit, max. resolution 100ns
• - 3-wire SPI with Interrupt-on-Address Bit
• - I²C Master and Slave mode
• - Secondary Oscillator Clock Option - Timer1/Timer3
• - 1,2 or 4 PWM Outputs with Selectable Polarity
• - Eight Channel 10-bit Analog-to-Digital Converter
Advanced CAN Technology:
• - Complies with ISO CAN Conformance Test
• - Message bit rates up to 1 Mbps
• - 8-byte Message Length
• - 29-bit Identifier Fields
• - 3 Transmit Message Buffers with Prioritization
• - 6 full, 29-bit Acceptance Filters
• - Advanced Error Management Features
Special Microcontroller Features:
• - Power-On Reset
• - Power-up Timer (PWRT) and Oscillator Start-Up Timer (OST)
• - 1,000 erase/write cycles Enhanced Flash Program Memory
• - 1,000,000 typical erase/write cycles EEPROM Data Memory
• - Watchdog Timer (WDT) with its own On-Chip RC oscillator
• - Programmable Code Protection
• - Power Saving SLEEP mode
• - 4X Phase Lock Loop (of primary oscillator)
• - Secondary Oscillator (32kHz) clock input
• - In-Circuit Debug (ICD)
CMOS Technology:
• - Low power, high speed CMOS FLASH technology
• - Fully Static Design
• - Wide Operating Voltage Range (2.0V to 5.5V)
I/O and Packages:
• - 33 I/O pins with individual direction control
• - 40-pin DIP
Architecture:
• CPU: The CPU in the PIC18F458 is an 8-bit Harvard architecture with a RISC-like
instruction set. The CPU has 16-bit program counter, 8-bit status and data registers, and
an 8-level hardware stack.
• Memory: The PIC18F458 has up to 32 KB of flash memory for program storage, and
up to 1536 bytes of RAM for data storage. It also has a separate EEPROM for non-
volatile data storage.
• I/O: The PIC18F458 has a variety of peripherals, including analog-to-digital
converters, pulse width modulators, timers, and UARTs. It also has up to 34 general-
purpose I/O pins, which can be configured as inputs or outputs.
• Bus: The PIC18F458 has a multi-master, multi-slave bus architecture with support for
SPI, I2C, and CAN protocols.
• Interrupts: The PIC18F458 has a flexible interrupt system with support for up to 23
sources.
Comparison of PIC 18 series Microcontrollers:
The PIC 18 series microcontrollers are a family of 8-bit microcontrollers manufactured
by Microchip Technology. These microcontrollers are widely used in various applications,
including automotive, industrial, medical, and consumer electronics. Here is a comparison of
some of the popular PIC 18 series microcontrollers:
• PIC18F4550: This microcontroller has 32 KB of flash memory, 2 KB of RAM, and
operates at a maximum frequency of 48 MHz. It has 33 input/output pins and supports
USB 2.0. It is commonly used in applications that require USB connectivity.
• PIC18F4520: This microcontroller has 32 KB of flash memory, 1.5 KB of RAM, and
operates at a maximum frequency of 40 MHz. It has 40 input/output pins and supports
SPI, I2C, and USART communication protocols. It is commonly used in industrial
control and automation applications.
• PIC18F26K22: This microcontroller has 64 KB of flash memory, 3.8 KB of RAM,
and operates at a maximum frequency of 64 MHz. It has 34 input/output pins and
supports SPI, I2C, and USART communication protocols. It is commonly used in
battery-powered applications due to its low-power consumption.
• PIC18F67K22: This microcontroller has 128 KB of flash memory, 3.8 KB of RAM,
and operates at a maximum frequency of 64 MHz. It has 64 input/output pins and
supports SPI, I2C, and USART communication protocols. It is commonly used in high-
performance applications that require large amounts of memory and I/O.
• PIC18F27K42: This microcontroller has 128 KB of flash memory, 4 KB of RAM, and
operates at a maximum frequency of 64 MHz. It has 44 input/output pins and supports
SPI, I2C, and USART communication protocols. It also has advanced peripherals such
as an ADC, DAC, and comparators, making it suitable for advanced motor control,
power supply, and lighting applications.
The PIC 18 series microcontrollers offer a wide range of features and capabilities to
suit various applications. When choosing a microcontroller, it is important to consider factors
such as memory size, processing power, communication protocols, and peripherals to ensure
that it meets the requirements of the application.
PIC18F458/452 Pin out connection:
PIC18F458 has total 40 pins.
Pin Description
Pin Number Description

1 MCLR/VPP - Master Clear Reset

2 RA0/AN0/Cvref - Port A

3 RA1/AN1 - Port A

4 RA2/AN2/VREF- - Port A

5 RA3/AN3/VREF+ - Port A

6 RA4/T0CKI - Port A

7 RA5/AN4/SS/LVDIN - Port A

8 RE0/RD/AN5 - Port E

9 RE1/WR/AN6/C1OUT - Port E

10 RE2/CS/AN7/C2OUT - Port E

11 Vdd - Positive Power Supply

12 Vss - Ground

13 OSC1/CLKI - Oscillator

14 OSC2/CLKO/RA6 - Port A

15 RC0/T1OSO/T1CKI - Port C

16 RC1/T1OSI - Port C

17 RC2/CCP1 - Port C

18 RC3/SCK/SCL - Port C

19 RD0/PSP0/C1IN+ - Port D

20 RD1/PSP1/C1IN- - Port D

21 RD2/PSP2/C2IN+ - Port D

22 RD3/PSP3/C2IN- - Port D

23 RC4/SDI/SDA - Port C

24 RC5/SDO - Port C

25 RC6/TX/CK - Port C

26 RC7/RX/DT - Port C

27 RD4/PSP4/ECCP1/P1A - Port D

28 RD5/PSP5/P1B - Port D
29 RD6/PSP6/P1C - Port D

30 RD7/PSP7/P1D - Port D

31 Vss - Ground

32 Vdd - Positive Power Supply

33 RB0/INT0 - Port B

34 RB1/INT1 - Port B

35 RB2/INT2/CANTX - Port B

36 RB3/CANRX - Port B

37 RB4 - Port B

38 RB5/PGM - Port B

39 RB6/PGC - Port B

40 RB7/PGD - Port B

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:
• General Purpose Registers (GPRs): These are the 8-bit registers used to store data and
program variables during the execution of the program. The PIC18F has 96 GPRs,
numbered from 0x00 to 0x5F.
• Special Function Registers (SFRs): These are the registers that control the operation of
the microcontroller. They are used to configure and control the operation of the various
peripherals on the device, such as timers, UARTs, and SPI modules. The PIC18F has
many SFRs, and they are mapped to specific memory addresses in the device's memory
space. These registers are used to control various on-chip peripherals, such as the
analog-to-digital converter (ADC), the serial communication modules, and the PWM
modules. Some examples of SFRs include the STATUS register, the PORTB register,
and the TMR0 register.
• 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.
• Stack Pointer (SP): This register points to the top of the stack, which is used to store
data during subroutine calls and interrupts. This register keeps track of the current
location of the top of the stack, which is used for storing return addresses and other data
during subroutine calls.
• Program Counter (PC): This register contains the address of the next instruction to be
executed.
• Special Event Trigger (SRE) Register: This register is used to configure the SRE
module, which allows the device to trigger an interrupt when a specific event occurs.
• 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.
• Status Register (STATUS): This register contains several status flags that indicate the
current state of the microcontroller. These flags include the carry flag, the zero flag,
and the interrupt enable flag, among others.

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 TMR0, 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.
Program Counter in PIC18F:
Programmable ROM space in the PIC18F:
File register and Access bank, Bank switching in PIC18F:
Addressing modes:
Addressing modes are an aspect of the instruction set architecture in most central
processing unit (CPU) designs. The various addressing modes that are defined in a given
instruction set architecture define how the machine language instructions in that architecture
identify the operand(s) of each instruction. An addressing mode specifies how to calculate the
effective memory address of an operand by using information held in registers and/or constants
contained within a machine instruction or elsewhere.
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.
1. Immediate Addressing Mode
2. Direct Addressing Mode
3. Register Indirect Addressing Mode
4. Register Indirect/Indexed ROM Addressing Mode
Oscillator configurations:
Crystal Oscillator/Ceramic Resonators:

RC Oscillator:
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. Devices differentiate between various kinds of
reset:
1. Power-on Reset (POR).
2. MCLR reset during normal operation.
3. MCLR reset during SLEEP.
4. WDT reset during normal operation.
5. Brown-out Reset (BOR).
6. Parity Error Reset (PER).

Reset Control (RCON) Register:


Power-Up Timer (PWRT):
********************

You might also like