Sie sind auf Seite 1von 57

CHAPTER 1=EMBEDDED SYSTEM DESIGN

1.1 INTRODUCTION Embedded system employs a combination of software & hardware to perform a specific function. It is a part of a larger system which may not be a computer Works in a reactive & time constrained environment. Any electronic system that uses a CPU chip, but that is not a general-purpose workstation, desktop or laptop computer is known as embedded system. Such systems generally use microprocessors; microcontroller or they may use custom-designed chips or both. They are used in automobiles, planes, trains, space vehicles, machine tools, cameras, consumer and office appliances, cell phones, PDAs and other handhelds as well as robots and toys. The uses are endless, and billions of microprocessors are shipped every year for a myriad of applications.

Figure: Embedded System

basic

In embedded systems, the software is permanently set into a read-only memory such as a ROM or flash memory chip, in contrast to a general-purpose computer that loads its programs into RAM each time. Sometimes, single board and rack mounted generalpurpose computers are called "embedded computers" if used to control

We are living in the Embedded World. You are surrounded with many embedded products and your daily life largely depends on the proper functioning of these gadgets. Television, Radio, CD player of your living room, Washing Machine or Microwave Oven in your kitchen, Card readers, Access Controllers, Palm devices of your work space enable you to do many of your tasks very effectively. Apart from all these, many controllers embedded in your car take care of car operations between the bumpers and most of the times you tend to ignore all these controllers. In recent days, you are showered with variety of information about these embedded controllers in many places. All kinds of magazines and journals regularly dish out details about latest technologies, new devices, fast applications which make you believe that your basic survival is controlled by these embedded products. Now you can agree to the fact that these embedded products have successfully invaded into our world. You must be wondering about these embedded controllers or systems. What is this Embedded System? The computer you use to compose your mails, or create a document or analyze the database is known as the standard desktop computer. These desktop computers are manufactured to serve many purposes and applications. You need to install the relevant software to get the required processing facility. So, these desktop computers can do many things. In contrast, embedded controllers carryout a specific work for which they are designed. Most of the time, engineers design these embedded controllers with a specific goal in mind. So these controllers cannot be used in any other place. Theoretically, an embedded controller is a combination of a piece of microprocessor based hardware and the suitable software to undertake a specific task. These days designers have many choices in microprocessors/microcontrollers. Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an experienced designer. Selecting a right microprocessor may turn out as a most difficult first step and it is getting complicated as new devices continue to pop-up very often.

1.2 EMBEDDED APPLICATIONS

AUTOMOBILES: Fuel Injection control (for fuel efficiency), Air bags and

Automatic braking (for safety), and car entertainment systems.

MEDICAL ELECTRONICS: Many sophisticated medical instruments (Body

Scanners, Heart rate monitors, Pacemaker etc) Industrial Control: such as CNC machines are example embedded systems.

BUSINESS

APPLICATIONS:

Vending

machines,

scanners,

printers.

CONSUMER ELECTRONICS: Cameras, Toys, Cellular Phones, Washing

Machines

AVIONICS: Airplanes, Satellite Stations

DEFENSE: RADARs, SONARs (for suvellience ), Guided Missile Systems

1.3 COMPONENTS OF EMBEDDED SYSTEM

HARDWARE

Processor Memory User Interface Displays Input/Output

Other Electrical Components Examples include Power Supply, Data Converters,

Electric Filters Components of Embedded System

SOFTWARE

Control Software :Responsible for managing and synchronizing Computation Extensive Software Device Drivers which control System's Peripheral User Interface for collecting user inputs Operating System (optional) : Operating System is a software which manages the

different resources (CPU, Memory, Peripherals) of a system

CHAPTER 2=SIMULATION

2.1 INTRODUCTION
4

Simulation is the imitation of some real thing, state of affairs, or process. The act of simulating something generally entails representing certain key characteristics or behaviors of a selected physical or abstract system. Simulation is used in many contexts, including the modeling of natural systems or human systems in order to gain insight into their functioning. Other contexts include simulation of technology for performance optimization, safety, engineering, training and education. Simulation can be used to show the eventual real effects of alternative conditions and courses of action A computer simulation (or "sim") is an attempt to model a real-life or hypothetical situation on a computer so that it can be studied to see how the system works. By changing variables, predictions may be made about the behavior of the system. Computer simulation has become a useful part of modeling many natural systems in physics, chemistry, biology and human systems in economics and social science(the computational sociology) as well as in engineering to gain insight into the operation of those systems. For example, simulators have been used to debug a microprogram or sometimes commercial application programs, before the program is downloaded to the target machine. Since the operation of the computer is simulated, all of the information about the computer's operation is directly available to the programmer, and the speed and execution of the simulation can be varied at will.

2.2 CLASSIFICATION OF SIMULATION SYSTEMS


