Professional Documents
Culture Documents
6B13ELE:
EMBEDDED SYSTEMS BASICS
Dr Jinesh Mathew
MSc., MPhil., PhD, Post Doc
INTRODUCTION TO EMBEDDED SYSTEMS
An embedded system is an electronic/electro-mechanical system designed to perform
a specific function and is a combination of both hardware and firmware(software).
Every embedded system is unique, and the hardware as well as the firmware is highly
specialised to the application domain.
An embedded system is designed to run on its own without human intervention, and
may be required to respond to events in real time.
Application Areas
• TV
• stereo
• remote control
• phone / mobile phone
• refrigerator
• microwave
• washing machine
• electric tooth brush
• oven / rice or bread cooker
• watch
• alarm clock
• electronic musical instruments
• electronic toys (stuffed animals,handheld toys, pinballs, etc.)
• medical home equipment (e.g. blood
pressure, thermometer)
•…
• [PDAs?? More like standard computer system]
Consumer Products
Application Areas
• Medical Systems
– pace maker, patient monitoring systems,
– injection systems, intensive care units, …
• Office Equipment
– printer, copier, fax, …
• Tools
– multimeter, oscilloscope, line tester, GPS, …
• Banking
– ATMs, statement printers, …
• Transportation
– (Planes/Trains/[Automobiles] and Boats)
• radar, traffic lights, signalling systems, …
Application Areas
• Automobiles
– engine management, trip computer (fuel
cons. etc), cruise control, immobilizer
and keyless entry, car alarm,
– airbag, ABS, Electronic steering, …
• Building Systems
– elevator, heater, air conditioning,
lighting, key card entries, locks, alarm
systems, …
• Agriculture
– feeding systems, milking systems, …
• Space
– satellite systems, …
Categories of embedded systems
Components of an Embedded System
• An embedded system has three main components : Hardware,
Software and Real time operating system
i) Hardware:
• Power Supply
• Processor
• Memory
• Timers
• Serial communication ports
• Output/Output circuits
• System application specific circuits
Components of an Embedded System…
ii)Software: The application softwar
Software architecture
e is required to perform the series o
f tasks.
• The ARM architecture is a widely used 32-bit RISC processor architecture. In fact, the ARM
family accounts for about 75% of all 32-bit CPUs, and about 90% of all embedded 32-bit
CPUs. ARM Limited licenses several popular microprocessor cores to many vendors (ARM
does not sell physical microprocessors). Originally ARM stood for Advanced RISC Machines.
ARM Microprocessors
• Some cores offered by ARM:
• ARM7TDMI
• ARM9
• ARM11
• Some examples of ARM based processors:
• Intel X-Scale (PXA-255 and PXA-270), used in Palm PDAs
• Philips LPC2000 family (ARM7TDMI-S core), LPC3000 family (ARM9 core)
• Atmel AT91SAM7 (ARM7TDMI core)
• ST Microelectronics STR710 (ARM7TDMI core)
• Freescale MCIMX27 series (ARM9 core)
• The lowest-cost ARM processors (in the LPC2000 series) have dropped
below US$ 5 in ones, which is less than the cost of many 16-bit and 8-bit
microprocessors.
PIC microcontroller
• PIC (usually pronounced as "pick") is a family of microcontrollers made
by Microchip Technology, derived from the PIC1650 originally developed
by General Instrument's Microelectronics Division. The name PIC initially
referred to Peripheral Interface Controller. The first parts of the family were
available in 1976; by 2013 the company had shipped more than twelve billion
individual parts, used in a wide variety of embedded systems.
• Early models of PIC had read-only memory (ROM) or field-programmable
EPROM for program storage, some with provision for erasing memory. All
current models use flash memory for program storage, and newer models allow
the PIC to reprogram itself. Program memory and data memory are separated.
Data memory is 8-bit, 16-bit, and, in latest models, 32-bit wide. Program
instructions vary in bit-count by family of PIC, and may be 12, 14, 16, or 24 bits
long. The instruction set also varies by model, with more powerful chips adding
instructions for digital signal processing functions.
PIC microcontroller
• The hardware capabilities of PIC devices range from 6-pin SMD, 8-pin DIP chips
up to 144-pin SMD chips, with discrete I/O pins, ADC and DAC modules, and
communications ports such as UART, I2C, CAN, and even USB. Low-power and
high-speed variations exist for many types.
• The manufacturer supplies computer software for development known
as MPLAB X, assemblers and C/C++ compilers, and programmer/debugger
hardware under the MPLAB and PICKit series. Third party and some open-
source tools are also available. Some parts have in-circuit programming
capability; low-cost development programmers are available as well as high-
production programmers.
• PIC devices are popular with both industrial developers and hobbyists due to
their low cost, wide availability, large user base, extensive collection of
application notes, availability of low cost or free development tools, serial
programming, and re-programmable Flash-memory capability.
PIC microcontroller
• The PIC architecture is characterized by its multiple attributes:
• Separate code and data spaces (Harvard architecture).
• A small number of fixed-length instructions
• Most instructions are single-cycle (2 clock cycles, or 4 clock cycles in 8-bit models), with one
delay cycle on branches and skips
• One accumulator (W0), the use of which (as source operand) is implied (i.e. is not encoded in
the opcode)
• All RAM locations function as registers as both source and/or destination of math and other
functions.[22]
• A hardware stack for storing return addresses
• A small amount of addressable data space (32, 128, or 256 bytes, depending on the family),
extended through banking
• Data-space mapped CPU, port, and peripheral registers
• ALU status flags are mapped into the data space
• The program counter is also mapped into the data space and writable (this is used to
implement indirect jumps).
• There is no distinction between memory space and register space because the
RAM serves the job of both memory and registers, and the RAM is usually just
referred to as the register file or simply as the registers.
Programming languages and tools for Embedded systems
• Embedded system software.
• Assembly languages, high level languages.
• Embedded C programming ( Eg: Kiel C, Microchip C, SDCC Compiler).
• PIC in keil C (uVision IDE).
Stack
• When an interrupt occurs, first the PIC microcontroller has to execute
the interrupt and the existing process address. Then that is being
executed is stored in the stack. After completing the execution of the
interrupt, the microcontroller calls the process with the help of
address, which is stored in the stack and get executes the process.
I/O Ports
• The series of PIC16 consists of five ports such as Port A, Port B, Port C,
Port D & Port E.
• Port A is an 6-bit port that can be used as input or output port based
on the status of the TRISA (Tradoc Intelligence Support Activity)
register.
• Port B is an 8- bit port that can be used as both input and output
port.
• Port C is an 8-bit and the input of output operation is decided by the
status of the TRISC register.
• Port D is an 8-bit port acts as a slave port for connection to the
microprocessor BUS.
• Port E is a 3-bit port which serves the additional function of the
control signals to the analog to digital converter.
BUS
• BUS is used to transfer and receive the data from one peripheral to
another. It is classified into two types such as data bus and address
bus.
• Data Bus: It is used for only transfer or receive the data.
• Address Bus: Address bus is used to transmit the memory address
from the peripherals to the CPU. I/O pins are used to interface the
external peripherals; UART and USART both are serial communication
protocols which are used for interfacing serial devices like GSM, GPS,
Bluetooth, IR , etc.
BUS
A/D converters
• The main intention of this analog to digital converter is to convert analog voltage values to
digital voltage values. A/D module of PIC microcontroller consists of 5 inputs for 28 pin devices
and 8 inputs for 40 pin devices. The operation of the analog to digital converter is controlled by
ADCON0 and ADCON1 special registers. The upper bits of the converter are stored in register
ADRESH and lower bits of the converter are stored in register ADRESL. For this operation, it
requires 5V of an analog reference voltage.
Timers/ Counters
• PIC microcontroller has four timer/counters wherein the one 8-bit
timer and the remaining timers have the choice to select 8 or 16-bit
mode. Timers are used for generating accuracy actions, for example,
creating specific time delays between two operations.
Interrupts
• PIC microcontroller consists of 20 internal interrupts and three
external interrupt sources which are associated with different
peripherals like ADC, USART, Timers, and so on.
Serial Communication
• Serial communication is the method of transferring data one bit at a time sequentially over a
communication channel.
• USART: The name USART stands for Universal synchronous and Asynchronous Receiver and
Transmitter which is a serial communication for two protocols. It is used for transmitting and
receiving the data bit by bit over a single wire with respect to clock pulses. The PIC
microcontroller has two pins TXD and RXD. These pins are used for transmitting and receiving
the data serially.
• SPI Protocol: The term SPI stands for Serial Peripheral Interface. This protocol is used to send
data between PIC microcontroller and other peripherals such as SD cards, sensors and shift
registers. PIC microcontroller support three wire SPI communications between two devices on
a common clock source. The data rate of SPI protocol is more than that of the USART.
• I2C Protocol: The term I2C stands for Inter Integrated Circuit , and it is a serial protocol which
is used to connect low speed devices such as EEPROMS, microcontrollers, A/D converters, etc.
PIC microcontroller support two wire Interface or I2C communication between two devices
which can work as both Master and Slave device.
Serial Communication
Oscillators
• Oscillators are used for timing generation. Pic microcontroller consist
of external oscillators like RC oscillators or crystal oscillators. Where
the crystal oscillator is connected between the two oscillator pins.
The value of the capacitor is connected to every pin that decides the
mode of the operation of the oscillator. The modes are crystal mode,
high-speed mode and the low-power mode. In case of RC oscillators,
the value of the resistor & capacitor determine the clock frequency
and the range of clock frequency is 30KHz to 4MHz.
CCP module
• The name CCP module stands for capture/compare/PWM where it works
in three modes such as capture mode, compare mode and PWM mode.
• Capture Mode: Capture mode captures the time of arrival of a signal, or
in other words, when the CCP pin goes high, it captures the value of the
Timer1.
• Compare Mode: Compare mode acts as an analog comparator. When the
timer1 value reaches a certain reference value, then it generates an
output.
• PWM Mode: PWM mode provides pulse width modulated output with a
10-bit resolution and programmable duty cycle.
PIC Microcontroller Applications
• The PIC microcontroller projects can be used in different applications, such as
peripherals, audio accessories, video games, etc. For better understanding of this
PIC microcontroller, the following project demonstrates PIC microcontroller’s
operations.
Street Light that Glows on Detecting Vehicle Movement:
• The main intention of this project is to detect the movement of vehicles on
highways to switch on a block of street lights ahead of it, and also switch off the
trailing lights to conserve energy. In this project, a PIC microcontroller is done by
using assembly language or embedded C.
• The power supply gives the power to the total circuit by stepping
down, rectifying, filtering and regulating AC mains supply. When there
are no vehicles on highway, then all lights will turn OFF so that the
power can be conserved. The IR sensors are placed on the road to
sense the vehicle movement. When there are vehicles on highway,
then the IR sensor senses the vehicle movement immediately, it
sends the commands to the PIC microcontroller to switch ON/OFF the
LEDs. A bunch of LEDS will be turned on when a vehicle come near to
the sensor and once the vehicle passes away from the sensor the
intensity will become lower than the LEDs will turn OFF
Advantages of PIC Microcontroller:
• PIC microcontrollers are consistent and faulty of PIC percentage is very
less. The performance of the PIC microcontroller is very fast because of
using RISC architecture.
• When comparing to other microcontrollers, power consumption is very
less and programming is also very easy.
• Interfacing of an analog device is easy without any extra circuitry
(viii) Miscellaneous
• BSF f,b : Set bit b of register f
• SLEEP : Go into stand by mode
• NOP : No operation i.e Do nothing , wait one clock cycle.
Instruction Execution Period
• All instructions are executed in one cycle except for conditional
branch instructions if condition was true, or if the contents of
program counter was changed by some instruction. In that case,
execution requires two instruction cycles, and the second cycle is
executed as NOP (No Operation).
• Four oscillator clocks make up one instruction cycle.
• If we are using an oscillator with 4MHz frequency, the normal time for
executing an instruction is 1 µs, and in case of conditional branching,
execution period is 2 µs.
TIMER MODULES:
• There are three completely independent Timers available in PIC
16F8XX Microcontrollers. They are
• Timer 0
• Timer 1 and
• Timer 2
Timer 0:
• The Timer 0 module is a simple 8-bit overflow counter.
• The clock source can be either the internal system clock (Fosc/4) or an
external clock. When the clock source is an external clock, the Timer0
module can be selected to increment on either the rising or falling edge.
• The Timer 0 module also has a programmable prescaler option. This
prescaler can be assigned to either the Timer0 module or the Watchdog
Timer. Bit PSA assigns the prescaler and bits PS2:PSO determine the
prescaler value.
• TMR0 can increment at the following rates:1:1 when the prescaler is
assigned to Watchdog Timer, 1:2, 1:4, 1:8, 1:16, 1:32, 1:64, 1:128and 1:256.
• Synchronization of the external clock occurs after the prescaler. When the
prescaler is used, the external clock frequency may be higher than the
device’s frequency.
• The maximum frequency is 50 MHz, given the high and low time
requirements of the clock.
Timer 1
• Timer1 is a 16-bit timer/counter.
• The clock source can be either the internal systemclock (Fosc/4), an external
clock, or an external crystal.
• Timer1 can operate as either a timer or a counter.
• When operating as a counter (external clock source), the counter can
either operate synchronized to the device or asynchronously to the device.
• Asynchronous operation allows Timer1 to operate during sleep, which is
useful for applications that require a real-timeclock as well as the
power savings of SLEEP mode.
• Timer 1 also has a prescaler option, which allows TMR1 to increment at the
following rates: 1:1, 1:2, 1:4 and 1:8 TMR1 can be used in conjunction with
the Capture/Compare/PWM module.
• When used with a CCP module, Timer1 is the time-base for 16-bit capture
or 16-bit compare and must be synchronized to the device.
Timer 2
• Timer 2 is an 8bit timer with a programmable prescaler and a programmable
postscaler, as well as an 8- bit Period Register (PR2).
• Timer 2 can be used with the CCP module (in PWM mode) as well as the Baud
Rate Generator for the Synchronous Serial Port(SSP).
• The prescaler option allows Timer2 to increment at the following rates: 1:1,
1:4 and 1:16.
• The post scaler allows TMR2 register to match the period register (PR2) a pro
grammable number of times before generating an interrupt.
• The postscaler can be programmed from 1:1 to 1:16 (inclusive).
WATCH DOG TIMER (WDT):
• The Watchdog Timer is a free running on-chip RC oscillator which does
not require any external components.
• This RC oscillator is separate from the RC oscillator of theOSC1/CLKIN
pin. That means that the WDT will run, even if the clock on the
OSC1/CLKIN and OSC2/CLKOUT pins of the device has been stopped, for
example, by execution of a SLEEP instruction.
• During normal operation, a WDT time-out generates a device reset. If the
device is in SLEEP mode, a WDT time-out causes the device to wake-up
and continue with normal operation.
• The WDT can be permanently disabled by clearing configuration bit
WDTE.
WDT PERIOD:
• The WDT has a nominal time-out period of 18 ms, (with no prescaler).
• The time-out periods vary with temperature, VDD and process variations from
part to part (see DC specs).
• If longer time-out periods are desired, a prescaler with a division ratio of up to
can be assigned to the WDT under software control by writing to the OPTION
register. Thus, time-out periods up to seconds can be realized.
• The CLRWDT and SLEEP instructions clear the WDT and the postscaler, if
assigned to the WDT, and prevent it from timing out and generating a device
RESET condition.
• The TO bit in the STATUS register will be cleared upon a WDT time-out.
• WDT PROGRAMMING CONSIDERATIONS:
It should also be taken in account that under worst case conditions (VDD=
Min., Temperature = Max., max WDT prescaler) it may take several seconds
before a WDT time-out occurs.
Module 3
• Embedded system software.
• Assembly languages, high level languages.
• Embedded C programming ( Eg: Kiel C, Microchip C and SDCC Compiler).
• Data types, variables, port accessing, function.
• PIC in keil C (uVision IDE).
• Simple programs -LED blinking, LCD, Serial port.
• Embedded communication standards
• RS232, I2C, SPI ,USB (Over view).
• Case study of Traffic Light controller, Water level controller, DC Motor
speed control.
• Electronics manufacturing process, circuit designing, Programming, PCB
designing using software.
Differences b/n standard/ANSI C and Embedded C
• Included files
• Special function registers
• Super Loop
• Extensions to storage classes
• Special keywords must be used to specify a function as an interrupt service
routine
Difference b/n standard/ANSI C and Embedded C
• Storage classes
• Embedded C combilers supports the standard ANSI C data types
• char
• short
• int
• long
• float
• Extensions to storage classes
• Near/data
• Idata
• Far/xdata
• Pdata
• Bit
• Sfr
• Sbit
• code
Embedded C
• Programs written in C are much easier to develop and maintain than the
ones written in Assembly language
• Embedded C is a superset of standard ANSI C. Embedded C includes special
keywords to access the special features of the microcontroller for which the
program is being written.
• Due to the absence of an operating system, we use super loops while
writing C programs for microcontrollers.
• Certain keywords allow variables in C programs to be declared in the desired
memory spaces of the MCS-51 based microcontroller. These are called
storage classes. We can inform the compiler to use a default storage class for
all variables in a C program by specifying a memory model to use when
compiling the program.
Embedded C
• We can use absolute addressing for placing variables at a given address in
the external RAM
• We can manipulate individual bits of a byte-wide variable or register using
bitwise logical operators.
• Special keywords must be used to specify a function as an interrupt service
routine.
• Assembly language code can be mixed with C language code by using special
keywords.
Embedded C : sample questions
• Write three examples of embedded C compilers
• What are the main differences between the standard C and the
embedded C
• What is super loop? Why do we need super loops while writing C
programs for microcontrollers?
• What are the various storage classes that can be used with SDCC? In
which memory space are the variables placed as per each of these
storage classes.
Embedded C
• Example programs (printouts given earlier in the class)
• Blinking of LED
• Interfacing switch and LED
• Interfacing of LCD
• Serial communication
6B03ELE-P: Embedded System Practical (Practical-3)
• Linux may require more system resources than some other embedded operating
systems but has a highly-tested stable kernel, is completely open source code, and
a zero distribution cost.