Introduction To Micro-Processors & Micro-Controllers
Introduction To Micro-Processors & Micro-Controllers
Micro-controllers
Micro-processors
Micro-controllers
2
Micro-processors
A microprocessor is a computer processor which incorporates the functions of
a computer's Central Processing Unit (CPU) on a single integrated circuit (IC)
or at most a few integrated circuits.
The integration of a whole CPU onto a single chip or on a few chips greatly
reduced the cost of processing power, increasing efficiency.
3
Micro-controllers
A microcontroller (or MCU for MicroController Unit) is a small computer on a
single integrated circuit. In modern terminology, it is a System on a Chip (SoC).
Data Data
input processing output
Supercomputer
Mainframe Computer
Raspberry PI
Raspberry PI zero
iPad Pro
Computer Hardware
Main Hardware Components of a Processing Unit:
RAM Modules
13
Mainboard / Motherboard
Multi-Core CPU
A multi-core CPU consists of a multiple of these 3-unit-core in a
single chip so that multiple fetch-decode-execute (multi-threading)
can take place making computation faster and efficient.
17
Hardware vs. Software
Thus CPU continuously transfers data to and from the RAM.
Instructions/Data transfer to and from the CPU are done in units called
word (16 bit).
In addition to the registers, a CPU also has cache memories which are
used to store the instructions that are used by the CPU repeatedly or the
instructions in the pipeline (next executable instructions). Usually the
higher the amount of the cache memory, the better the CPU performs.
But cache memories are very expensive.
18
Hardware vs. Software
There are two types of CPU architecture* in wide use today:
• RISC (Reduced Instruction Set Computer) – ARM (v5, v6, v7) CPUs are
RISC ones. They support fewer instructions (often simpler ones) and are
power saver. So they are used in smart phones, tablet computers, etc.
This 4 GB RAM limit are avoided by 64-bit CPUs and 64-bit OSs.
➢ A 64-bit CPU/OS can keep track of 264 =18,446,744,073,709,551,616 byte (18
EB, i.e., 18 Giga GB) of RAM and 9 ZB (9 Giga TB) partition of HDD.
➢ In order to avail the 64-bit computing advantages, one must have both 64-bit
CPU and 64-bit OS.
[32-bit CPUs cannot run 64-bit OSs and 32-bit OSs cannot run 64-bit
software even if the CPU is 64-bit.]
26
Kilobyte KB 10 1,024
2
Megabyte MB 20 1,048,576
2
Gigabyte GB 30 1,073,741,824
2
Terabyte TB 40 1,099,511,627,776
2
27
Primary Memory
➢ Each bit of information (programming instructions/data) for
processing by the CPU is fetched from the RAM or stored back to
the RAM after/or during processing. Not only that, every devices
communicates to the CPU via its reserved area inside RAM
(allocated by the OS).
Computer Software
Hardware Abstraction
Layer (HAL)
Types of software
29
Hardware Abstraction Layer (HAL)
➢ The core component of an OS is its ‘kernel’. Kernel consists of
hardware device drivers which control the hardware at their lowest level.
➢ OSs also provide a set of API libraries/routines/framework to the user at a
higher level to use those hardware in an efficient way, thus increasing the
productivity of the programmer.
Software
Application Programs Systems Programs
CPU
33
Program
and
Data
Memory
(RAM)
CPU
An instruction "Read a data byte from memory and store it in the accumulator"
is executed as follows: -
Cycle 1 - Read Instruction
Cycle 2 - Read Data out of RAM and put into Accumulator
Block Diagram of MCU 34
CPU
Program Data
Memory Memory
Harvard Architecture 35
CPU
The same instruction (as shown under Neumann Architecture) would be executed as follows:
Cycle 1 / - Complete previous instruction & - Read the "Move Data to Accumulator" instruction
Cycle 2 / - Execute "Move Data to Accumulator" instruction & - Read next instruction
Hence each instruction is effectively executed in one instruction cycle. Thus, due to parallelism,
Harvard architecture executes more instructions in a given time compared to Neumann
Architecture.
36
Microprocessor vs. Microcontroller
Microprocessor Microcontroller
• CPU is stand-alone, RAM, • CPU, RAM, ROM, I/O and timer
ROM, I/O, timer are separate are all on a single chip
• designer can decide on the • fixed amount of on-chip ROM,
amount of ROM, RAM and RAM, I/O ports
I/O ports.
• for applications in which cost,
• expensive power and space are critical
• versatility
• single-purpose (control-oriented)
• general-purpose
• Low processing power
• High processing power
• High power consumption • Low power consumption
• Instruction sets focus on • Bit-level operations
processing-intensive • Instruction sets focus on control
operations and bit-level operations
• Typically 32/64 – bit • Typically 8/16 bit
• Typically deep pipeline (5-20 • Typically single-cycle/two-stage
stages)
pipeline
37
system bus
I/O
(serial line, Disk Network
keyboard, Interface
mouse)
standard interfaces
All the parts around the
processor are usually required
38
I/O custom
Interface ROM RAM logic
high-speed
interactions
Microcontroller (MCU)
• Primarily used in Embedded Systems
– Operations managed behind the scenes by
microcontroller(s)
• Microcontroller (MCU)
– Integrated electronic computing device that
includes three major components on a single
chip
• Microprocessor (CPU)
• Memory (RAM)
• I/O (Input/Output) ports
40
Microcontroller
• Besides the three main components, there are
some Support Devices:
– Timers
– A/D converter
– Serial I/O devices
• Common communication lines
– System Bus
– RS232
– JTAG
– I2C
– SPI
41
Microcontroller
• Input Devices
– Switches and Keypads
– Provide binary information to the MPU
– Analog or Digital
• Output devices
– LEDs and LCDs
– Receive binary information from the MPU
– PWM Signal Generators
Microcontrollers are used to create interactive systems through
programming which can take input from switches and sensors
and control physical outputs like lights, cameras, motors,
actuators or robots.
42
Typical Micro-controller Interfaces
Programmer
➢ Each MCU has its own unique PIN assignments which have to be learned from
its ‘datasheet’ supplied by its manufacturer.
➢ Each MCU series has its own hardware ‘programmer’ which needs to be
procured separately.
➢ Each MCU series has its own software programming language (many require
their own assembly language) or ‘IDE’ which needs to be learned.
➢ Each MCU series has its own customized development board to test logics.
43
Arduino
➢ Arduino is an open source
and free, hardware and
software specifications for
the Microcontroller Eco-
system.
➢ Arduino is an Italian
company, which initially
built these specifications
using an Atmel ATmega
Computer language evolution
MCU, coupled with a
language and IDE.
The benefits of Arduino eco-system are:
➢ The PIN assignments are sort of standardized, e.g. all Arduino compatible
MCUs support a digital output of 5 volts to an LED on their pin no. 13.
➢ Hardware programmers and Development boards (test-boards) are also
standardized.
➢ A single IDE with a simple language construct very similar to C is used.
44
Arduino
➢ Moreover, since the hardware and software specifications are open source
and free, many companies are manufacturing hardware programmer and
development boards at different levels of sophistication and they are
modestly priced.
➢ The primary mode of computer connection is via USB, serial or ethernet.
➢ Other manufacturers are also making their MCUs compatible with the
Arduino eco-system.
➢ Another huge benefit ofComputer
Arduinolanguage evolution
eco-system is the wide availability of
many shields, which are electronic circuit boards which can be plugged-
into the Arduino boards to extend its functionality.
➢ With Arduino shields, motors and servos can be controlled without a
separate drive circuits.
➢ Arduino shields are also available to build even cell-phones, mp3 players,
simple robots, etc. using Arduino.
45
Arduino
Arduino Shields
➢ Arduinos are facilitating the development of many ‘Internet of Things
(IoT) devices’ which are programmable devices connected to the internet
and capable of sharing information over the internet such as smart energy
meters, smart thermostats, smart refrigerators, smart cars, etc.
46
Arduino – An Introduction
Clock Chip
Programmer Chip
ATmega328 MCU
Computer language evolution
USB and DC
Connectors
48
Arduino
Arduino IDE
51
Arduino
Four Steps to develop MCU-based System:
void loop() { // the loop function runs over and over again forever
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage
//level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage
//LOW
delay(1000); // wait for a second
}
54
Arduino
4. Assemble the physical circuit and testing and
debugging the code and the circuit.
• NodeMCU 1.0
• Built-in ESP8266,
”ESPduino”
• Works with Arduino IDE,
not officially though
• 12 V regulator for input
voltage
• Price: 5 – 10 €
• 13 GPIO, only one PWM
and ADC (0-1 V)
• Pins work with 0 – 3.3 V
Other Capabilities
• Anything starting from programming, office suite,
web server, games, streaming media server, IoT
devices and even supercomputers are made using
Raspberry Pi.
Some Raspberry Pi Projects
Digital Clock
PiBot!
Supercomputer