Você está na página 1de 74

Bank Token Issue System

A Mini Project Report On BANK TOKEN ISSUE SYSTEM


Submitted in partial fulfillment of the requirement for the award of degree

Bachelor of Engineering in
ELECTRONICS AND COMMUNICATION ENGINEERING

by
R.ABILASH T.TS NAGA LAXMI T.JAHNAVI (08UT1A0447) (08UT1A0453) (08UT1A0456)

Under The Guidance Of Ms.SRI LAKSHMI (M-Tech) Assistant Professor Submitted To

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

VISHNU SREE INSTITTUTE OF ENGINNERING


JALALPUR, BOMMALARAMARAM, NALGONDA.

Electronics and Communication Engineering

Bank Token Issue System

CERTIFICATE

Electronics and Communication Engineering

Bank Token Issue System

ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany the successful completion of any task would be incomplete without the mentioning of the people whose constant guidance and encouragement made it possible. We take pleasure in presenting before you, our project, which is result of studied blend of both research and knowledge. We express our thanks to Dr. V.MURALI KRISHNA,M.Tech,Ph.D principal of Vishnu Sree Institute of Technology for giving his consent to take up this dissertation. Our special thanks to Mr.D.Ramanna,M.Tech,(Ph.D.) Head of the Department of ELECTRONICS AND COMMUNICATION, Vishnu Sree Institute of Technology, who has given us an immense support throughout the course of the project. We express our earnest gratitude to our internal guide, Assistant Professor Ms.SRI LAKSHMI Department of ECE, our project guide, for her constant support, encouragement and guidance. We are grateful for her co-operation and her valuable suggestions. Finally, we express our gratitude to all other members who are involved either directly or indirectly for the completion of this project.

R.ABILASH T.TS NAGA LAXMI T.JAHNAVI

08UT1A0447 08UT1A0453 08UT1A0456

Electronics and Communication Engineering

Bank Token Issue System

DECLARATION
We, the undersigned, here by declare that the mini project entitled BANK TOKEN ISSUE SYSTEM, being submitted in partial fulfillment for the award of Bachelor of Engineering Degree in Electronics and Communication Engineering, affiliated to Jawaharlal Nehru Technological University, is the work carried out by us.

R.ABILASH T.TS NAGA LAXMI T.JAHNAVI

Electronics and Communication Engineering

Bank Token Issue System

ABSTRACT
An embedded system is a combination of computer circuitry and software that is built into a product for purposes such as control, monitoring and communication without human intervention. Embedded systems are at the core of every modern electronic product, ranging from toys to medical equipment to aircraft control systems.The introduction of high-end technologies, digital signal processing and VLSI has changed the face of the world.. This project is mainly designed for the purpose of management of data through the interfaces between various different units of companies in case of large plant consisting of more than one unit. In embedded technology, the embedded Programming is burnt into the AT89S52 micro controller. The project includes 7 SEGMENT LED DISPLAY, which will display the corresponding number given as an input from keypad and software code, which is burned into ROM of 8051 micro controller consists of various subroutines for keypad interface, 7 segment led interface. SOFTWARE MODULES: Keil Software Embedded C HARDWARE REQUIRED: 1. Micro controller 2. Seven segment Unit 3. Power Supply

Electronics and Communication Engineering

Bank Token Issue System

INDEX
LIST OF FIGURES

FIGURE NAME
Figure. 1.1 Figure. 1.2 Figure. 1.3 Figure. 1.4 Figure. 1.5 Figure. 1.7 Figure. 1.8(a) Figure. 1.8(b) Figure. 1.9 Figure.1.10 Figure.1.11 Figure.1.12 Bank Token Display Block diagram Power Supply Voltage regulator Microcontroller 89S52 EEPROM Resistor Capacitor 4x3 Keypad MAX232 Circuit Diagram Flowchart 3 4 5 6 7 10 11 12 13 14 15 43

PAGE NO.

Electronics and Communication Engineering

Bank Token Issue System

CHAPTERS

Chapter one: Overview of the project 1.1 Block Diagram


1.2 Analysis and design of hardware 1.3 Circuit diagram

Chapter two: ....


Chapter three: Chapter four: Chapter six: Advantages and Disadvantages of project. () Bibliography .. () Appendix .. ()

Electronics and Communication Engineering

Bank Token Issue System

CHAPTER:1 OVERVIEW OF PROJECT


1.1 1.2

1.3

Basic Block diagram description Analysis and design of hardware Circuit diagram

Electronics and Communication Engineering

Bank Token Issue System

BLOCK DIAGRAM

Figure:1.1

Electronics and Communication Engineering

Bank Token Issue System

Block Diagram Description


This Project mainly consists of Power Supply section, Microcontroller section, Max 232 serial driver section, Seven segment Display .

Power Supply Section: This section is meant for supplying Power to all the sections
mentioned above. It basically consists of a Transformer to step down the 230V ac to 5V ac followed by diodes. Here diodes are used to rectify the ac to dc. After rectification the obtained rippled dc is filtered using a capacitor Filter. A positive voltage regulator is used to regulate the obtained dc voltage.

Microcontroller Section: This section forms the control unit of the whole project.
This section basically consists of a Microcontroller with its associated circuitry like Crystal with capacitors, Reset circuitry, Pull up resistors (if needed) and so on. The Microcontroller forms the heart of the project because it controls the devices being interfaced and communicates with the devices according to the program being written.

Pumping Section: This pumping section consists of an immerse-able motor to pump


the required no. of liters of petrol. This pumping section is interfaced to microcontroller through the respective driving circuitry.

MAX 232 Sections: It consists of max232 which perform the conversion of the
voltage level compatible to computer and controller. It provides proper communication between the controller and computer.

EEPROM:
It is one type of read only memory and it will provide the space to store the token no. It also contains the information of the token issued and why they are issued

Electronics and Communication Engineering

Bank Token Issue System

1.2 ANALYSIS AND DESIGN OF HARDWARE

MICROCONTROLLER:

Figure:1.2

Electronics and Communication Engineering

Bank Token Issue System

SERIALCOMMUNICATION:

Figure:1.3

POWERSUPPLY:

Figure:1.4

Electronics and Communication Engineering

Bank Token Issue System

SEVENSEGMNETDISPLAY:

Figure:1.5