It is useful to classify the system being simulated into two separate categories depending upon the degree of randomness associated with the behavior of the system in its simulated

2.2.1 STOCHASTIC SYSTEM A system, such as this one, that relies heavily upon random behavior is referred to as a stochastic system. The results generated from a stochastic system are typically
5

analyzed statistically in order to make conclusions regarding the behavior of the system.For example, consider a simulated system consisting of a series of bank tellers who must provide transaction services to incoming customers. The length of time required for a teller to process a customer's transaction cannot usually be predetermined before the simulation is started. Consequently such a simulation system must introduce random behavior to simulate the duration of each transaction. During the analysis of a real world banking system it may be discovered that the time required for a transaction occurs over some well known probability distribution. Hence the duration of each transaction may be generated from this distribution. A similar strategy may be adopted for the rate at which customers enter a bank. Through the introduction of this randomness, the results of a simulation may never be the same as a previous simulation. 2.2.2 DETERMINISTIC SYSTEM Conversely, a deterministic simulation system incorporates absolutely no random

behavior whatsoever. As such, the simulation results for a given set of inputs will always be identical. Simulations involving circuit behavior are examples of deterministic systems. Supplying high signals to both inputs of a 2-input NAND gate will always produce a low signal on the gate's output, regardless of where the gate is located in the circuit's design hierarchy or when the inputs are received by the gate. In the context of circuit simulation, deterministic simulation is used to verify that a particular circuit design is behaving as expected when the circuit is supplied with a given set of inputs; the circuit produces the expected outputs at the correct time.

2.3 ABSTRACTION LEVELS FOR CIRCUIT SIMULATION


This section will outline some of the aspects related to the simulation of circuits, including the different levels at which circuit simulators may operate. Circuit simulation provides a means of modeling a circuit's response to a given set of inputs. The simulator may generate numbers representing the voltages present at specific nodes of the circuit at certain times or it may generate waveform diagrams that show the circuit's output over the duration of the simulation. What is actually produced as a result of the simulation is largely dependent upon the abstraction level at which the circuit was described and subsequently simulated. For example, simulating a circuit described in terms of transistors and capacitors will conventionally show how these components
6

interact at the electrical or analog level, whereas simulating a circuit described in terms of gates, flip-flops and registers will demonstrate the digital interaction amongst the components. Circuits may be described and simulated at several levels of abstraction. This section will describe three major abstraction levels, each of which are related to the simulation models described above. These levels are described below in order of increasing abstraction level

2.3.1 CIRCUIT LEVEL SIMULATORS


Circuit-level simulators are used to model the behavior of a circuit at its lowest conceptual level. The circuit is described in terms of transistors, wires, capacitors and resistors and their respective interconnectivity. Circuit-level simulators manipulate extensive detail regarding the interaction of all the components in the circuit and also take into consideration subtleties such as wire resistance and geometric properties of the subcomponents. The end goal circuit level simulation is to produce very detailed analog waveforms which accurately model the behavior of the circuit's devices in the real world.

Consequently, continuous simulation techniques are often used to implement circuit-level simulators. Although this method generates very accurate results, the technique is very computationally intensive, resulting in poor simulation speed. As a result, circuit-level simulation is usually not feasible for large designs and is therefore commonly used to simulate only the most critical sub regions of a given circuit.

2.3.2 LOGIC LEVEL SIMULATORS


Logic-level simulators attempt to remedy the computationally intensive nature of circuitlevel simulators by raising the level of abstraction to the domain of switches and logic components. Instead of manipulating continuous, analog data, logic-level simulators simply process logic values; that is, 0, 1 and X. In addition, logic-level simulators traditionally simplify the simulation process by assuming that the connecting wires have negligible resistance. Logic level simulators can be subdivided into two further categories, switchlevel and gate-level simulators.

2.3.2.1 SWITCH LEVEL SIMULATORS


In switch-level simulators, transistors are promoted to elementary switches and very little attention is given to the intricacies of other transistor attributes. During the simulation itself, equations governing the behaviour of the circuit are greatly approximated, thereby increasing the speed at which the simulator operates. The detail that is inevitably lost as a result of this approach is not usually vital.

2.3.2.2 GATE LEVEL SIMULATORS


Gate-level simulators operate at yet a higher abstraction level. Low level circuit devices such as transistors, capacitors and resistors are replaced with logic gates such as NAND, XOR and flip-flops. Circuits described at this level bear strong resemblance to data flow diagrams in which information is passed amongst interconnected components. Effective use of Gate-level simulators operates at yet a higher abstraction level. Low level logic gates permit relatively high-level designs to be easily described and

subsequently simulated. Because the components are increasingly abstract, more complex systems may be designed and simulated at the gate level rather than at the switch level.

2.3.3FUNCTIONAL- AND BEHAVIOURAL-LEVEL SIMULATORS


