You are on page 1of 36

Faculty of Engineering and Technology

Mechanical Engineering Department

Lecture 1

CMP 456:
Design of Real-Time Embedded Systems

Prepared by:
Dr. Mohamed Ali Torad
Mohamed.torad@gmail.com
Course Objectives and Outlines

Code: CMP 456

•Credit Hours: 2

•Objectives:
Provide the student with the capability to analyze, design, interface,
program, hardware assembly, integration, and testing of the real-time
embedded systems.

•Description
Introduction to bus architectures and programming; Device and system
firmware; Arduino and I/O architectures; Memory architectures;
Interrupt service routines; Real-time clocks/timers; Real-time debugging
techniques and tools; Development and testing techniques.
CMP 456 Eng. Mohamed Ali Torad 2
Textbook and References

CMP 456 Eng. Mohamed Ali Torad 3


Grading

CMP 456 Eng. Mohamed Ali Torad 4


Course Content
Week Topic No. of hours Lecture Tutorial Practical

1 Introduction to embedded systems 4 2 1


2 Introduction to AT mega 2560 4 2 1
3 Pulse Width Modulation (PWM) 4 2 1
4 4 2 1
5 4 2 1
6 4 2 1
7 Semester First Exam - - -
8 4 2 1
9 4 2 1
10 4 2 1
11 4 2 1
12 4 2 1
13 4 2 1
14 Final Semester exam - - - -

Logic Design (1) Dr. Mohamed A. Torad 5


Polices- Academic Honesty

• All work must be yours

• Do not share code with classmates

• Do not plagiarize code from the Internet

Logic Design (1) Dr. Mohamed A. Torad 6


Logic Gates

• AND gate

• OR gate

CMP 456 Eng. Mohamed Ali Torad 7


Logic Gates(cont.)

• Inverter

• XOR gate

CMP 456 Eng. Mohamed Ali Torad 8


Logic Gates(cont.)

• NAND gate

• NOR gate

CMP 456 Eng. Mohamed Ali Torad 9


Logic Design Using Gates

• Half adder

CMP 456 Eng. Mohamed Ali Torad 10


Logic Design Using Gates(cont.)

• Full adder

CMP 456 Eng. Mohamed Ali Torad 11


Logic Design Using Gates(cont.)

• 4-bit adder

CMP 456 Eng. Mohamed Ali Torad 12


The Difference between microprocessor and microcontroller

MICROCONTROLLER MICROPROCESSOR
Advantages: Advantages:

1. all components or devices on one chip (embedded system) 1. Very high speed system

2. Low cost. 2. All peripheral can be upgraded, replacement or extended.

3. Low power consumption. 3. Using it for solve a very complicated mathematical or


algorithmic equations. (Complex production lines)

Disadvantages: Disadvantages:

1. Low speed. 1. Very expensive system.

2. Can’t upgrade any peripherals. 2. High power consumption

3. Very bulker or complicated system (need mother board)


Application: Application:

1. Car keys. 1. Servers.

2. Mobiles. 2. Mobiles.

3. Intercom. 3. Sophisticated production lines.

4. TV 4. Mainframes.

5. Toys. 5. Personal computers.


The Difference between microprocessor and microcontroller(cont.)

• Microprocessor block diagram

CMP 456 Eng. Mohamed Ali Torad 14


The Difference between microprocessor and microcontroller(cont.)

• Microcontroller block diagram

CMP 456 Eng. Mohamed Ali Torad 15


The criteria for choosing microcontroller

1. Task meeting and efficiency


• 8 bit or 16 bit or 32 bit microprocessor data bus.
• Number of I/O of microcontroller.
• The size of program memory (ROM).
• The size of (RAM) and (registers).
• Power consumption (low or high).
• Package size DIP or QFP.
• ADC resolution.
• Serial com baud rate and protocol SPI/I^2/UARC.
• Speed of crystal and machine cycle.
• Cost for every wait.

CMP 456 Eng. Mohamed Ali Torad 16


The criteria for choosing microcontroller(cont.)

2. Software developer
• Assembler
• Disassemble
• Simulation (MP lap – protues)
• Emulation (hardware and software)
• Debugger
3. Availability for using and famous
Now we will say that the microcontroller has three types of
range to work of it:
• 1- Low range like: PIC 10Fxxx , PIC 12Fxxx
• 2- Mid range like: PIC 14Fxxx , PIC 16Fxxx & PIC 18Fxxx
• 3- High range like: PIC 32Fxxx , PIC 17Fxxx . PIC 24Fxxx

CMP 456 Eng. Mohamed Ali Torad 17


RISC(reduced instruction set computer) CISC(complex instruction set computer)

