Professional Documents
Culture Documents
• Instruction set architectures are common to many processors. For example, Intel
instruction set architecture IA32/IA64 is also used by AMD processors.
• Other most common ISAs include ARM, MIPS , Motorola 68K , Risc V.
Microprocessor (MPU)
• A computer system has 3 basic hardware
components.
• CPU (central processing unit) consists of ALU and
control unit. Control unit provides information
exchange and analyzes the meaning of the code
according to ISA. ALU makes computation
• Memory: It is where program commands and data are
stored.
• Input/Output units: Allow the CPU to receive
information from the outside world and transfer
information to the outside world. They are also called
Peripheral units .
• An integrated circuit containing a CPU is
called as microprocessor .
Microprocessor units are units that process the information they receive from the
memories with which they communicate, on basic processing units such as an ALU
(unit where addition, subtraction, translation and logic operations are performed)
and Multiplier, and write it back to the appropriate location of the memory. These
memory units can also be input and output units.
Example of 2-bit multifunction ALU
• The following examples can be given to frequently
encountered commands
• Arithmetic commands : Addition, Subtraction, (Multiplication,
division): Arithmetic commands are performed as integers by
default. However, there are special units that can perform
floating-point operations for more precise numbers.
• Logic commands : Translation, Logic operations: AND, OR, XOR,
Inversion
• Data transfer : Move , Load , Store
• Branching and Jumping
8080 processor
The first popular microcontroller was Intel's 8-bit 8051 , introduced in 1980. In addition to
internal memories, it contained peripherals such as a timer, serial port, and programmable
input and output connections. Even today, there are different featured products from different
manufacturers that still use the 8051 core.
MSP430 family from TI, which continues to be used intensively today with its developing
content, was the first 16-bit microcontroller released in 1992.
• The ARM core, which emerged in the early 1990s , has been used extensively in the
mobile phone market since 1995, thanks to its RISC structure and low power,
became one of the first 32-bit microcontroller in the market.
• In the mid-2000s, NXP and ST introduced the LPC and STM32F1 ARM MCU families,
respectively, which would attracted great attention in the market with the ARMv7-
based ARM Cortex-M3 license.
• Today , the Microcontroller market hosts thousands of 8, 16 and 32 bit
microcontrollers from simple to advanced .
•
Embedded systems
• What is an embedded system ?
• Application specific computer system
• Integrates into larger systems
• Real time limitations embedded
• Why are embedded systems integrated into a system
larger system ?
• better performance
• More functions and content
• Lower costs
• Reliability
Embedded
Input from software
Computer Output to the
the hardware
environment
environment
User Connection to
Interface other systems
CPU → MCU → Embedded systems
• Embedded system
• Typically implemented with MCUs
• It is often integrated into the larger mechanical and
electronic system.
• They often have real-time limitations.
Embedded
system
WHERE ARE THE EMBEDDED SYSTEMS?
• Industrial Automation/Test/Production systems
• Aerospace industry
• Automation
• military devices
• production devices /robotic systems
• Radar/Sonar...
• CNC / 3D printers...
• weapon systems
• Industry 4.0 infrastructure devices
• Airplane/missile/ D rone ...
• ...
• Communication / network devices
• customer electronics
• Modem
• Phone/television/ monitor
• gateway
• fax /copier/printer/scanner
• router
• white goods
• Smart home and Buildings
• Sound and music systems
• Gateway
• small appliances
• sensors
•
•
and much more....
Cameras/projectors
• DRAM: Dynamic RAMs are mostly used PC, Laptop etc which requires large
memories. Since DRAMs typically use 1 transistor and capacity for each bit , they are 4GB
cheaper and larger in size than SRAMs . Their speeds are slower than SRAM . Even if
there is energy, the information inside will be deleted if it is not refreshed . DRAM
Therefore, control circuits for Refreshing DRAMs are alos required . Today Single
chip DRAMs up to 64GB are available. Embedded systems are rarely uses DRAMs.
• FRAM : It is a new generation technology and exhibits RAM features. But electricity
data is preserved when gone. Write lifetime is over 100 trillion . Since small sizes are
currently available, they are mostly used in Embedded systems. Serial
FRAM
• Non - Volatile Memory: These types of memories are used as program memories, boot
memories, data storage memories or configuration memories.
• ROM Read Only Memory-Parallel : Used to store program commands and constants. They can
only be read, but not written . They are parallel and fast. They are not much used today.
• FLASH memories - Parallel: These memories are mostly for reading purposes. However, the
writing process can be done several thousand times. Since the writing process is in blocks and
slow, it is not suitable for storing frequently variable information. They are mostly used as
program memory and to store some settings of constants. Today's MCUs mostly use Flash
memory as program memory. Although their reads are fast, their writes are slow and occur in
the form of sectors. In PC or Laptop applications, they are used only as boot software memory.
Their sizes can reach GBs . Since Parallel Flash memories are used directly inside MCUs , there is
usually no boot process. Therefore, embedded systems They can be activated within ms's .
• FLASH memories – Series : SSD, SDCard , MMC, eMMC , SPI-Flash memories are used for storage
and booting purposes. These types of memories are much slower than parallel memories
because they are used serially. Sizes reach TB s. It is appropriate to use this type of memory as
an I/O unit through serial buses (SPI, I2C etc..) .
• EEPROM ( Electrically erasable Programmable ROM ) Parallel-Serial: These are memories with a
write life of millions. These memories are often used to store parameters that need to be stored
but change frequently. Write speeds are slow. Data is preserved when the power goes out .
Their size can be 2 MB. It's not very big.
I/O units
• Units other than memory are considered I/O units. These
include serial memories connection structures.
• I/O units acn be accessed by
• Parallel addressing (with memory map and address resolvers)
• Serial communication (SPI, I2C, MODBUS, CAN, SATA, USB...)
While CISC instructions can do more complex operations, they require more clock
cycles and more complex hardware. In a typical CISC processor, the number of
instructions can be 120 - 300 , while in RISC processors it does not exceed 35-60.
Commands are completed between 2 and 10 cycles . This reduces the amount of
transactions per second. To achieve the same speed as RISC, the CISC processor must
operate at a higher frequency. It both increases power consumption and heats up.
The LDAX B instruction for 8080 takes 7 c .
• In RISC processors, almost every instruction is completed in 1
cycle .
• Advantages of RISC Architecture
• Using a microprocessor with a RISC design offers many advantages over using
a comparable CISC design .
• Speed: Because the reduced instruction set allows for single cycle operation
and superscalar (parallel processing) design, RISC processors often 2 – 4
times outperform to CISC processors using comparable semiconductor
technology and the same clock rates .
• Simple Hardware: Since the instruction set of the RISC processor is very
simple, they use very little chip space. Extra functions, memory controllers or
floating point arithmetic units are also placed on the same chip .
• Short Design Time : Since RISC processors are simpler than CISC processors,
they can be designed more quickly and can apply the advantages of other
technological developments more quickly than CISC designs.
RISC processors are used more intensively today. Many
microcontrollers are in RISC structure.
Instruction Set Architecture - Classification based on
instruction processing methods
• Memory-to-Memory : This type of ISA allows more than one operand of most
instructions to be in memory . VAX and PDP series are examples of this type of
architecture .
• Generating numbers
• 123456 = 1*10 5 + 2*10 4 + 3*10 3 + 4*10 2 + 5*10 1 + 6*10 0
• 100101 = 1*2 5 + 0*2 4 + 0*2 3 + 1*2 2 + 0*2 1 + 1*2 0
BYTE, WORD AND NIBBLE CONCEPTS
• eight-bit binary numbers are called as Byte
• 10011101 8 bit or one byte
• Althought Word is generally associated with 16-bit numbers,
This concept is sometimes paired with the number of the bus
length of the processor.
• 11001001 11100011 2 bytes or one word.
• Nibble is 4 bits
POSITIVE AND NEGATIVE NUMBERS
Let's look at the smallest and largest positive numbers of one byte
• negative numbers, it can be said that half of these numbers are positive and half are
negative.
For example , 1 byte number will vary between -127 and +127 .
• In binary , negative numbers are represented by complementary numbers so that
subtraction can be done through addition .
• Complementary number is the number that completes the given number to the
largest number represented for that number of bits. (It is practically done by
inverting bits.)
• For example 00001010 Its complement is 11110101 . (255 –10). This type of
complement is called as 1 's complement. Notice that the most weighted (leftmost)
bit is 1 for negative numbers. It is not used much in practice because there are two
0's here (0000 0000 and 1000 0000) and subtraction cannot be obtained by direct
addition of the processor.
Two 's Complement (2's Complement )
two 's complement number has a single 0. The numbers range from -2 bitnumber-1 .. 0 .. (2
bitnumber-1-1 ) . For example -128 ..0 ..127 for 8 bits .
Example : Let's express the number -20 - ( 0001 0100) as an 8-bit binary number
2 8 -20 =256 –20 =236= 1110 1100
Since hexadecimal numbers are used very often, they should be well known.
Example :
0011 1010 = 3A Hex, 1110 0101 = E5 Hex
0101 1101 1100 1001 0110 0111 =5DC967 Hex
In addition, both formats must be the same. For example, both numbers must be in Q15
format. If not, it should be shifted to fit one of the numbers.
The bottom number is shifted one right. It is converted to 3.5 format and summed (the
smallest digit will be lost.)
110.11010 (6.8125)
There was an overflow. the format will
010.01001 (2.28125)
be 4.4.
+__________
The smallest digit is shifted to the right
1 001.0001 1
and discarded.
Result : 1001.0001 (9.0625) (Rounding errors will occur due to shifts (actual value would be
9.109375). If these errors are not desired, more bit space should be reserved for numbers.
After the multiplication of fixed point numbers , 2 times length should be reserved for
the result . For example, at least 16 bits must be reserved for the product of 2, 8-bit
numbers.
multiplication of signed numbers : when msb bit is kept as sign bit, there will be 2 sign
bits as a result of multiplication, so the result is used by shifting 1 bit to the left.
For example, let's multiply two signed numbers in the format Q15 (1.15). Result will be
Q30 (2.30) . Since there will be two sign bits in this number, the number should be
converted to Q31 (1.31) format by shifting 1 bit.
• Let's multiply 2 8-bit numbers in Q7 format. The format is 1.7 and the numbers range
from -1 to 127/128.
0.1111100 (124/128= 0.96875) and
1.0100000 (-0.75 ) ( -96/128 (256-96 two's complement ))
X ___________________
Result 11.01 0001 1000 0000 (format 2.14). The result (because it carries 2 sign bits is
shifted to the left by 1 bit as (1.15) will be formatted.
1.010 0011 0000 0000 -0.7265625 ( for reversing to decimal (2 16 - 41728) / 2 15 )
Floating Point numbers
• Floating-point numbers are used to perform precision fractional operations and
mathematical operations with a wide dynamic range. Low - end and mid-range
processors often lack the necessary infrastructure for floating point operations.
• Floating point numbers are represented by a signed mantissa and exponent.
For example y= m* b e Here m: the mantissa part, b: base, e: exponential .
Floating-point numbers are stored in a variety of formats. The most widely used
format is IEEE/ANSI 754. This format is 32 bit and has the following structure.
Depending on the ALU structure, more than one bit is processed simultaneously.
For example, an 8-bit ALU will perform operations on two 8-bit numbers .
Examples
• Let's use 8 bit numbers
• Let A: 0x35, B=0x28
• R=A&B=?
• A= 0011 0101
• B= 0010 1000
• R= 0010 0000 = 0x20
• R=A|B=? • R=!A=?
• A= 0011 0101 • A = 0011 0101
• B= 0010 1000 • R = 1100 1010 = 0xCA
• R= 0011 1101 = 0x3D
• R = A ^ 0xFF ?
• R=A^B=? • A = 0011 0101
• A = 0011 0101 • 1111 1111
• B= 0010 1000 • R= 1100 1010 = 0xCA
• R= 0001 1101 = 0x1D
If a number is xored with logic 1 ,
result will be inverted.
SHIFTING OPERATION
Logical shift Arithmetic shift
<<
>>
rotation
CODE SYSTEMS
• Computers only work with numbers, whereas we need letters and
other symbols as well. These symbols are also encoded in such a way
that they correspond to numbers. For example, if the program
encounters this number, it prints the corresponding symbol on the
screen, or prints the symbolic equivalent of the number coming from
the keyboard .
DEVICE 0x48
0x45 H E
UART
Program Max 8 Bit Max 16 with
Memory Pin Number Digital Bit Digital Protocol USB
Product Status Size (KB) RAM (B) Count of ADCs Timers Timers Support SPI™ I2C Interface
PIC10F220 In Production 0.375 16 6 1 1 0 0 0 None
PIC10F204 In Production 0.375 16 6 0 1 0 0 0 None
PIC10F200 In Production 0.375 16 6 0 1 0 0 0 None
PIC10F320 In Production 0.448 64 6 1 2 0 0 0 None
PIC16F54 In Production 0.75 25 18 0 1 0 0 0 None
PIC12F508 In Production 0.75 25 8 0 1 0 0 0 None
PIC10F222 In Production 0.75 23 6 1 1 0 0 0 None
PIC10F206 In Production 0.75 24 6 0 1 0 0 0 None
PIC10F202 In Production 0.75 24 6 0 1 0 0 0 None
PIC10F322 In Production 0.896 64 6 1 2 0 0 0 None
PIC16F527 In Production 1.5 68 20 1 1 0 0 0 None
PIC16HV540 In Production 1.5 25 18 0 1 0 1 1 None
PIC16F526 In Production 1.5 67 14 1 1 0 0 0 None
PIC16F506 In Production 1.5 67 14 1 1 0 0 0 None
PIC16F505 In Production 1.5 72 14 0 1 0 0 0 None
PIC12F519 In Production 1.5 41 8 0 1 0 0 0 None
PIC12F510 In Production 1.5 38 8 1 1 0 0 0 None
PIC12F509 In Production 1.5 41 8 0 1 0 0 0 None
PIC12F1571 In Production 1.75 128 8 1 2 4 0 0 None
PIC12F1501 In Production 1.75 64 8 1 2 1 0 0 None
PIC16F84A In Production 1.75 68 18 0 1 0 0 0 None
PIC16F818 In Production 1.75 128 18 1 2 1 0 0 None
Example 16-bit processor parametric table
https:// www.ti.com/microcontrollers-mcus-processors/microcontrollers/msp430-
microcontrollers/products.html
Example 32-
bit ARM
processors
STM32F1xx
STM32
product map
Data type and capacities
• Data types in MCUs can be of various types. These are bit, nibble
, byte , word , double word . The table below shows data types
and capacities.
Architectures of various processors
Intel 8051 microcontroller
ADSP2181 Digital Signal Processor block diagram
STM32F1xx
ARM
Cortex-M3
processor
block
diagram
Processing commands
• A Command states an operation which is done in 1 step. For example,
adding 2 numbers, shifting the number, writing or reading to memory
or to an input-output unit.
• In microprocessor architectures, the central processing unit generally
processes commands in the following order.
1. Read (command) address content in program memory, indicated by program
counter
2. Send the command to Instruction decoder.
3. The Instruction decoder parses the command and CPU performs the necessary
operations.
4. Create new value of program counter (PC=PC+1 or PC= PC + n or PC= X) Go back
to step 1.
To perform this operation, a clock period ( clock cycle ) is used. RISC processors
generally perform an operation in the same cycle . As the cycle gets shorter (as the
frequency increases), the number of commands processed per second will increase.
For example, in RISC processors, for 1MHz clock 1 million commands are processed in
second. In SuperScalar RISC processors, since more than one instruction will be
processed in 1 Cycle , the number of instructions processed per second is higher than
the operating frequency.
Coding of commands
• Instructions are encoded on the program memory according to the capability
of the processor. For example
Command Parameters 16 bit
code (6bit) 10 bits instruction
The size of the instructions is adjusted according to the number of bits of the processor
program memory. For example, the command code is 6 bits, the parameters are 10
bits, 16 bits in total.
Since commands would be difficult to prepare in this way, each command is encoded
with a representative word. This coding format is called assembler language.
Below are the instruction codes and symbolic definitions for the now obsolete 6800
processor with von-neumann architecture .
Memory Memory Command
Address Data Name Description
0x0020 0xA6 LDA Store Data to Accumulator Register A from Memory
0x0021 0x50 Memory Address H
0x0022 0x01 Memory Address L
0x0023 0xBB ADD Add Accumulator A and Memory Data to A
0x0024 0x50 Memory Address H
0x0025 0x02 Memory Address L
0x0026 0xB7 STA Store Accumulator To memory
0x0027 0x50 Memory Address H
0x0028 0x03 Memory Address L
0x0029 0x3E HLT Halt
A program example such as X+Y=Z
• Program stops
Stack
• It is one of the important concept in microprocessor systems.
1 2 3 4
Stack
• PUSH is to add information to stack
• POP is to Get Info from Stack
A subroutine CALL, Interrupt calls and, if applicable, PUSH commands fall under the PUSH category.
RETURN and, if applicable, POP commands fall into the POP category.
STACK Overflow
If the stack depth is not handled properly, the microprocessor will overflow the stack to an unknown
address, the microprocessor will go to an unknown address, and the program will start to
malfunction. Until a reset procedure, the processor will not work properly.
To prevent overflow;
• Maximum consecutive stacks A number of push and pop operations that will not exceed the
depth should be performed.
• The number of POPs should be equal to the number of PUSH.
• first stack operation after reset should be PUSH.