Schematic Description:
Firstly, the required operating voltage for Microcontroller 89S52 is 5V. Hence the 5V D.C. power supply is needed by the same. This regulated 5V is generated by first stepping down the 230V to 9V by the step down transformer. The step downed a.c. voltage is being rectified by the Bridge Rectifier. The diodes used are 1N4007. The rectified a.c voltage is now filtered using a C filter. Now the rectified, filtered D.C. voltage is fed to the Voltage Regulator. This voltage regulator allows us to have a Regulated Voltage which is +5V.The rectified; filtered and regulated voltage is again filtered for ripples using an electrolytic capacitor 100F. Now the output from this section is fed to 40th pin of 89S51 microcontroller to supply operating voltage. Electronics and Communication Engineering

Bank Token Issue System The microcontroller 89S52 with Pull up resistors at Port0 and crystal oscillator of 11.0592 MHz crystal in conjunction with couple of capacitors of is placed at 18th & 19th pins of 89S52 to make it work (execute) properly. The Token issue system o/p & i/p pins i.e. RX and TX are connected to MAX 232 serial drivers 14th and 13th pins and its output to Microcontroller from 11th & 12th of MAX to TX and RX pins of Microcontroller.

HARDWARE Components:
The Hardware components used in this project are Regulated Power Supply Microcontroller LED MAX 232 Seven Segment Display

REGULATED POWER SUPPLY:


The power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronics circuits and other devices. A RPS (Regulated Power Supply) is the Power Supply with Rectification, Filtering and Regulation being done on the AC mains to get a Regulated power supply for Microcontroller and for the other devices being interfaced to it. A power supply can by broken down into a series of blocks, each of which performs a particular function. A d.c power supply which maintains the output voltage constant irrespective of a.c mains fluctuations or load variations is known as Regulated D.C Power Supply

Electronics and Communication Engineering

Bank Token Issue System

For example a 5V regulated power supply system as shown below: Figure

Figure:1.6 Transformer:
A transformer is an electrical device which is used to convert electrical power from one Electrical circuit to another without change in frequency. Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-up transformers increase in output voltage, step-down transformers decrease in output voltage. Most power supplies use a step-down transformer to reduce Electronics and Communication Engineering

Bank Token Issue System the dangerously high mains voltage to a safer low voltage.The input coil is called the primary and the output coil is called the secondary.There is no electrical connection between the two coils; instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core..Transformers waste very little power so the power out is equal to the power in. Note that as voltage is stepped down current is stepped up.The ratio of the number of turns on each coil, called the turns ratio, it determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage.

An Electrical Transformer

Figure:1.7

Turns ratio = Vp/ VS = Np/NS Power Out= Power In VS X IS=VP X IP Vp = primary (input) voltage Np = number of turns on primary coil Ip = primary (input) current

Electronics and Communication Engineering

Bank Token Issue System

RECTIFIER:
A circuit which is used to convert a.c to dc is known as RECTIFIER. The process of conversion a.c to d.c is called rectification.

TYPES OF RECTIFIERS:
Half wave Rectifier Full wave rectifier 1. Centre tap full wave rectifier. 2. Bridge type full bridge rectifier.

Full-wave Rectifier:
From the above comparison we came to know that full wave bridge rectifier as more advantages than the other two rectifiers. So, in our project we are using full wave bridge rectifier circuit.

Bridge Rectifier:
A bridge rectifier makes use of four diodes in a bridge arrangement as shown in fig (a) to achieve full-wave rectification. This is a widely used configuration, both with individual diodes wired as shown and with single component bridges where the diode bridge is wired internally.

Electronics and Communication Engineering

Bank Token Issue System

Fig (A)

Figure:1.8 Operation:
During positive half cycle of secondary, the diodes D2 and D3 are in forward biased while D1 and D4 are in reverse biased as shown in the fig(b). The current flow direction is shown in the fig (b) with dotted arrows.

Fig (B)

Figure:1.9
During negative half cycle of secondary voltage, the diodes D1 and D4 are in forward biased while D2 and D3 are in reverse biased as shown in the fig(c). The current flow direction is shown in the fig (c) with dotted arrows.

Electronics and Communication Engineering

Bank Token Issue System

Fig(C) Figure:2.0

Filter:
A Filter is a device which removes the a.c component of rectifier output but allows the d.c component to reach the load

Capacitor Filter:
We have seen that the ripple content in the rectified output of half wave rectifier is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples is not acceptable for most of the applications. Ripples can be removed by one of the following methods of filtering. (a) A capacitor, in parallel to the load, provides an easier by pass for the ripples voltage though it due to low impedance. At ripple frequency and leave the D.C. to appear at the load. (b) An inductor, in series with the load, prevents the passage of the ripple current (due to high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c) (c) Various combinations of capacitor and inductor, such as L-section filter section

filter, multiple section filter etc. which make use of both the properties mentioned in (a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and another with full wave rectifier. Electronics and Communication Engineering

Bank Token Issue System

Filtering is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value). To calculate the value of capacitor(C), C = *3*f*r*Rl Where, f = supply frequency, r = ripple factor, Rl = load resistance Note: In our circuit we are using 1000F hence large value of capacitor is placed to reduce ripples and to improve the DC component.

