Embedded systems and Microcontroller basics
What we will understand:
1] Embedded system definition
2] Features of Embedded system
3] Microprocessor vs Microcontroller
4] Types of CPU architecture
5] RISC and CISC Architecture for CPU
6] Compiler
7] Debugger, Simulator, and Emulator
8] Address bus, Data bus, and Control Bus
9] 8 bit, 16 bit, 32-bit Controllers
10] What other components do a basic embedded system
require?
Before starting this topic, I would like the reader to
know that he should have basic knowledge of Electronics and Computers. Like
what is basically a microcontroller or a microprocessor and some terms like the
OS, how does an ALU or microcontroller or processor processes? Just a brief understanding
of such topics should be great.
1] Embedded system:
An embedded system is a combination of mechanical,
electrical, and electronic hardware and software designed for a specific
function. It is a system that is placed in another system. A simple system
can be defined as input, processing, and output. Further, there comes a part
of the feedback and then sensing. Now, for embedded systems, it's not like the
computer which does the general-purpose tasks. It is different than Computer systems. For example, a computer is a general system where at the same
time we can play music, handle some of the applications (like in a windows PC
it might) be an excel sheet and Chrome with some software for downloading and
at the same time we would be coding in Anaconda or IntelliJ, etc. So, here, there
is no certain task which of high priority or something that is not given prime
importance rather the others. For example, if we consider a Mobile, its first
priority is to receive calls, and later comes the other stuff like the applications
it is playing.
An embedded system is something that senses something
through a sensor, processes it through its brain or microcontroller, and acts or
outputs something depending on it. For example, we have a simple rear parking
sensor in an automobile. Considering reversing the car scenario, once the
vehicle's reverse gear is engaged the sensor is activated and it monitors
continuously, they are usually ultrasonic sensors that emit the high
frequencies waves, and the time it takes to receive these waves back will
determine the distance. This is calculated in the small microcontroller and the
distance in meters is pushed on the display. So we have a sensor to get the
input to the microcontroller, a microcontroller that processes this sensor
data and the output, which is the distance before an impact.
2] Features of Embedded system:
- Embedded system performs a specialized task and performs that repeatedly.
- The system has to be real-time and reactive to the environment with which it works.
- Tightly connected to the memory, peripherals, sensors, and processing fast. No delay in achieving a specialized task that is recommended.
- There is a concept known as hard real-time and soft real-time. Most of the Embedded systems are hard real-time(also known as mission-critical), which means it has to process certain inputs and provide output within a limited time. For soft real-time, it's not the same.
- Power consumption is always at a price. Limited power consumption, as majorly such systems are to be considered in standalone systems.
- It should be efficient and reliable.
- It should also be secure and safe.
3] Microprocessor vs Microcontroller:
Most of the Embedded systems use Microcontrollers to
achieve the tasks, very few of the Embedded systems use Microprocessors. Let
us know about the basic differences.
4] Types of CPU architecture:
Be it Microcontroller or Microprocessor it has to have a
CPU, the brain of these chips. The basic differences in these are the Von
Neumann architecture and the Harvard architecture.
The basic differences are as shown in the diagram below
So, the basic difference between a Von Neumann architecture is
that it has the same memory for the Data and code. In Harvard architecture the Data
and Program or code memories are different. The code which runs the instruction
is in different memory area and the data which is used for running this code is
stored at different location of the memory as separate entities.
Another type of architecture: SHARC(Super Harvard
Architecture)
Some of the advanced architectures are as shown below:
A DSP SHARC architecture:
From the above architecture diagrams, it is clear that there
are various advances in the CPU architectures. Although not a lot of
information to digest, we would not get into the details.
5] RISC and CISC Architecture for CPU:
For a CPU, the Architectures depending on the instruction
set and use of the processor is done in a certain way which lets another
classification of the architecture known as RISC(Reduced instruction set
computing) and CISC(Complex instruction set computing) architectures
respectively. RISC has simple instructions which almost take only a single cycle
for execution. Now, what does it mean when we say one cycle for execution, this
is the frequency at which the CPU takes the input, processes it, and provides the
output. So, technically a microcontroller has a crystal or RC oscillator which
is responsible for the clocking of the processor or controller. We can think of
oscillator and operation cycles as the pumping process of the heart. The brain being the Microcontroller or the processor.
Moving on with the RISC and CISC architectures, CISC
takes complex instructions and more than one operation cycle. RISC has fixed
format instructions whereas CISC has variable format instructions. RISC relies
more on the software for execution it is a software-centric design whereas CISC
is Hardware centric design of architecture. CISC uses memory cautiously,
RISC uses the memory heavily.
6] Compiler:
In an embedded system, majorly the used programming
languages have to be very efficient, safe, and well-controlled. The majority of
these use C, C++. Coming to the compiler, a compiler is a computer program that
translates computer code written in one programming language into another
language. The name "compiler" is primarily used for programs that
translate source code from a high-level programming language to a lower-level
language to create an executable program.
We come across a terminology called Native and cross
compiler:
1. Native Compiler :
Native compilers are compilers that generate code for the
same platform on which it runs. It converts high language into computer’s
native language. For example Turbo C or GCC compiler
2. Cross compiler :
A Cross compiler is a compiler that generates executable
code for a platform other than one on which the compiler is running. For
example, a compiler that runs on Linux/x86 box is building a program that
will run on a separate Arduino/ARM.
Embedded systems majorly use cross compilers.
Compilation process:
7] Debugger, Simulator and Emulator:
Debugger: A debugger or debugging tool is a computer program used
to test and debug other programs (the "target"
program). The main use of a debugger is to run the target program under
controlled conditions that permit the programmer to track its operations in
progress and monitor changes in computer resources (most often memory areas
used by the target program or the computer's operating system) that may indicate
malfunctioning code.
Simulator: Code is tested for the MCU / system by
simulating it on the host computer used for code development. Simulators try to
model the behavior of the complete microcontroller in software.
Emulator:
An emulator is a hardware device or software program that
enables one computer system (also known as a host) to imitate the functions of
another computer system (known as the guest). It enables the host system to run the software, tools, peripheral devices, and other components which are designed for
the guest system. Emulators can be of different types, replicating things such
as hardware, software, OS, or CPU.
Today, the use of the terms emulator and debugger seems
to be interchangeable.
An in-circuit emulator (ICE) provides a window into the
embedded system. The programmer uses the emulator to load programs into the
embedded system, run them, step through them slowly, and view and
change data used by the system's software.
An emulator gets its name because it emulates
(imitates) the central processing unit (CPU) of the embedded system's
computer. Traditionally it had a plug that inserts into the socket where the
CPU integrated circuit chip would normally be placed. Most modern
systems use the target system's CPU directly, with special JTAG-based debug
access. Emulating the processor, or direct JTAG access to it lets the ICE do
anything that the processor can do but under the control of a software
developer.
8] Address bus, Data bus, and Control Bus:
There are normally three types of bus in any processor
system:
1] An address bus: this determines the location in
memory that the processor will read data from or write data to.
2] A data bus: this contains the contents that have
been read from the memory location or are to be written into the memory location.
3] A control bus: this manages the information flow
between components indicating whether the operation is a read or a write and
ensuring that the operation happens at the right time.
9] 8 bit, 16 bit, 32-bit Controllers:
So the bits represent the Data bus length, registers size, and the instruction. Now, as the bus width increases the number of cycles to
complete certain tasks decreases. Making the 32-bit controllers the fastest.
Considering the cost there are no huge differences as such. The CPU performs 8
bit operations on the 8-bit microcontroller, similarly 16 bit and 32-bit
operations for 16 bit and 32-bit microcontroller as such. 32-bit controllers
give the best precision. Also, larger the number of bits more is the range for the
address bus. The register size does become big but it also leads to more
packing of features in the 32-bit controller.
10] What other components do a basic embedded system
require?
1] Power supply (regulated)
2] PCB: PCB or development kit containing
circuit having resistors, pulled up or down, capacitors,
Crystal Oscillator, LED's, Microcontroller, Sensors, ASIC's, JTAG or debug pin,
DB9's or other pins whichever required according to the board being used, LCD
or LED small display if required and many others depending on the application
3] Schematics
4] Oscilloscope
5] Debugger or Emulator
6] Software for debugging or ICE(In Circuit Emulation)
7] Multimeter (and if required a soldering gun)
8] Connecting wires from the Development board to PC and
if any other hardware
Embedded software is fun and challenging to learn stay
for more such posts!!
Comments
Post a Comment