Functional- and behavioral-level description languages and simulators represent the highest levels of simulation available to circuit designers. These levels enable designers to model circuits in terms of interacting abstract units that may not even be capable of fabrication. As such, designers are not limited by the restricted behavior of fundamental circuit devices Functional-level simulators are generally closer to the actual hardware representation than behaviour-level simulators. An abstract unit in a functional-level simulation would accept input and produce output just like its corresponding hardware component. However, more flexibility is permitted with respect to how the input is presented to the unit and how it is processed to produce output. For example, an adder at the gate-level may consist of several half-adders which adds to numbers by operating directly on their bits. The equivalent functional-level unit would simply take two integers and add them using arithmetic constructs available in the hardware description language Behavioural-level simulators go one level higher and permit designers to model abstract control processing which may not be realizable in hardware. The purpose of these simulators is to give the designer a general overview of the design and to experiment with high-level alternatives. The usefulness of design tools and simulators that operate at this level has been the subject of debate due to the difficulty in translating such high level designs into compact, high-performance circuits.

2.4 SIMULATION OF SEVEN-SEGMENT DISPLAY

2.5

SIMULATION OF MULTISEGMENT DISPLAY

2.6

SIMULATION OF ANALOG TO DIGITAL CONVERTER

10

2.7 SIMULATION OF LCD

2.8 SIMULATION OF MOTOR

11

2.9 SIMULATION OF 555 TIMER AS SQUARE WAVE GENERATOR

12

13

CHAPTER 3=MICROCONTROLLER 8051


3.1 INTRODUCTION Microcontroller are widely used in Embedded System products. An Embedded product uses the microprocessor(or microcontroller) to do one task & one task only. A printer is an example of Embedded system since the processor inside it perform one task only namely getting the data and printing it. Contrast this with Pentium based PC. A PC can be used for any no. of applications such as word processor, print server, bank teller terminal, video game player, network server or internet terminal. Software for variety of applications can be loaded and run. Of course the reason a PC can perform multiple task is that it has RAM memory and an operating system that loads the application software into RAM & lets the CPU run it. In and Embedded system there is only one application software that is typically burn into ROM. An x86PC Contain or its connected to various Embedded Products such as keyboard, printer, modem, Disc controller, Sound card, CDRom Driver, Mouse & so on. Each one of these peripherals as a microcontroller inside it that performs only one task. Although microcontroller are preferred choice for many Embedded systems, There are times that a microcontroller is inadequate for the task. For this reason in recent years many manufactures of general purpose microprocessors such as INTEL, Motorolla, AMD & Cyrix have targeted their microprocessors for the high end of Embedded market. While INTEL, AMD, Cyrix push their x86 processors for both the embedded and desktop pc market, Motorolla is determined to keep the 68000 families alive by targeting it mainly for high end of embedded system. One of the most critical needs of the embedded system is to decrease power consumptions and space. This can be achieved by integrating more functions into the CPU chips. All the embedded processors based on the x86 and 680x0 have low power consumptions in additions to some forms of I/O, Com port & ROM all on a single chip. In higher performance Embedded system the trend is to integrate more & more function on the CPU chip & let the designer decide which feature he/she wants to use.

3.2 HISTORY
14

Intel Corporation introduced an 8-bit microcontroller called 8051 in 1981 this controller had 128 bytes of RAM, 4k bytes of on chip ROM, two timers, one serial port, and four ports all are on single chip. The 8051 is an 8 bit processor, meaning that the CPU can work on only 8 bit data at a time. Data larger than 8 bits broken into 8 bit pieces to be processed by CPU. It has for I/O 8 bit wide.

15

FEATURES OF THE 8051 FEATURE


ROM RAM Timer I/O pins Serial port Interrupt sources

QUANTITY
4K bytes 128 bytes 2 32 1 6

3.3 DEFINITION OF A MICROCONTROLLER


Microcontroller, as the name suggests, are small controllers. They are like single chip computers that are often embedded into other systems to function as processing/controlling unit. For example, the remote control you are using probably has microcontrollers inside that do decoding and other controlling functions. They are also used in automobiles, washing machines, microwave ovens, toys ... etc, where automation is needed.

THE KEY FEATURES OF MICROCONTROLLERS INCLUDE:


High Integration of Functionality Microcontrollers sometimes are called single-chip computers because they have

on-chip memory and I/O circuitry and other circuitries that enable them to function as small standalone computers without other supporting circuitry.

Field Programmability, Flexibility Microcontrollers often use EEPROM or EPROM as their storage device to allow

field programmability so they are flexible to use. Once the program is tested to be correct then large quantities of microcontrollers can be programmed to be used in embedded systems.

Easy to Use

16

Assembly language is often used in microcontrollers and since they usually follow RISC architecture, the instruction set is small. The development package of microcontrollers often includes an assembler, a simulator, a programmer to "burn" the chip and a demonstration board. Some packages include a high level language compiler such as a C compiler and more sophisticated libraries.