Regulator:
Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output voltages. The maximum current they can pass also rates them. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current ('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulators ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the output pin.

Electronics and Communication Engineering

Bank Token Issue System

Fig 2.1 A Three Terminal Voltage Regulator

CHAPTER:2

Electronics and Communication Engineering

Bank Token Issue System

MICRO CONTROLLER 89S52

MICRO CONTROLLER 89S52


Introduction:
A Micro controller consists of a powerful CPU tightly coupled with memory, various I/O interfaces such as serial port, parallel port timer or counter, interrupt controller, data acquisition interfaces-Analog to Digital converter, Digital to Analog converter, integrated on to a single silicon chip. If a system is developed with a microprocessor, the designer has to go for external memory such as RAM, ROM, EPROM and peripherals. But controller is provided all these facilities on a single chip. Development of a Micro controller reduces PCB size and cost of design.

Electronics and Communication Engineering

Bank Token Issue System One of the major differences between a Microprocessor and a Micro controller is that a controller often deals with bits not bytes as in the real world application. Intel has introduced a family of Micro controllers called the MCS-51.

Figure:2.2 The Major Features:


Compatible with MCS-51 Products 8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Programmable Serial Channel Low-power Idle and Power-down Modes

Why AT 89S52
The system requirements and control specifications clearly rule out the use of 16, 32 or 64 bit micro controllers or microprocessors. Systems using these may be earlier to Electronics and Communication Engineering

Bank Token Issue System implement due to large number of internal features. They are also faster and more reliable but, 8-bit micro controller satisfactorily serves the above application. Using an inexpensive 8-bit Microcontroller will doom the 32-bit product failure in any competitive market place. Coming to the question of why to use AT89S52 of all the 8-bit microcontroller available in the market the main answer would be because it has 4 Kb on chip flash memory which is just sufficient for our application. The on-chip Flash ROM allows the program memory to be reprogrammed in system or by conventional non-volatile memory Programmer. Moreover ATMEL is the leader in flash technology in todays market place and hence using AT 89C51 is the optimal solution.

AT89s52 MICROCONTROLLER ARCHITECTURE


The 89C51 architecture consists of these specific features: Eight bit CPU with registers A (the accumulator) and B Sixteen-bit program counter (PC) and data pointer (DPTR) Eight- bit stack pointer (PSW) Eight-bit stack pointer (Sp) Internal ROM or EPROM (8751) of 0(8031) to 4K (89C51) Internal RAM of 128 bytes: 1. Four register banks, each containing eight registers 2. Sixteen bytes, which maybe addressed at the bit level 3. Eighty bytes of general- purpose data memory Thirty two input/output pins arranged as four 8-bit ports:p0-p3 Two 16-bit timer/counters: T0 and T1 Full duplex serial data receiver/transmitter: SBUF Control registers: TCON, TMOD, SCON, PCON, IP, and IE Two external and three internal interrupts sources. Oscillator and clock circuits.

Electronics and Communication Engineering

Bank Token Issue System

Figure:2.3

Functional block diagram of micro controller

General Description:
The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes of Flash programmable and erasable read only memory (PEROM). The device is manufactured using Atmels high-density nonvolatile memory technology and is Compatible with the industry-standard 80C51 and 80C52 instruction set and pinout.The on-chip Flash allows the program memory to be reprogrammed insystem or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcomputer which provides a highly-flexible and cost-effective solution to many embedded control applications.

Electronics and Communication Engineering

Bank Token Issue System

Microcontroller Unit:
This digital data of ADC is transmitting to microcontroller unit through ADC data lines. In our project the 8 data lines of ADC are connected to Port 0 of microcontroller. Port 0 is an 8-bit bi-directional I/O port. Four switches are connected to first four pins of the microcontrollers Port 1.The main functions of the switches are to store the data. If Switch 1 is pressed then the temperature will display on computer monitor using serial communication and temperature will store in separate file with corresponding data and time. For serial communication we are using port 3.0 and port 3.1 pins. Port 3.0 i.e. serial input port (RXD) is connected to 12th pin of MAX232 (R1out) and port 3.1 i.e. serial out port (TXD) is connected to 11th pin of MAX232 (T1in).

Pin Description of ATMEL 89S52 Microcontroller:

Electronics and Communication Engineering

Bank Token Issue System

Figure:2.4 Pin Description:


VCC: Supply voltage. GND: Ground.

Port 0:
Port 0 is an 8-bit open drain bi-directional I/O port. As an output port each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs. Port 0 may also be configured to be the multiplexed low order address/data bus during accesses to external program and data memory. In this mode P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming, and outputs the code bytes during program verification. External pull-ups are required during

Electronics and Communication Engineering

Bank Token Issue System program verification.Below table indicates pin connections of port 0 in our data logger circuit. Port Pin P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 Pin Description AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7 Connected to 17th data pin of ADC (LSB). 14th data pin of ADC. 15th data pin of ADC. 8th data pin of ADC. 18th data pin of ADC. 19th data pin of ADC. 20th data pin of ADC. 21st data pin of ADC (MSB).

Figure:2.5 Port 1:
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 1 also receives the low-order address bytes during Flash programming and verification. Port Pin P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 Connected to Switch 1. Switch 2. Switch 3. Switch 4. No Connection. No Connection. No Connection. No Connection.

Figure:2.6 Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port Pin Pin Description Connected to

Electronics and Communication Engineering

Bank Token Issue System P2.0 P2.1 P2.2 P2.3 P2.4 P2.5 P2.6 P2.7 A8 A9 A10 A11 A12 A13 A14 A15 SOC-6th pin of ADC. EOC-7th pin of ADC. OE-9th pin of ADC. ALE-22nd pin of ADC. No Connection. No Connection. No Connection. No Connection.

Figure:2.7 Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source Current (IIL) because of the pull-ups.Below table indicates pin connections of port 3 in our data logger circuit. Port Pin P3.0 P3.1 P3.2 P3.3 P3.4 P3.5 P3.6 P3.7 Pin Description RXD (serial input port) TXD (serial output port) INT0 (external interrupt 0) INT1 (external interrupt 1) T0 (Timer 0 external input) T1 (Timer 1 external input) WR (External data memory write strobe) RD (external data memory read strobe) Connected to 12 pin of MAX232 (R1out). 11th pin of MAX232 (T1in).. No Connection No Connection No Connection No Connection No Connection
th

No Connection

Figure:2.8 RST:
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device

ALE/PROG:

Electronics and Communication Engineering

Bank Token Issue System Address Latch Enable 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/6the 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 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 AT89C51 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.

EA/VPP:
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, for parts that require 12-volt VPP.

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

XTAL2:
It is the Output from the inverting oscillator amplifier.

Interfacing the Switches with 89c52 Microcontroller

Electronics and Communication Engineering

Bank Token Issue System Four switches are connected to first four pins of the microcontrollers Port 1.The main functions of the switches are to store the data when we pressed. If we press the Switch 1, the microcontroller will transmit the particular temperature through serial communication unit and that particular temperature will display on computer monitor with date and time. And also, the temperature will store in a separate file with corresponding time and date. The stored data may use for us in future. Similarly Switch 2, 3, 4 are used for us to store the temperature. The switch diagram which we used in our project is shown below.

Switch

Figure:2.9

Interfacing Switches with 89c52 Microcontroller is shown below

Electronics and Communication Engineering

Bank Token Issue System

Figure:3.0 The 89S52 oscillator and clock:


The heart of the 89C51 circuitry that generates the clock pulses by which all the internal all internal operations are synchronized. Pins XTAL1 And XTAL2 is provided for connecting a resonant network to form an oscillator. Typically a quartz crystal and capacitors are employed. The crystal frequency is the basic internal clock frequency of the microcontroller. The manufacturers make 89C51 designs that run at specific minimum and maximum frequencies typically 1 to 16 MHz. XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be configured for use as an on-chip oscillator, as shown in Figs 6.2.3. 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 as shown in Figure 6.2.4.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 flipflop, but minimum and maximum voltage high and low time specifications must be observed.

Electronics and Communication Engineering

Bank Token Issue System

Fig 3.1: - Oscillator and timing circuit

Fig 3.2 Oscillator Connections

Fig 3.3 External Clock Drive Configuration

REGISTERS:

Electronics and Communication Engineering

Bank Token Issue System

In the CPU, registers are used to store information temporarily. That information could be a byte of data to be processed, or an address pointing to the data to be fetched. The vast majority of 8051 registers are 8bit registers. In the 8051 there is only one data type: 8bits. The 8bits of a register are shown in the diagram from the MSB (most significant bit) D7 to the LSB (least significant bit) D0. With an 8-bit data type, any data larger than 8bits must be broken into 8-bit chunks before it is processed. Since there are a large number of registers in the 8051, we will concentrate on some of the widely used general-purpose registers and cover special registers in future chapters. D7 D6 D5 D4 D3 D2 D1 D0 The most widely used registers of the 8051 are A (accumulator), B, R0, R1, R2, R3, R4, R5, R6, R7, DPTR (data pointer), and PC (program counter). All of the above registers are 8-bits, except DPTR and the program counter. The accumulator, register A, is used for all arithmetic and logic instructions.

SFRs (Special Function Registers):


Among the registers R0-R7 is part of the 128 bytes of RAM memory. What about registers A, B, PSW, and DPTR? Do they also have addresses? The answer is yes. In the 8051, registers A, B, PSW and DPTR are part of the group of registers commonly referred to as SFR (special function registers). There are many special function registers and they are widely used. The SFR can be accessed by the names (which is much easier) or by their addresses. For example, register A has address E0h, and register B has been ignited the address F0H, as shown in table.

The following two points should noted about the SFR addresses.

Electronics and Communication Engineering

Bank Token Issue System 1. The Special function registers have addresses between 80H and FFH. These addresses are above 80H, since the addresses 00 to 7FH are addresses of RAM memory inside the 8051. 2. Not all the address space of 80H to FFH is used by the SFR. The unused locations 80H to FFH are reserved and must not be used by the 8051 programmer. Regarding direct addressing mode, consider the following two points: (a) the address value is limited to one byte, 00-FFH, which means this addressing mode is limited to accessing RAM locations and registers located inside the 8051. (b) If we examine the l st file for an assembly language program, we will see that the SFR registers names are replaced with their addresses as listed in table. Symbol Name Address ACC Accumulator 0E0H B B register 0F0H PSW Program status word 0D0H SP Stack pointer 81H DPTR Data pointer 2 bytes DPL Low byte 82H DPH High byte 83H P0 Port0 80H P1 Port1 90H P2 Port2 0A0H P3 Port3 0B0H IP Interrupt priority control 0B8H IE Interrupt enable control 0A8H TMOD Timer/counter mode control 89H TCON Timer/counter control 88H T2CON Timer/counter 2 control 0C8H T2MOD Timer/counter mode2 control 0C9H TH0 Timer/counter 0high byte 8CH TL0 Timer/counter 0 low byte 8AH TH1 Timer/counter 1 high byte 8DH TL1 Timer/counter 1 low byte 8BH TH2 Timer/counter 2 high byte 0CDH TL2 Timer/counter 2 low byte 0CCH RCAP2H T/C 2 capture register high byte 0CBH RCAP2L T/C 2 capture register low byte 0CAH SCON Serial control 98H Electronics and Communication Engineering

Bank Token Issue System SBUF PCON Serial data buffer Power control 99H 87H

Figure:3.4 8051 Special function register Address

A REGISTER (ACCUMULATOR):

This is a general-purpose register which serves for storing intermediate results during operating. A number (an operand) should be added to the accumulator prior to execute an instruction upon it. Once an arithmetical operation is preformed by the ALU, the result is placed into the accumulator. If a data should be transferred from one register to another, it must go through accumulator. For such universal purpose, this is the most commonly used register that none microcontroller can be imagined without (more than a half 8051 microcontroller's instructions used use the accumulator in some way).

B Register:
B register is used during multiply and divide operations which can be performed only upon numbers stored in the A and B registers. All other instructions in the program can use this register as a spare accumulator (A).

NOTE: During programming, each of registers is called by name so that their exact address is not so important for the user. During compiling into machine code (series of Electronics and Communication Engineering

Bank Token Issue System hexadecimal numbers recognized as instructions by the microcontroller), PC will automatically, instead of registers name, write necessary addresses into the microcontroller.

PSW Register (Program Status Word) :

This is one of the most important SFRs. The Program Status Word (PSW) contains several status bits that reflect the current state of the CPU. This register contains: Carry bit, Auxiliary Carry, two register bank select bits, Overflow flag, parity bit, and userdefinable status flag. The ALU automatically changes some of registers bits, which is usually used in regulation of the program performing.

P - Parity bit. If a number in accumulator is even then this bit will be automatically set
(1), otherwise it will be cleared (0). It is mainly used during data transmission and receiving via serial communication.

Bit 1. This bit is intended for the future versions of the microcontrollers, so it is not
supposed to be here.

OV Overflow occurs when the result of arithmetical operation is greater than 255
(decimal), so that it can not be stored in one register. In that case, this bit will be set (1). If there is no overflow, this bit will be cleared (0).

RS0, RS1 - Register bank selects bits. These two bits are used to select one of the
four register banks in RAM. By writing zeroes and ones to these bits, a group of registers R0-R7 is stored in one of four banks in RAM. RS1 RS2 Space in RAM

Electronics and Communication Engineering

Bank Token Issue System 0 0 1 1 0 1 0 1 Bank0 00h-07h Bank1 08h-0Fh Bank2 10h-17h Bank3 18h-1Fh

F0 - Flag 0. This is a general-purpose bit available to the user. AC - Auxiliary Carry Flag is used for BCD operations only. CY - Carry Flag is the (ninth) auxiliary bit used for all arithmetical operations and
shift instructions.

DPTR Register (Data Pointer) :


These registers are not true ones because they do not physically exist. They consist of two separate registers: DPH (Data Pointer High) and (Data Pointer Low). Their 16 bits are used for external memory addressing. They may be handled as a 16-bit register or as two independent 8-bit registers. Besides, the DPTR Register is usually used for storing data and intermediate results which have nothing to do with memory locations.

SP Register (Stack Pointer)

Electronics and Communication Engineering

Bank Token Issue System

The stack is a section of RAM used by the CPU to store information temporarily. This information could be data or an address. The CPU needs this storage area since there are only a limited number of registers.

Program counter:
The important register in the 8051 is the PC (Program counter). The program counter points to the address of the next instruction to be executed. As the CPU fetches the OPCODE from the program ROM, the program counter is incremented to point to the next instruction. The program counter in the 8051 is 16bits wide. This means that the 8051 can access program addresses 0000 to FFFFH, a total of 64k bytes of code. However, not all members of the 8051 have the entire 64K bytes of on-chip ROM installed, as we will see soon.

TIMERS
On-chip timing/counting facility has proved the capabilities of the microcontroller for implementing the real time application. These includes pulse counting, frequency measurement, pulse width measurement, baud rate generation, etc,. Having sufficient number of timer/counters may be a need in a certain design application. The 8051 has two timers/counters. They can be used either as timers to generate a time delay or as counters to count events happening outside the microcontroller. Let discuss how these timers are used to generate time delays and we will also discuss how they are been used as event counters.

Electronics and Communication Engineering

Bank Token Issue System

PROGRAMMING 8051 TIMERS


The 8051 has timers: Timer 0 and Timer1.they can be used either as timers or as event counters. Let us first discuss about the timers registers and how to program the timers to generate time delays.

BASIC RIGISTERS OF THE TIMER


Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit architecture, each 16-bit timer is accessed as two separate registers of low byte and high byte.

TIMER 0 REGISTERS:
The 16-bit register of Timer 0 is accessed as low byte and high byte. the low byte register is called TL0(Timer 0 low byte)and the high byte register is referred to as TH0(Timer 0 high byte).These register can be accessed like any other register, such as A,B,R0,R1,R2,etc.for example, the instruction MOV TL0, #4Fmoves the value 4FH into TL0,the low byte of Timer 0.These registers can also be read like any other register.

TIMER 1 REGISTERS

Electronics and Communication Engineering

Bank Token Issue System Timer 1 is also 16-bit register is split into two bytes, referred to as TL1 (Timer 1 low byte) and TH1 (Timer 1 high byte).these registers are accessible n the same way as the register of Timer 0.

TMOD (timer mode) REGISTER


Both timers TIMER 0 and TIMER 1 use the same register, called TMOD, to set the various timer operation modes. TMOD is an 8-bit register in which the lower 4 bits are set aside for Timer 0 and the upper 4 bits for Timer 1.in each case; the lower 2 bits are used to set the timer mode and the upper 2 bits to specify the operation.

MODES: M1, M0: M0 and M1 are used to select the timer mode. There are three modes: 0, 1, 2.Mode 0 is a 13-bit timer, mode 1 is a 16-bit timer, and mode 2 is an 8-bit timer. We will concentrate on modes 1 and 2 since they are the ones used most widely. We will soon describe the characteristics of these modes, after describing the reset of the TMOD register. GATE Gate control when set. The timer/counter is enabled only while the INTx pin is high and the TRx control pin is. Set. When cleared, the timer is enabled. C/T - Timer or counter selected cleared for timer operation (Input from internal system clock).set for counter Operation (input TX input pin). M1 M0 M1 0 Mode bit 1 Mode M0 0 bit 0 MODE 0 Operating Mode 13-bit timer mode

Electronics and Communication Engineering

Bank Token Issue System 8-bit timer/counter THx with TLx as 5 - Bit pre-scaler. 0 1 1 16-bit timer mode 16-bit timer/counters THx with TLx are Cascaded; there is no prescaler 1 0 2 8-bit auto reload 8-bit auto reload timer/counter;THx Holds a value that is to be reloaded into TLx each time it overflows. 1 1 3 Split timer mode.

C/T (clock/timer)
This bit in the TMOD register is used to decide whether the timer is used as a delay generator or an event counter. If C/T=0, it is used as a timer for time delay generation. The clock source for the time delay is the crystal frequency of the 8051.this section is concerned with this choice. The timers use as an event counter is discussed in the next section.

Serial Communication
Computers can transfer data in two ways: parallel and serial. In parallel data transfers, often 8 or more lines (wire conductors) are used to transfer data to a device that is only a few feet away. Examples of parallel data transfer are printers and hard disks; each uses cables with many wire strips. Although in such cases a lot of data can be transferred in a short amount of time by using many wires in parallel, the distance cannot be great. To transfer to a device located many meters away, the serial method is used. In serial communication, the data is sent one bit at a time, in contrast to parallel communication, in which the data is sent a

Electronics and Communication Engineering

Bank Token Issue System byte or more at a time. Serial communication of the 8051 is the topic of this chapter. The 8051 has serial communication capability built into it, there by If data is to be transferred on the telephone line, it must be converted from 0s and 1s to audio tones, which are sinusoidal-shaped signals. A peripheral device called a modem, which stands for modulator/demodulator, performs this conversion. Serial data communication uses two methods, asynchronous and synchronous. The synchronous method transfers a block of data at a time, while the asynchronous method transfers a single byte at a time. In data transmission if the data can be transmitted and received, it is a duplex transmission. This is in contrast to simplex transmissions such as with printers, in which the computer only sends data. Duplex transmissions can be half or full duplex, depending on whether or not the data transfer can be simultaneous. If data is transmitted one way at a time, it is referred to as half duplex. If the data can go both ways at the same time, it is full duplex. Of course, full duplex requires two wire conductors for the data lines, one for transmission and one for reception, in order to transfer and receive data simultaneously. making possible fast data transfer using only a few wires.

Asynchronous serial communication and data framing


The data coming in at the receiving end of the data line in a serial data transfer is all 0s and 1s; it is difficult to make sense of the data unless the sender and receiver agree on a set of rules, a protocol, on how the data is packed, how many bits constitute a character, and when the data begins and ends.

Start and stop bits


Asynchronous serial data communication is widely used for character-oriented transmissions, while block-oriented data transfers use the synchronous method. In the asynchronous method, each character is placed between start and stop bits. This is called framing. In the data framing for asynchronous communications, the data, such as ASCII

Electronics and Communication Engineering

Bank Token Issue System characters, are packed between a start bit and a stop bit. The start bit is always one bit, but the stop bit can be one or two bits. The start bit is always a 0 (low) and the stop bit (s) is 1 (high).

Data transfer rate


The rate of data transfer in serial data communication is stated in bps (bits per second). Another widely used terminology for bps is baud rate. However, the baud and bps rates are not necessarily equal. This is due to the fact that baud rate is the modem terminology and is defined as the number of signal changes per second. In modems a single change of signal, sometimes transfers several bits of data. As far as the conductor wire is concerned, the baud rate and bps are the same, and for this reason we use the bps and baud interchangeably. The data transfer rate of given computer system depends on communication ports incorporated into that system. For example, the early IBMPC/XT could transfer data at the rate of 100 to 9600 bps. In recent years, however, Pentium based PCS transfer data at rates as high as 56K bps. It must be noted that in asynchronous serial data communication, the baud rate is generally limited to 100,000bps.

RS232 Standards
To allow compatibility among data communication equipment made by various manufacturers, an interfacing standard called RS232 was set by the Electronics Industries Association (EIA) in 1960. In 1963 it was modified and called RS232A. RS232B AND RS232C were issued in 1965 and 1969, respectively. Today, RS232 is the most widely used serial I/O interfacing standard. This standard is used in PCs and numerous types of equipment. However, since the standard was set long before the advert of the TTL logic family, its input and output voltage levels are not TTL compatible. In RS232, a 1 is represented by -3 to -25V, while a 0 bit is +3 to +25V, making -3 to +3 undefined. For this reason, to connect any RS232 to a microcontroller system we must use voltage converters such as MAX232 to convert the TTL logic levels to the RS232 voltage levels, and vice versa. MAX232 IC chips are commonly referred to as line drivers.

RS232 pins

Electronics and Communication Engineering

Bank Token Issue System RS232 cable is commonly referred to as the DB-25 connector. In labeling, DB25P refers to the plug connector (male) and DB-25S is for the socket connector (female). Since not all the pins are used in PC cables, IBM introduced the DB-9 Version of the serial I/O standard, which uses 9 pins only, as shown in table.

DB-9 pin connector


12345 6789 Pin Functions: Pin 1 2 3 4 5 6 7 8 9 Description Data carrier detect (DCD) Received data (RXD) Transmitted data (TXD) Data terminal ready(DTR) Signal ground (GND) Data set ready (DSR) Request to send (RTS) Clear to send (CTS) Ring indicator (RI)

Note: DCD, DSR, RTS and CTS are active low pins. The method used by RS-232 for communication allows for a simple connection of three lines: Tx, Rx, and Ground. The three essential signals for 2-way RS-232 Communications are these: TXD: carries data from DTE to the DCE. RXD: carries data from DCE to the DTE SG: signal ground

MAX232:

Electronics and Communication Engineering

Bank Token Issue System

Description
Operate from power supply with pump Capacitors. Operates up to 120 kbit/s Two drivers and two receivers 30-v input Level Low supply current Application---Battery Powered system,Modems and Computers To receive data from i.e. a PC, you need a level converter, like a MAX232, or use standard components and make your own level converter A level converter is needed because the Communication port of a PC switches the data between Electronics and Communication Engineering 1.0F chargea single 5-v

Bank Token Issue System approx. -10 to +10 Volt.-10 Volt corresponds with a logical '0' (lo), 10 Volt corresponds with a logical '1' (hi), both on TTL level of 5 Volt, so can be connected directly to the i/o's of an AVR. The MAX232 can convert at a maximum speed of 120kbit/sec.

8051 connection to RS232


The RS232 standard is not TTL compatible; therefore, it requires a line driver such as the MAX232 chip to convert RS232 voltage levels to TTL levels, and vice versa. The interfacing of 8051 with RS232 connectors via the MAX232 chip is the main topic. The 8051 has two pins that are used specifically for transferring and receiving data serially. These two pins are called TXD and RXD and a part of the port 3 group (P3.0 and P3.1). Pin 11 of the 8051 is assigned to TXD and pin 10 is designated as RXD. These pins are TTL compatible; therefore, they require a line driver to make them RS232 compatible. One such line driver is the MAX232 chip. MAX232 converts from RS232 voltage levels to TTL voltage levels, and vice versa. One advantage of the MAX232 chip is that it uses a +5V power source which, is the same as the source voltage for the 8051. In the other words, with a single +5V power supply we can power both the 8051 and MAX232, with no need for the power supplies that are common in many older systems. The MAX232 has two sets of line drivers for transferring and receiving data. The line drivers used for TXD are called T1 and T2, while the line drivers for RXD are designated as R1 and R2. In many applications only one of each is used.

Electronics and Communication Engineering

Bank Token Issue System

CONNECTING C to PC using MAX 232

MAX 232 Serial Line Drivers:


The pin-out diagram of MAX 232 is shown below.

TXD RXD GND

Embedded Controller
MAX 232E Dual Driver/Receiver

INTERRUPTS
A single microcontroller can serve several devices. There are two ways to do that: INTERRUPTS or POLLING.

Electronics and Communication Engineering

Bank Token Issue System INTERRUPTS Vs POLLING: The advantage of interrupts is that the microcontroller can serve many devices (not all the same time, of course); each device can get the attention of the microcontroller based on the priority assigned to it. The polling method cannot assign priority since it checks all devices in round-robin fashion. More importantly, in the interrupt method the microcontroller can also ignore (mask) a device request for service. This is again not possible with the polling method. The most important reason that the interrupt method is preferable is that the polling method wastes much of the microcontrollers time by polling devices that do not need service. So, in order to avoid tying down the microcontroller, interrupts are used.

Six Interrupts in the 8051:


In reality, only five interrupts are available to the user in the 8051, but many manufacturers data sheets state that there are six interrupts since they include reset .the six interrupts in the 8051 are allocated as above. 1. Reset. When the reset pin is activated, the 8051 jumps to address location 0000.this is the power-up reset. 2. Two interrupts are set aside for the timers: one for Timer 0 and one for Timer 1.Memory location 000BH and 001BH in the interrupt vector table belong to Timer 0 and Timer 1, respectively. 3. Two interrupts are set aside for hardware external harder interrupts. Pin number 12(P3.2) and 13(P3.3) in port 3 are for the external hardware interrupts INT0 and INT1,respectively.These external interrupts are also referred to as EX1 and EX2.Memory location 0003H and 0013H assigned to INT0 and INT1, respectively. 4. Serial communication has a single interrupt that belongs to both receive and transmit. The interrupt vector table location 0023H belongs to this interrupt. in the interrupt vector table are

Electronics and Communication Engineering

Bank Token Issue System

Steps in executing an interrupt


Upon activation of an interrupt, the microcontroller goes through the following steps. 1. It finishes the instruction it is executing and saves the address of the next instruction (PC) on the stack. 2. It also saves the current status of all the interrupts internally (i.e., not on the stack). 3. It jumps to a fixed location in memory called the interrupt vector table that holds the address of the interrupts service routine. 4. The microcontroller gets the address of the ISR from the interrupt vector table and jumps to it. It starts to execute the interrupt service subroutine until it reaches the last instruction of the subroutine, which is RETI (return from interrupt). 5. Upon executing the RETI instruction, the microcontroller returns to the place where it was interrupted. First, it gets the program counter (PC) address from the stack by popping the top two bytes of the stack into the PC. Then it starts to execute from that address. Notice from step 5 the critical role of the stack. For this reason, we must be careful in manipulating the stack contents in the ISR. Specifically, in the ISR, just as in any CALL subroutine, the number of pushes and pops must be equal.

Enabling and disabling an interrupt:


Upon reset, all interrupt are disabled (masked), meaning that none will be responded to by the microcontroller if they are activated. The interrupt must be enabled by software in order for the microcontroller to respond to them. There is a register called IE (interrupt enable) that is responsible for enabling (unmasking) and disabling (masking) the interrupts. Notice that IE is a bit-addressable register.

Steps in enabling an interrupt:


Electronics and Communication Engineering

Bank Token Issue System

To enable an interrupt, we take the following steps: 1. Bit D7 of the IE register (EA) must be set to high to allow the reset to take effect. If EA=1, interrupts are enabled and will be responded to if their corresponding bit in IE are high. If EA=0, no interrupt will be responded to, even if the associated bit in the IE register is high.

Interrupt Enable Register


D7 EA D6 -D5 ET2 D4 ES D3 ET1 D2 EX1 D1 ET0 D0 EX0

EA

IE.7

disables all interrupts. If EA=0, no interrupts is acknowledged. If EA=1, each interrupt source is individually enabled disabled By setting or clearing its enable bit.

-ET2 ES ET1 EX1 ET0 EX0

IE.6 IE.5 IE.4 IE.3 IE.2 IE.1 IE.0

Not implemented, reserved for future use.* Enables or disables Timer 2 overflow or capture interrupt (8052 Only) Enables or disables the serial port interrupts. Enables or disables Timers 1 overflow interrupt Enables or disables external interrupt 1. Enables or disables Timer 0 overflow interrupt. Enables or disables external interrupt.

Electronics and Communication Engineering

Bank Token Issue System The reader provides a path for your application to send and receive commands from the card. There are many types of readers available, such as serial, PC-Card, and standard keyboard models. Unfortunately, the ISO group was unable to provide a standard for communicating with the readers so there is no one-size-fits-all approach to smart card communication. Each manufacturer provides a different protocol for communication with the reader.

First you have to communicate with the reader. Second, the reader communicates with the card, acting as the intermediary before sending the data to the card. Third, communication with a smart card is based on the APDU format. The card will process the data and return it to the reader, which will then return the data to its originating source.

The following classes are used for communicating with the reader:

ISO command classes for communicating with 7816 protocol Classes for communicating with the reader Classes for converting data to a manufacturer-specific format

An application for testing and using the cards for an intended and specific purpose.

FEATURES:
256 8-bit EEPROM organization Byte-wise addressing Irreversible byte-wise write protection of lowest 32 addresses (Byte 0 ... 31) 32 1-bit organization of protection memory Two-wire link protocol End of processing indicated at data output Answer-to-Reset acc. to ISO standard 7816-3 Programming time 2.5 ms per byte for both erasing and writing Minimum of 104 write/erase cycles1) Data retention for minimum of ten years1)