Low instruction set (35 instruction set) high instruction set (more than 200
instruction set)

HARVARD
ARCHITECTURE VON-NEUMANN
ARCHITECTURE

Data bus and address buses are separated so Data bus and address bus are collected on
we can read the next instruction while the same bus
executing previous instruction
All instructions occupies 1 machine cycle Can’t know exactly the how many byte used
except branch instruction(jump instructions)
High speed Low speed
Microcontroller MFGRs
•AMCC ! •Holtek! •Silabs!
•Atmel! •Infineon! •Silicon Motion!
•Comfile Technology •Intel!
Inc.! •Microchip •STMicroelectronics!
•Coridium! Technology! •Texas Instruments!
•Cypress •National •Toshiba!
MicroSystems! Semiconductor! •Western Design
•Dallas •NEC!
•Parallax, Inc.! Center!
Semiconductor !
•Elba Corp.! •Philips •Ubicom!
•Freescale Semiconductors! •Xemics!
Semiconductor ! •PICAXE! •Xilinx!
•Fujitsu! •Renesas •ZiLOG
Technology!
CMP 456 Eng. Mohamed Ali Torad 19
Why the Arduino?

Improvement over other micro-controllers for hobby usage!

• Inexpensive!

• IDE on multiple platforms (Mac, PC, Linux)!

• Simple, clear programming environment: “C”!

• Open source and extensible software/hardware!

• Arduino Shields

CMP 456 Eng. Mohamed Ali Torad 20


Arduino Shields
• VGA camera! • Load Cell!

• GPS! • Accelerometer/Gyros!

• LCD displays! • LED displays!

• Ethernet! •Memory Cards!

•WiFi! •Weather Sensors!

•Motor control • Relays!

• (dc, stepper) ! •Mobile Robot


CMP 456 Eng. Mohamed Ali Torad 21
Arduino

CMP 456 Eng. Mohamed Ali Torad 22


Arduino

Arduino Uno board.

CMP 456 Eng. Mohamed Ali Torad 23


Arduino Uno board.

• The Arduino/Genuino Uno has an onboard ATmega328


microcontroller.

• It has onboard six analog input ports (A0–A5). Each pin can operate
at 0–5 V.

• It has 14 digital input/output (I/O) pins out of which 6 are PWM


output, 6 analog inputs

• 2 KB SRAM, 1 KB EEPROM, and operates at 16 MHz of frequency.

CMP 456 Eng. Mohamed Ali Torad 24


Arduino Uno board.
Pin Name Description
Vin The external voltage to the Arduino board
+5 V +5 V regulated output
3.3 V On board 3.3 V supply
GND Ground
IOREF Provides the voltage reference and select appropriate power source
Serial Transmits and receives serial data, Pins: 0(Rx) 1(Tx)
External interrupts Trigger an interrupt on low value, Pins: 2 and 3
PWM Provides 8 bit PWM output, Pins: 3,5,6,9,10,11
SPI Supports SPI communication, Pins: 10 (SS), 11 (MOSI), 12 (MISO), and 13
(SCK)
LED LED driven by Pin 13
TWI Supports TWI communication, Pins: A4 (SDA), A5 (SCL)
AREF Reference voltage for the analog inputs
Reset It is used to reset the onboard microcontroller
CMP 456 Eng. Mohamed Ali Torad 25
Arduino

Arduino Mega board.

CMP 456 Eng. Mohamed Ali Torad 26


Arduino Mega board.
• The Arduino Uno has onboard ATmega2560 microcontroller.

• It has onboard 16 analog inputs, 54 digital I/O, USB connection, 4


UART, power jack, and a reset button.

• It operates at 16 MHz frequency.

• The board can be operated with 5–12 V of external power; if supplied


more than this, it can damage the board.

• It has onboard 256 KB flash memory, 8 KB SRAM, and 4 KB


EEPROM

CMP 456 Eng. Mohamed Ali Torad 27


Pin Name Description Arduino Mega board.
Vin The external voltage to the Arduino board
+5 V +5 V regulated output
3.3 V On board 3.3 V supply
GND Ground
IOREF Provides the voltage reference and select appropriate power source
Serial0 Transmits and receives serial data, Pins: 0(Rx) 1(Tx)
Serial1 Transmits and receives serial data, Pins: 19(Rx) 18(Tx)
Serial2 Transmits and receives serial data, Pins: 17(Rx) 16Tx)
External interrupts Trigger an interrupt on low value, Pins: 2 (interrupt0), 3 (interrupt1),
18 (interrupt5), 19 (interrupt4), and 20 (interrupt2)
PWM Provides 8 bit PWM output, Pins: 2–13 and 44–46
SPI Supports SPI communication, Pins: 53 (SS), 51 (MOSI), 50 (MISO),
and 52 (SCK)
LED LED driven by Pin 13
TWI Supports TWI communication, Pins: 20 (SDA), 21 (SCL)
AREF Reference voltage for the analog inputs
ResetCMP 456 Eng. Mohamed Ali Torad
It is used to reset the onboard microcontroller 28
Arduino