17

MOST MICROCONTROLLERS WILL ALSO COMBINE OTHER DEVICES SUCH AS:

A Timer module to allow the microcontroller to perform tasks for certain time A serial I/O port to allow data to flow between the microcontroller and other An ADC to allow the microcontroller to accept analogue input data for

periods.

devices such as a PC or another microcontroller.

processing.

Figure: Showing a typical microcontroller device and its different subunits The heart of the microcontroller is the CPU core. In the past this has traditionally been based on an 8-bit microprocessor unit.

3.4 MICROCONTROLLERS VERSUS MICROPROCESSORS


Microcontroller differs from a microprocessor in many ways. First and the most important is its functionality. In order for a microprocessor to be used, other components such as memory, or components for receiving and sending data must be added to it. In short that means that microprocessor is the very heart of the computer. On the other hand, microcontroller is designed to be all of that in one. No other external components are needed for its application because all necessary peripherals are already built into it. Thus, we save the time and space needed to construct devices.

18

3.5 TYPES OF MICROCONTROLLER ARCHITECTURE:


There are two types of Microcontroller architecture designed for embedded system development. These are: 1)RISC- Reduced instruction set computer 2)CISC- Complex instruction set computer

19

3.5.1 DIFFERENCE BETWEEN CISC AND RISC


CISC stands for Complex Instruction Set Computer. Most PC's use CPU based on this architecture. For instance Intel and AMD CPU's are based on CISC architectures. Typically CISC chips have a large amount of different and complex instructions. In common CISC chips are relatively slow (compared to RISC chips) per instruction, but use little (less than RISC) instructions. MCS-51 family microcontrollers are based on CISC architecture. RICS stands for Reduced Instruction Set Computer. The philosophy behind it is that almost no one uses complex assembly language instructions as used by CISC, and people mostly use compilers which never use complex instructions. Therefore fewer, simpler and faster instructions would be better, than the large, complex and slower CISC instructions. However, more instructions are needed to accomplish a task. Atmels AVR microcontroller is based on RISC architecture.

3.6 8051 ARCHITECTURE OVERVIEW


The 8051 family is one of the most common microcontroller architectures used worldwide. 8051 based microcontrollers are offered in hundreds of variants from many different silicon manufacturers. The 8051 is based on an 8-bit CISC core with Harvard architecture. It's an 8-bit CPU, optimized for control applications with extensive Boolean processing (single-bit logic capabilities), 64K program and data memory address space and various on-chip peripherals. The 8051 microcontroller family offers developers a wide variety of high-integration and cost-effective solutions for virtually every basic embedded control application. From traffic control equipment to input devices and computer networking products, 8051 u.c deliver high performance together with a choice of configurations and options matched to the special needs of each application. Whether it's low power operation, higher frequency performance, expanded on-chip RAM, or an application-specific requirement, there's a version of the 8051 microcontroller that's right for the job. When it's time to upgrade product features and functionality, the 8051 architecture puts you on the first step of a smooth and costeffective upgrade path - to the enhanced performance of the 151 and 251 microcontrollers.

20

21

BLOCK DIAGRAM OF 8051

Figure: Internal Architecture of 8051 There are four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports upon RESET are configured as output, ready to be used as output ports. To use any of these ports as an input port, it must be programmed.

PORT 0
Port 0 occupies a total of 8 pins (pins 32-39) .It can be used for input or output. To use the pins of port 0 as both input and output ports, each pin must be connected externally to a 10K ohm pull-up resistor. This is due to the fact that P0 is an open drain, unlike P1, P2, and P3.Open drain is a term used for MOS chips in the same way that open collector is used for TTL chips. With external pull-up resistors connected upon reset, port 0 is configured as an output port. For example, the following code will continuously send out to port 0 the alternating values 55H and AAH

22

Figure: Pin Configuration Of 8051

PORT 0 AS INPUT:
With resistors connected to port 0, in order to make it an input, the port must be programmed by writing 1 to all the bits. In the following code, port 0 is configured first as an input port by writing 1's to it, and then data is received from the port and sent to

23

P1.

Dual Role of Port 0 :-Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. When connecting an 8051/31 to an external memory, port 0 provides both address and data. The 8051 multiplexes address and data through port 0 to save pins. ALE indicates if P0 has address or data. When ALE = 0, it provides data D0-D7, but when ALE =1 it has address and data with the help of a 74LS373 latch.

PORT 1
Port 1 occupies a total of 8 pins (pins 1 through 8). It can be used as input or output. In contrast to port 0, this port does not need any pull-up resistors since it already has pullup resistors internally. Upon reset, Port 1 is configured as an output port. For example, the following code will continuously send out to port1 the alternating values 55h & AAh

PORT 1 AS INPUT

24