Electronics and Communication Engineering

Bank Token Issue System

SEVENSEGMENTDISPLAYS:
It is an electronic display device . It is composed of seven elements. The seven segments are arranged as a rectangle of two vertical segments on each side with one horizontal segment on the top, middle, and bottom. The segments of a 7-segment display are referred to by the letters A to G, as shown to the right, where the optional DP decimal. point (an "eighth segment") is used for the display of non-integer numbers..Seven-segment displays may use a liquid crystal display (LCD),arrays of light-emitting diodes (LEDs),

Seven segment display connections

Electronics and Communication Engineering

Bank Token Issue System

CHAPTER:3 SOFTWARE DESCRIPTION

Electronics and Communication Engineering

Bank Token Issue System

ABOUT SOFTWARE
Software used is: *Keil software for C programming KEIL Vision3 What's New in Vision3? Vision3 adds many new features to the Editor like Text Templates, Quick Function Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for dialog based startup and debugger setup. Vision3 is fully compatible to Vision2 and can be used in parallel with Vision2. What is Vision3? Vision3 is an IDE (Integrated Development Environment) that helps you write, compile, and debug embedded programs. It encapsulates the following components: A project manager. A make facility. Tool configuration. Editor. A powerful debugger.

EMBEDDED C: The programming Language used here in this project is an Embedded C Language. This Embedded C Language is different from the generic C language in few things like a) Data types b) Access over the architecture addresses.