Arduino Nano board.


CMP 456 Eng. Mohamed Ali Torad 29
Arduino Nano board.

• The Arduino/Genuino Nano has onboard ATmega328 microcontroller.

• It has onboard 8 analog and 14 digital I/O ports and 6 PWM of 8 bit.

• Each pin can operate at 0–5 V.

• It has onboard 32 KB flash memory, 2 KB SRAM, 1 KB EEPROM,


and operates at 16 MHz of frequency.
Endurance:
10,000 write for Flash memory
1,000,000 write for EEPROM memory
100 year data stored

CMP 456 Eng. Mohamed Ali Torad 30


Arduino Nano board.
Pin Name Description
Vin The external voltage to the Arduino board
+5 V +5 V regulated output
3.3 V On board 3.3 V supply
GND Ground
IOREF Provides the voltage reference and select appropriate power source
Serial Transmits and receives serial data, Pins: 0(Rx) 1(Tx)
External interrupts Trigger an interrupt on low value, Pins: 2 and 3
PWM Provides 8 bit PWM output, Pins: 3,5,6,9,10,11
SPI Supports SPI communication, Pins: 10 (SS), 11 (MOSI), 12 (MISO), and 13
(SCK)
LED LED driven by Pin 13
TWI Supports TWI communication, Pins: A4 (SDA), A5 (SCL)
AREF Reference voltage for the analog inputs
Reset It is used to reset the onboard microcontroller
CMP 456 Eng. Mohamed Ali Torad 31
Reset
The PIC16F87XA differentiates between various
kinds of Reset:
• Power-on Reset (POR)
• MCLR Reset during normal operation
• MCLR Reset during Sleep
• WDT Reset (during normal operation)
• WDT Wake-up (during Sleep)
• Brown-out Reset (BOR)

CMP 456 Eng. Mohamed Ali Torad 32


Reset(cont.)
• MCLR
R1>=1K ohm
R2=100 ohm
C1= 0.1 µF

• Power-on Reset (POR)


A Power-on Reset pulse is generated n-chip when VDD rise is detected
(in the range of 1.2V-1.7V), The Power-up Timer provides a fixed 72ms
nominal time-out on power-up only from the POR. The Power up timer
operates on an internal RC oscillator. The chip is kept in Reset as long
as the PWRT is active.

CMP 456 Eng. Mohamed Ali Torad 33


Reset(cont.)
• Oscillator Start-up Timer (OST)
The Oscillator Start-up Timer (OST) provides a delay of 1024 oscillator cycles (from
OSC1 input) after the PWRT delay is over (if PWRT is enabled). This helps to ensure
that the crystal oscillator or resonator has started and stabilized.

• Brown-out Reset (BOR)


the Brown-out Reset circuit. If VDD falls below VBOR (about 4V) for longer than TBOR
(about 100 μS), the brown-out situation will reset the device. If VDD falls be

Time-out Sequence
On power-up, the time-out sequence is as follows:
1. The PWRT delay starts (if enabled) when a POR Reset occurs.
2. OST starts counting 1024 oscillator cycles when PWRT ends (LP, XT, HS). When
the OST ends, the device comes out of Reset.
If MCLR is kept low long enough, the time-outs will expire. Bringing MCLR high will
begin execution immediately. This is useful for testing purposes or to synchronize
more than one PIC16F87XA device operating in parallel.

CMP 456 Eng. Mohamed Ali Torad 34


OSCILLATOR TYPES
The PIC16F87XA can be operated in four different oscillator modes. The user can
program two configuration bits (FOSC1 and FOSC0) to select one of these four modes:
• LP Low-Power Crystal
• XT Crystal/Resonator
• HS High-Speed Crystal/Resonator
• RC Resistor/Capacitor
In XT, LP or HS modes, a crystal or ceramic resonator is connected to the OSC1/CLKI
and OSC2/CLKO pins to establish oscillation

CMP 456 Eng. Mohamed Ali Torad 35


OSCILLATOR TYPES(cont.)
• RC OSCILLATOR

Most of the PIC microcontrollers can operate up to 20MHz. One instructions cycle
(machine cycle) consists of four clock cycles.

CMP 456 Eng. Mohamed Ali Torad 36

You might also like