To make port1 an input port, it must be programmed as such by writing 1 to all its bits. In the following code port1 is configured first as an input port by writing 1s to it, then data is received from the port and saved in R7 ,R6 & R5.

PORT 2
Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input or output. Just like P1, P2 does not need any pull-up resistors since it already has pull-up resistors internally. Upon reset, Port 2 is configured as an output port. For example, the following code will send out continuously to port 2 the alternating values 55h and AAH. That is all the bits of port 2 toggle continuously.

PORT 2 AS INPUT
To make port 2 an input, it must programmed as such by writing 1 to all its bits. In the following code, port 2 is configured first as an input port by writing 1s to it. Then data is received from that port and is sent to P1 continuously.

DUAL ROLE OF PORT 2


In systems based on the 8751, 8951, and DS5000, P2 is used as simple I/O. However, in 8031-based systems, port 2 must be used along with P0 to provide the 16-bit address for the external memory. As shown in pin configuration 8051, port 2 is also designed as A8-A15, indicating the dual function. Since an 8031 is capable of accessing 64K bytes of external memory, it needs a path for the 16 bits of the address. While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the address. In other words, when 8031 is connected to external memory, P2 is used for the upper 8 bits of the 16 bit address, and it cannot be used for I/O.

PORT 3
Port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or output. P3 does not need any pull-up resistors, the same as P1 and P2 did not. Although port 3 is configured as an output port upon reset. Port 3 has the additional function of providing some extremely important signals such as interrupts. This information applies both 8051 and 8031 chips. There functions are as follows:25

P3.0 and P3.1 are used for the RxD and TxD serial communications signals. Bits P3.2 and P3.3 are set aside for external interrupts. Bits P3.4 and P3.5 are used for timers 0 and 1. Finally P3.6 and P3.7 are used to provide the WR and RD signals of external memories connected in 8031 based systems.

ALE/PROG
Address Latch Enable is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/ 6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode.

PSEN
Program Store Enable is the read strobe to external program memory. When the AT89S8252 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory.
26

EA/VPP
EA stands for External Access Enable. EA must be strapped to GND in order to enable the device to fetch code from external program memory locations starting at 0000H up to FFFFH. Note, however, that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12-volt programming enable voltage (VPP) during Flash programming when 12-volt programming is selected.

XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2
Output is from the inverting oscillator amplifier.

Oscillator Characters:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator; either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

27

Figure: 11.0592MHZ Crystal

3.7 MEMORY UNIT


Memory is part of the microcontroller whose function is to store data. The easiest way to explain it is to describe it as one big closet with lots of drawers. If we suppose that we marked the drawers in such a way that they can not be confused, any of their contents will then be easily accessible. It is enough to know the designation of the drawer and so its contents will be known to us for sure.

Figure: Simplified model of a memory

Memory components are exactly like that. For a certain input we get the contents of a certain addressed memory location and that's all. Two new concepts are brought to us:
28

addressing and memory location. Memory consists of all memory locations, and addressing is nothing but selecting one of them. This means that we need to select the desired memory location on one hand, and on the other hand we need to wait for the contents of that location. Besides reading from a memory location, memory must also provide for writing onto it. This is done by supplying an additional line called control line. We will designate this line as R/W (read/write). Control line is used in the following way: if r/w=1, reading is done, and if opposite is true then writing is done on the memory location. Memory is the first element, and we need a few operation of our microcontroller. The amount of memory contained within a microcontroller varies between different microcontrollers. Some may not even have any integrated memory (e.g. Hitachi 6503, now discontinued). However, most modern microcontrollers will have integrated memory. The memory will be divided up into ROM and RAM, with typically more ROM than RAM. Typically, the amount of ROM type memory will vary between around 512 bytes and 4096 bytes, although some 16 bit microcontrollers such as the Hitachi H8/3048 can have as much as 128 Kbytes of ROM type memory. ROM type memory, as has already been mentioned, is used to store the program code. ROM memory can be ROM (as in One Time Programmable memory), EPROM, or EEPROM. The amount of RAM memory is usually somewhat smaller, typically ranging between 25 bytes to 4 Kbytes. RAM is used for data storage and stack management tasks. It is also used for register stacks (as in the microchip PIC range of microcontrollers).

29

Figure: Memory Organization

3.7.1 LOGICAL SEPARATION OF PROGRAM DATA MEMORY


All Atmel Flash microcontrollers have separate address spaces for program and data memory. The logical separation of program and data memory allows the data memory to be accessed by 8-bit addresses, which can be more quickly stored and manipulated by an 8- bit CPU. Nevertheless, 16-bit data memory addresses can also be generated through the DPTR register. Program memory can only be read. There can be up to 64K bytes of directly addressable program memory. The read strobe for external program memory is the Program Store Enable signal (PSEN). Data memory occupies a separate address space from program memory. Up to 64K bytes of external memory can be directly addressed in the external data memory space. The CPU generates read and write signals, RD and WR, during external data memory accesses. External program memory and external data memory can be combined by applying the RD and PSEN
30