Electronics and Communication Engineering

Bank Token Issue System The Embedded C Programming Language forms the user friendly language with access over Port addresses, SFR Register addresses etc. Embedded C Data types: Data Types unsigned char signed char unsigned int signed int sbit bit sfr Size in Bits 8-bit 8-bit 16-bit 16-bit 1-bit 1-bit 8-bit Data Range/Usage 0-255 -128 to +127 0 to 65535 -32,768 to +32,767 SFR bit addressable only RAM bit addressable only RAM addresses 80-FFH only Signed char: o Used to represent the or + values. o As a result, we have only 7 bits for the magnitude of the signed number, giving us values from -128 to +127.

SOFTWARE
Vision3
Vision3 is an IDE (Integrated Development Environment) that helps you write, compile, and debug embedded programs. It encapsulates the following components: A project manager. A make facility. Tool configuration. Editor. A powerful debugger.

Electronics and Communication Engineering

Bank Token Issue System To help you get started, several example programs (located in the \C51\Examples, \C251\Examples, \C166\Examples, and \ARM\...\Examples) are provided. HELLO is a simple program that prints the string "Hello World" using the Serial Interface. Building an Application in Vision2 To build (compile, assemble, and link) an application in Vision2, you must: 1. Select Project - (for example, 166\EXAMPLES\HELLO\HELLO.UV2). 2. Select Project - Rebuild all target files or Build target. Vision2 compiles, assembles, and links the files in your project.

