BY Ajay Kumar & Putr
BY Ajay Kumar & Putr
INTRODUCTION:
An Embedded System is a microprocessor based system that is embedded as a subsystem, in a larger system (which may or may not be a computer system).
Tightly-constrained
-- Low cost, low power, small, fast, etc.
CHARACTERISTCS:
rather than be a general-purpose computer for multiple tasks. Some also have real-time performance constraints that must be met, for reasons such as safety and usability; others may have low or no performance requirements, allowing the system hardware to be simplified to reduce costs. 2. Embedded systems are not always standalone devices. Many embedded systems consist of small, computerized parts within a larger device that serves a more general purpose. For example, the Gibson Robot Guitar features an embedded system for tuning the strings, but the overall purpose of the Robot Guitar is, of course, to play music. 3. The program instructions written for embedded systems are referred to as firmware, and are stored in read-only memory or Flash memory chips. They run with limited computer hardware resources: little memory, small or non-existent keyboard or screen.
FEATURES:
Small size & less weight. More efficency . Embedded systems are programmed to perform specific task only. Embedded systems are playing important roles in our lives every day.
ADVANTAGES: High reliable. Can be interface as user convenient. Embedded systems are constrained for power
Application areas
Automotive electronics Aircraft electronics Trains
Telecommunication
Application areas
Medical systems
Military applications
Application areas
Consumer electronics
Fabrication equipment
Smart buildings
A Closer Look
Essential Components
Microprocessor / DSP Sensors Converters (A-D and D-A) Actuators Memory (On-chip and Off chip) Communication path with the interacting
environment
Memory
Essential Considerations
Response Time -- Real Time Area Cost Portability Low Power (Battery Life)
Fault Tolerance
Systems
USER INTERFACE:
Microcontrollers
8051 Microcontroller
Objectives
Understand the 8051 Architecture Use SFR in C Use I/O ports in C
Vcc P0.0(AD0) P0.1(AD1) P0.2(AD2) P0.3(AD3) P0.4(AD4) P0.5(AD5) P0.6(AD6) P0.7(AD7) EA/VPP ALE/PROG PSEN P2.7(A15) P2.6(A14) P2.5(A13) P2.4(A12) P2.3(A11) P2.2(A10) P2.1(A9) P2.0(A8)
Ext Memory Address Ext Memory Access Control Ext Memory Address
39
38
37
36
8051
35
34
33
32
10
31
11
30
12
29
13
28
14
27
15
26
16
25
17
24
18
23
XTAL 1 GND
19
22
20
21
Port 0
D0 D7
EA
(enable Ex. Memory)
8051
ALE
Address Latch Enable
A0 A7
Port 2
A8 - A15
PSEN RD
Ex. Data RAM Reade
OE
WR
Contd.
The first 6 crystal pulses (clock cycle) is used to fetch the opcode and the second 6 pulses are used to perform the operation on the operands in the ALU. This gives an effective machine cycle rate at 1MIPS (Million Instructions Per Second).
XTAL2
Crystal
XTAL!
GND
Contd.
The B register is a register just for multiplication and division operation which requires more register spaces for the product of multiplication and the quotient and the remainder for the division. The immediate result is stored in the accumulator register (Acc) for next operation and the Program Status Word (PSW) is updated depending on the status of the operation result
timer interrupt
serial
(40)Vcc (20) Vg
Port 1
Port 3
RAM
EPROM
code
+1
(18 19)
10k
Read latch
Read pin
Q
Port pin FET
Latch CL Q
PORT P2 (pins 21 to 28): Similar to P0, the port P2 can also play a
role (A8-A15) in the address bus in conjunction with PORT P0 to access external memory.
Contd.
In addition to acting as a normal I/O port, P3.0 can be used for serial receive input pin(RXD) P3.1 can be used for serial transmit output pin(TXD) in a serial port, P3.2 and P3.3 can be used as external interrupt pins(INT0 and INT1), P3.4 and P3.5 are used for external counter input pins(T0 and T1), P3.6 and P3.7 can be used as external data memory write and read control signal pins(WR and RD)read and write pins for memory access.
128 bytes
0x80 0x7F General purpose RAM (variable data) 0x30 0x2F Bit addressible RAM 16x8 bits 0x20 0x1F Register bank 0(R0-R7) Register bank 1(R0-R7) Register bank 2(R0-R7) 0x00 Register bank 3(R0-R7) Internal data memory RAM 4x8= 32 bytes 16 bytes 80 bytes
Contd.
Contd.
The 8051 has 256 bytes of internal addressable RAM,
although only first 128 bytes are available for general use by the programmer. The first 128 bytes of RAM (from 0x00 to 0x7F) are called the direct memory, and can be used to store data. The lowest 32 bytes of RAM are reserved for 4 general register banks. The 8051 has 4 selectable banks of 8 addressable 8-bit registers, R0 to R7.
Contd.
This means that there are essentially 32 available general purpose registers, although only 8 (one bank) can be directly accessed at a time. The advantage of using these register banks is time saving on the context switch for interrupted program to store and recover the status. Otherwise the push and pop stack operations are needed to save the current state and to recover it after the interrupt is over. The default bank is bank 0. The second 128 bytes are used to store Special Function Registers (SFR) that C51 program can configure and control the ports, timer, interrupts, serial communication, and other tasks.
Contd.
There are 21 SFRs. In addition to I/O ports, the most frequently used SFRs to
control and configure 8051 operations are:
TCON (Timer CONTROL) TMOD (Timer MODE) TH0/TH1 and TL0/TL1 (Timers high and low bytes) SCON (Serial port CONTROL) IP (Interrupt Priority) IE ( Interrupt Enable)
2. Interrupt Flags
The interrupt flags are set to 1 when the interrupts occur. IE0/IE1 in TCON - For External Interrupts TF0/TF1 in TCON - For Timer Interrupts TI/RI in SCON - For Serial Interrupts The flag 1 indicates the interrupt occurrence and the flag 0 indicates no interrupt.
3. Interrupt Priority
There are two types of interrupt priority: User Defined Priority and Automatic Priority User Defined Priority The IP register is used to define priority levels by users. The high priority interrupt can preempt the low priority interrupt. There are only two levels of interrupt priority.
EX0 = 1;
//the external interrupt INT1 at port P3.3 is assigned a low priority.
EX1 = 0; Automatic Priority In each priority level, a priority is given in order of:
External Interrupts
An external interrupt is triggered by a low level or negative
edge on INT0 and INT1 which depends on the external interrupt type setting. Set up an external interrupt type by IT0 and IT1 of TCON SFR. E.g., IT0 = 1; //set INT0 as Negative edge triggered IT1 = 0; // set INT1 as Level Triggered The external interrupt source may be a sensor, ADC, or a switch connected to port P3.2(INT0) or P3.3(INT1). You use IE0/IE1 to test the external interrupt events: Ex. If IE0 = 1 then the INT0 interrupt takes place. Note that if an external interrupt is set to low level trigger, the interrupt will reoccur as long as P3.2 or P3.3 is low that makes the code difficult to manage.
IE SFR.
EA = 1; EX0 = 1;
Serial Interrupts
Receive Transmit (UART) protocol transmits or receives the bits of a byte one after the other in a timed sequence on a single wire. It is used to communicate any serial port of devices and computers. The serial interrupt is caused by completion of a serial byte transmitting or receiving. The transmit data pin (TxD) is at P3.1 and the receive data pin (RxD) is at P3.0. All communication modes are controlled through SCON, a non bit addressable SFR. The SCON bits are defined as SM0, SM1, SM2, REN, TB8, RB8, TI, RI.
written five times as much as 'regular' software The vast majority of CPU-chips produced world-wide today are used in the embedded market ... ; only a small portion of CPU's is applied in PC's ... the number of software-constructors of Embedded Systems will rise from 2 million in 1994 to 10 million in 2010; ... the number of constructors employed by softwareproducers 'merely' rises from 0.6 million to 1.1 million.