signals to the input of an AND gate and using the output of the gate as the read strobe to the external program/data memory.

3.8 PROGRAM MEMORY


After reset, the CPU begins execution from location 0000H. each interrupt is assigned a fixed location in program memory. The interrupt causes the CPU to jump to that location, where it executes the service routine. External Interrupt 0, for example, is assigned to location 0003H. If External Interrupt 0 is used, its service routine must begin at location 0003H. If the interrupt is not used, its service location is available as general purpose program memory. The interrupt service locations are spaced at 8-byte intervals:

0003H for External Interrupt 0, 000BH for Timer 0, 0013H for External Interrupt 1, 001BH for Timer 1, and so on. If an interrupt service routine is short enough (as is often the case in control applications), it can reside entirely within that 8-byte interval. Longer service routines can use a jump instruction to skip over subsequent interrupt locations, if other interrupts are in use. The lowest addresses of program memory can be either in the on-chip Flash or in an external memory. To make this selection, strap the External Access (EA) pin to either VCC or GND. For example, in the AT89C51 with 4K bytes of on-chip Flash, if the EA pin is strapped to VCC, program fetches to addresses 0000H through 0FFFH are directed to the internal Flash. Program fetches to addresses 1000H through FFFFH are directed to external memory. In the AT89C52 (8K bytes Flash), EA = VCC selects addresses 0000H through 1FFFH to be internal and addresses 2000H through FFFFH to
31

be external. If the EA pin is strapped to GND, all program fetches are directed to external memory. The read strobe to external memory, PSEN, is used for all external program fetches. Internal program fetches do not activate PSEN. The hardware configuration is for external program execution. Note that 16 I/O lines (Ports 0 and 2) are dedicated to bus functions during external program memory fetches. Port 0 serves as a multiplexed address/data bus. It emits the low byte of the Program Counter (PCL) as an address and then goes into a float state while waiting for the arrival of the code byte from the program memory. During the time that the low byte of the Program Counter is valid on P0, the signal ALE (Address Latch Enable) clocks this byte into an address latch. Meanwhile, Port 2 emits the high byte of the Program Counter (PCH). Then PSEN strobes the external memory and the microcontroller reads the code byte. Program memory addresses are always 16 bits wide, even though the actual amount of program memory used may be less than 64K bytes. External program execution sacrifices two of the 8-bit ports, P0 and P2, to the function of addressing the program memory.

32

3.9 DATA MEMORY


The right half of the internal and external data memory spaces is available on Atmels Flash Microcontrollers. Hardware configuration is for accessing up to 2K bytes of external RAM. In this case, the CPU executes from internal Flash. Port 0 serves as a multiplexed address/data bus to the RAM, and 3 lines of Port 2 are used to page the RAM. The CPU generates RD and WR signals as needed during external RAM accesses. You can assign up to 64K bytes of external data memory. External data memory addresses can be either 1 or 2 bytes wide. One-byte addresses are often used in conjunction with one or more other I/O lines to page the RAM. Two-byte addresses can also be used, in which case the high address byte is emitted at Port 2.

33

Internal data memory addresses are always 1 byte wide, which implies an address space of only 256 bytes. However, the addressing modes for internal RAM can in fact accommodate 384 bytes. Direct addresses higher than 7FH access one memory space and indirect addresses higher than 7FH access a different memory space. Thus, the Upper 128 and SFR space are occupying the same block of addresses, 80H through FFH, although they are physically separate entities. The lowest 32 bytes are grouped into 4 banks of 8 registers. Program instructions call out these registers as R0 through R7. Two bits in the Program Status Word (PSW) select which register bank is in use. This architecture allows more efficient use of code space, since register instructions are shorter than instructions that use direct addressing.

34

3.10 CENTRAL PROCESSING UNIT


Let add 3 more memory locations to a specific block that will have a built in capability to multiply, divide, subtract, and move its contents from one memory location onto another. The part we just added in is called "central processing unit" (CPU). Its memory locations are called registers.

Figure: Simplified central processing unit with three registers Registers are therefore memory locations whose role is to help with performing various mathematical operations or any other operations with data wherever data can be found. Look at the current situation. We have two independent entities (memory and CPU) which are interconnected, and thus any exchange of data is hindered, as well as its functionality. If, for example, we wish to add the contents of two memory locations and return the result again back to memory, we would need a connection between memory and CPU. Simply stated, we must have some "way" through data goes from one block to another.

3.11 BUS
That "way" is called "bus". Physically, it represents a group of 8, 16, or more wires. There are two types of buses: address and data bus. The first one consists of as many lines as the amount of memory we wish to address and the other one is as wide as data, in our case 8 bits or the connection line. First one serves to transmit address from CPU memory, and the second to connect all blocks inside the microcontroller.