Creating Your Own Application in Vision2 To create a new project in Vision2, you must: 1. Select Project - New Project. 2. Select a directory and enter the name of the project file. 3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device Database. 4. Create source files to add to the project. 5. Select Project - Targets, Groups, Files, Add/Files, select Source Group1, and add the source files to the project. 6. Select Project - Options and set the tool options. Note when you select the target device from the Device Database all special options are set automatically. You typically only need to configure the memory map of your target hardware. Default memory model settings are optimal for most applications. 7. Select Project - Rebuild all target files or Build target. Debugging an Application in Vision2 To debug an application created using Vision2, you must: 1. Select Debug - Start/Stop Debug Session. 2. Use the Step toolbar buttons to single-step through your program. You may enter G, main in the Output Window to execute to the main C function. 3. Open the Serial Window using the Serial #1 button on the toolbar. Electronics and Communication Engineering

Bank Token Issue System Debug your program using standard options like Step, Go, Break, and so on.

SOURCE CODE

1. 2.

Click on the Keil uVision Icon on Desktop The following fig will appear

3. 4.

Click on the Project menu from the title bar Then Click on New Project

Electronics and Communication Engineering

Bank Token Issue System

5.

Save the Project by typing suitable project name with no extension in u r own folder sited in either C:\ or D:\

