Processor Architecture Unit-1 Notes (1)
Processor Architecture Unit-1 Notes (1)
• 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.
PIC18F458:
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
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
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).