As far as functionality, the situation has improved, but a new problem has also appeared: we have a unit that's capable of working by itself, but which does not have any contact with the outside world, or with us! In order to remove this deficiency, let's add a block which contains several memory locations whose one end is connected to the data bus, and the other has connection with the output lines on the microcontroller which can be seen as pins on the electronic component.

Figure: Showing connection between memory and central unit using buses

3.12 INPUT-OUTPUT UNIT


Those locations we've just added are called "ports". There are several types of ports: input, output or bidirectional ports. When working with ports, first of all it is necessary to choose which port we need to work with, and then to send data to, or take it from the port.

Figure: Simplified input-output unit communicating with external world When working with it the port acts like a memory location. Something is simply being written into or read from it, and it could be noticed on the pins of the microcontroller.

3.13 SERIAL COMMUNICATION


Beside stated above we've added to the already existing unit the possibility of communication with an outside world. However, this way of communicating has its drawbacks. One of the basic drawbacks is the number of lines which need to be used in order to transfer data. What if it is being transferred to a distance of several kilometers? The number of lines times number of kilometers doesn't promise the economy of the project. It leaves us having to reduce the number of lines in such a way that we don't lessen its functionality. Suppose we are working with three lines only, and that one line is used for sending data, other for receiving, and the third one is used as a reference line for both the input and the output side. In order for this to work, we need to set the rules of exchange of data. These rules are called protocol. Protocol is therefore defined in advance so there wouldn't be any misunderstanding between the sides that are communicating with each other. For example, if one man is speaking in French, and the other in English, it is highly unlikely that they will quickly and effectively understand each other. Let's suppose we have the following protocol. The logical unit "1" is set up on the transmitting line until transfer begins. Once the transfer starts, we lower the

transmission line to logical "0" for a period of time (which we will designate as T), so the receiving side will know that it is receiving data, and so it will activate its mechanism for reception. Let's go back now to the transmission side and start putting logic zeros and ones onto the transmitter line in the order from a bit of the lowest value to a bit of the highest value. Let each bit stay on line for a time period which is equal to T, and in the end, or after the 8th bit, let us bring the logical unit "1" back on the line which will mark the end of the transmission of one data. The protocol we've just described is called in professional literature NRZ (Non-Return to Zero).

Figure: Serial unit sending data through three lines only As we have separate lines for receiving and sending, it is possible to receive and send data (info.) at the same time. So called full-duplex mode block which enables this way of communication is called a serial communication block. Unlike the parallel transmission, data moves here bit by bit, or in a series of bits what defines the term serial communication comes from. After the reception of data we need to read it from the receiving location and store it in memory as opposed to sending where the process is reversed. Data goes from memory through the bus to the sending location, and then to the receiving unit according to the protocol.

3.14 TIMER UNIT


Since in the serial communication we can receive, send and process data. However, in order to utilize it in industry we need a few additionally blocks. One of those is the timer

block which is significant to us because it can give us information about time, duration, protocol etc. The basic unit of the timer is a free-run counter which is in fact a register whose numeric value increments by one in even intervals, so that by taking its value during periods T1 and T2 and on the basis of their difference we can determine how much time has elapsed. This is a very important part of the microcontroller whose understanding requires most of our time.

3.15 ANALOG TO DIGITAL CONVERTER


As the peripheral signals usually are substantially different from the ones that microcontroller can understand (zero and one), they have to be converted into a pattern which can be comprehended by a microcontroller. This task is performed by a block for analog to digital conversion or by an ADC. This block is responsible for converting an information about some analog value to a binary number and for follow it through to a CPU block so that CPU block can further process it.

Figure: Block for converting an analog input to digital output Finally, the microcontroller is now completed, and all we need to do now is to assemble it into an electronic component where it will access inner blocks through the outside pins. The picture below shows what a microcontroller looks like inside.

Figure: Physical configuration of the interior of a microcontroller Thin lines which lead from the center towards the sides of the microcontroller represent wires connecting inner blocks with the pins on the housing of the microcontroller so called bonding lines. Chart on the following page represents the center section of a microcontroller.

Figure: Microcontroller outline with basic elements and internal connections

For a real application, a microcontroller alone is not enough. Beside a microcontroller, we need a program that would be executed, and a few more elements which make up interface logic towards the elements of regulation.

CHAPTER 4=HOW TO USE KEILs VISION SOFTWARE


The Keil development tools for the 8051 offer numerous features and advantages that help you quickly and successfully develop embedded applications. They are easy to use and are guaranteed to help you achieve your design goals.

4.1 Vision3 Integrated Development Environment