6. 7. 8.

Then Click on save button above. Select the component for u r project. i.e. Atmel Click on the + Symbol beside of Atmel

Electronics and Communication Engineering

Bank Token Issue System

9.

Select AT89S52 as shown below

10. 11.

Then Click on OK The Following fig will appear

Electronics and Communication Engineering

Bank Token Issue System

12.

Then Click either YES or NOmostly NO

13. 14.

Now your project is ready to USE Now double click on the Target1, you would get another option Source group 1 as shown in next page.

Electronics and Communication Engineering

Bank Token Issue System

15.

Click on the file option from menu bar and select new

16.

The next screen will be as shown in next page, and just maximize it by double clicking on its blue boarder.

17. 18.

Now start writing program in either in C or ASM For a program written in Assembly, then save it with extension . asm and for C based program save it with extension .C

Electronics and Communication Engineering

Bank Token Issue System

19.

Now right click on Source group 1 and click on Add files to Group Source

20.

Now you will get another window, on which by default C files will appear.

Electronics and Communication Engineering

Bank Token Issue System

21. 22. 23.

Now select as per your file extension given while saving the file Click only one time on option ADD Now Press function key F7 to compile. Any error will appear if so happen.

24.

If the file contains no error, then press Control+F5 simultaneously.

Electronics and Communication Engineering