Vision3 IDE is Windows-based software development platforms that combines a robust editor, project manager, and make facility. Vision2 supports all of the Keil tools for the 8051 including the C compiler, macro assembler, linker/locator, and object-HEX converter. Vision3 helps expedite the development process of your embedded applications by providing the following: _ Full-featured source code editor, _ Device database for configuring the development tool setting, _ Project manager for creating and maintaining your projects, _ Integrated make facility for assembling, compiling, and linking your embedded applications, _ Dialogs for all development tool settings, _ True integrated source-level Debugger with high-speed CPU and peripheral simulator, _ Links to development tools manuals, device datasheets & users guides. 3 The Vision2 screen provides you with a menu bar for command entry, a tool bar where you can rapidly select command buttons, and windows for source files, dialog boxes, and information displays.

4.2STEPS TO ACCESS VISION:


3 1.
2.

Double Click on the icon present on the desktop. The following window will be popped-up

3. click on project and select new project

4. Create a new folder of your project name.

5. Select New from File menu. 6. And save file as file_name.c i.e. save file with .c extension.

7. Select the device and then build the target. We can select the device as atmel or Philips as per the requirement.

8. Configure Device and select clock 11.0592MHZ.

9. Create HEX. File.

10. Type the application code and after compiling, saving the code burn it into controller using Proload.

ACKNOWLADGEMENT
I take this opportunity to express my gratitude to my college Global Research Institute of management & Technology, Nachron (Radaur) for introducing the training in my course. Industrial training is an important aspect in the field of engineering, only after going through this training, I became aware of the practical and factory atmosphere. I am indebted to all the features of industrial electronics research and development department without their interest my training would never be materialized. It is my luck to get chance to join HCL,Hissar, which is the fountain head in the field of electronics and communication, adopting latest technology in electronics. I would like to thank department as a whole and particularly Mr. NARENDER SHARMA (HEAD TRAINING) AND MR. NITIN KUMAR for their genuine help to clear all difficulties during the training. At last I would like to thank the entire staff of DUCAT unit for providing me the necessary resources to enable me to complete my training without any difficulty and making it successful.

PREFACE

Theoretical knowledge is useless without being pragmatic. So, for the purpose training we got chance in DUCAT. For the period of 8 weeks without this training requirement of our B. Tech (E.C.E) would not have been fulfilled. Here, we come to know about the industrial environment. We also need managerial quality, technical, skills and here we were exposed to the electronic instruments which we have never seen before. We were also acquainted to the other departments of the DUCAT classes on different industrial aspects like IPR and certification etc. like providing extra

PROJECT REQUIREMENTS
ICS USED: ATMEL 89S52 (MICROCONTROLLER) ADC 0804 ULN 2003 ACTIVE COMPONENTS: 7805 (5 VOLT REGULATOR) CRYSTAL 11.0592MHZ TEMP. SENSOR LM 35 LED PASSIVE COMPONENTS: RESISTOR PACK DIODE TRANSFORMER 12-0-12 RELAYS 12VOLTS POWER SUPPLY: 5VOLTS 1 1 1 1 1 1 1

1 4 1 4

GLOBAL RESEARCH INSTITUTE OF TECHNOLOGY AND MANAGEMENT


Electronics Department
Training Report Format Order of Contents 1. Title page 2. Training Certificate 3. Acknowledgement 4. Table of contents/Index with page numbers Contents No. ...... 5. List of figures & Tables with page numbers Figure No. page No. .. Table No. No. . .. .. Title page Title .. .. Page

6. Company Profile (Max. 2 pages) 7. Training Contents (should be chapter wise, subheadings should be marked as 1.1, 1.2.under chapter 1 and so on) 8. Any Project covered 9. References Report should be on A4 size paper. There should be no page number on Title page. Page numbering should be in roman( I,ii,iii.) and at center bottom on above mentioned (2),(3),(4) & (5) and in numerics(1,2,3.) and at center bottom on above mentioned (6) onwards. Margins:

Top 1.0, Bottom 1.0, Left 1.5 and Right 1.0. Line spacing: 1.5 lines.

Caption for table: - above the table and should be marked as Table

1.1, Table 1.2 (under chapter 1) and so on. Caption for figures: - below the figure and should be marked as Figure 2.1, Figure 2.2 (under chapter 2) and so on. Font: - Times New Roman (NO italics).

Size: - 12 for text, 14 for headings (Chapter names Bold) and 12 for Sub headings.

Training Report
On EMBEDDED SYSTEM DESIGN
At

HCL,Hissar
Submitted in Partial fulfillment of requirement for the award of the degree of

B.tech in ECE
Submitted By: Name Rohit Kumar Roll No.- 4608126

Session ( 2008-2012) for 4th year Electronics & Communication Engineering Department GLOBAL RESEARCH INSTITUTE OF MANAGEMENT &TECHNOLOGY

Village NACHRON, RADAUR. Distt. YAMUNA NAGAR (Affiliated to Kurushetra University, Kurushetra)

Das könnte Ihnen auch gefallen