Bank Token Issue System

25.

The new window is as follows

26.

Then Click OK

27.

Now Click on the Peripherals from menu bar, and check your required port as shown in fig below

28.

Drag the port a side and click in the program file.

Electronics and Communication Engineering

Bank Token Issue System

29. 30.

Now keep Pressing function key F11 slowly and observe. You are running your program successfully

Electronics and Communication Engineering

Bank Token Issue System

CHAPTER:4 CODING IN EMBEDDED C LANGUAGE

Electronics and Communication Engineering

Bank Token Issue System

#include <AT89X52.H> #include<stdio.h> sfr seg1 = 0x90; sfr seg2 = 0xA0; unsigned int q,r,choice; unsigned int v=0; void delay(); void decoder(unsigned int); unsigned char c; void main(void) { SCON = 0X52; TMOD = 0X20; //TCON = 0x69; TH1 = 0XFD;//9600 baud rate TR1=1; IE=0x90; //TCON=0X69; seg1=0xFF; seg2=0xFF; delay();

Electronics and Communication Engineering

Bank Token Issue System

while(1) { /*printf("\7\t\tPress i for Increment\7"); printf("\n\t\tPress d for Decrement\n\7"); printf("\n\t\tPress r to return to zero\n\7");*/ // c=_getkey(); //putchar(c); if(v<=99) { if(c=='i') { v++; c='a'; } if(c=='d') { v--; c='a'; } if(c=='r') { v=0; c='a'; }
Electronics and Communication Engineering

Bank Token Issue System

} else v=0; q = v/10;//to be sent to seg1 r = v%10;//to be sent to seg2 choice = r; decoder(choice); seg2 = B; choice = q; decoder(choice); seg1 = B; } } void serial0() interrupt 4 { if(TI == 1) TI = 0; else { c = SBUF; RI=0;

Electronics and Communication Engineering

Bank Token Issue System

} return; } void delay() { unsigned int i; for(i=0;i<=30000;i++); } void decoder(unsigned int w) { switch(w) { case 1 : { B = 0xF9; delay(); break; } case 2 : { B = 0xA4; delay(); break; } case 3 :
Electronics and Communication Engineering

Bank Token Issue System

{ B = 0xB0; delay(); break; } case 4 : { B = 0x99; delay(); break; } case 5 : { B = 0x92; delay(); break; } case 6 : { B = 0x82; delay(); break; } case 7 : { B = 0xF8; delay();
Electronics and Communication Engineering

Bank Token Issue System

break; } case 8 : { B = 0x80; delay(); break; } case 9 : { B = 0x90; delay(); break; } case 0 : { B = 0xC0; delay(); break; } } }

Electronics and Communication Engineering

Bank Token Issue System

BIBLIOGRAPHY
NAME OF THE SITES

1. 2. 3. 4.

WWW.MITEL.DATABOOK.COM WWW.ATMEL.DATABOOK.COM WWW.FRANKLIN.COM WWW.KEIL.COM

REFERENCES 1. 8051-MICROCONTROLLER AND EMBEDDED SYSTEM. Mohd. Mazidi.

Electronics and Communication Engineering

Você também pode gostar