Sie sind auf Seite 1von 70

EMBEDDED DESIGN USING KEIL AND PROTEUS SOFTWARE

KEIL
Software Development Cycle When using the Keil tools, the project development cycle is similar to any other software development project. 1. Create a project, select the target device from the Device Data base, and configure the tool setting 2. Create your source files in C/C++ or Assembly 3. Build your application with the Project Manager 4. Debug and correct errors in source files, verify and optimize your application 5. Download your code to Flash ROM or SRAM and test the linked application Vision IDE The Vision IDE is a window-based software development platform combining a robust editor, Project Manager, and Make Utility tool. Vision supports all the Keil tools including C/C++ Compiler, Macro Assembler, Linker, Library Manager, and Object-HEX Converter. Vision helps expedite the development process. Vision Debugger The Vision Debugger is completely integrated into the Vision IDE. It provides the following features: Disassembly of the code on C/C++ source or assembly-level with program execution in various stepping modes and various view modes like assembler, text, or mixed mode. The Vision Debugger offers two operating modesSimulator Mode and Target Mode. Simulator Mode configures the Vision Debugger as a software-only product that accurately simulates target systems including instructions and most on-chip peripherals. In this mode, we can test our application code before any hardware is available. It gives us serious benefits for rapid development of reliable embedded software. Target Mode connects the Vision Debugger to real hardware. Vision windows The Project Windows area is that part of the screen in which, by default, the Project Window, Functions Window, Books Window, and Registers Window are displayed. Within the Editor Windows area, we are able to change the source code, view performance and analysis information, and check the disassembly code. The Output Windows area provides information related to debugging, memory, symbols, call stack, local variables, commands, browse information, and find in files results. If, for any reason, we do not see a particular window and have tried displaying/hiding it several times, please invoke the default layout of Vision through the Window Reset Current Layout Menu. Vision Modes The standard working mode is Build Mode. In this mode we write our application, configure the project, set preferences, select the target hardware and the device; we will compile, link, and assemble the programs, correct the errors, and set general settings valid for the entire application. In Debug Mode, we can also change some general options and edit source code files, but these changes

will only be effective after we have switched back to Build Mode, and rebuild our application. Changes to debug settings are effective immediately. Menus The Menu bar provides access to most Vision commands including file operations, editor operations, project maintenance, development tool settings, program debugging, window selection and manipulation, and on-line help. File Menu The File Menu includes commands that open, save, print, and close source files. The Device Database and License Manager dialogs are accessed from this menu. Edit Menu The Edit Menu includes commands for editing the source code; undo, redo, cut, copy, paste, and indentation, bookmark functions, various find and replace commands, source outlining functions, and advanced editor functions. Editor configuration settings are also accessed from this menu. View Menu The View Menu includes commands to display/hide a variety of windows. We can also enable/disable the Status Bar. The Periodic Window Update option is useful in Debug Mode to force the screens to periodically refresh. If this option has not been selected, we can manually update the screens via the Toolbox. Project Menu The Project Menu includes commands to open, save, and close project files. We can Export our project to a previous version of Vision, Manage project components, or Build the project. In addition, we can set Options for the project, group, and file. We can manage multiple projects through the Multi-Project Workspace Menu. Flash Menu The Flash Menu includes commands to configure, erase, and program Flash memory for your embedded target system. Debug Menu The Debug Menu includes commands that start and stop a debug session, reset the CPU, run and halt the program, and single-step in high-level and assembly code. In addition, commands are available to manage breakpoints, view RTOS Kernel information, and invoke execution profiling. We can modify the memory map and manage debugger functions and settings. Help Menu The Help Menu includes commands to start the on-line help system, to list information about on-chip peripherals, to access the knowledgebase, to contact the Technical Support team, to check for product updates, and to display product version information. Peripherals Menu The Peripherals Menu includes dialogs to display and change on-chip peripheral settings. The content of this menu is tailored to show the specific microcontroller options selected for your application. Dialogs are typically available for System Configuration, Interrupts, UARTs, I2C, Timer/Counters, General Purpose I/O, CAN, Pulse-Width Modulators, Real-Time Clocks, and Watchdog Timers. This menu is active in Debug Mode only.

Output Windows By default, the Output Windows1 are displayed at the bottom of the Vision screen and include: The Build Output Window includes errors and warnings from the compiler, assembler, and linker. Double-click a message to jump to the location of the source code that triggered the message. Press F1 for on-line help. The CommandWindow allows us to enter commands and review debugger responses. Hints are provided on the Status Bar of that window. Press F1 for on-line help. The Find in Files Window allows you to double-click a result to locate the source code that triggered the message The Serial and UART windows display I/O information of your peripherals The Call Stack Window enables you to follow the program call tree The Locals Window displays information about local variables of the current function The Watch windows provide a convenient way to personalize a set of variables you would like to trace. Objects, structures, unions, and arrays may be monitored in detail. The Symbols Window is a handy option to locate object definitions. You can drag and drop these items into other areas of Vision. The Memory windows enable you to examine values in memory areas. Define your preferred address to view data. The Source Browser Window offers a fast way to find occurrences and definitions of objects. Enter your search criteria to narrow the output.

Creating Embedded Programs Vision is a Windows application that encapsulates the Keil microcontroller development tools as well as several third-party utilities. Vision provides everything you need to start creating embedded programs quickly. Vision includes an advanced editor, project manager, and make utility, which work together to ease our development efforts, decreases the learning curve, and helps us to get started with creating embedded applications quickly. There are several tasks involved in creating a new embedded project: Creating a Project File Using the Project Windows Creating Source Files Adding Source Files to the Project Using Targets, Groups, and Files Setting Target Options, Groups Options, and File Options Configuring the Startup Code Building the Project Creating a HEX File Working with Multi-Projects

Creating a Project File Creating a new Vision project requires just three steps: 1. Select the Project Folder and Project Filename 2. Select the Target Microcontroller 3. Copy the Startup Code to the Project Folder Selecting the Folder and Project Name To create a new project file, select the Project New Project Menu. This opens a standard dialog that prompts you for the new project file name. It is good practice to use a separate folder for each project. We may use the Create New Folder button in this dialog to create a new empty folder. Select the preferred folder and enter the file name for the new project. Vision creates a new, empty project file with the specified name. The project contains a default target and file group name, which we can view on the Project Window. Selecting the Target Microcontroller After we have selected the folder and decided upon a file name for the project, Vision asks us to choose a target microcontroller. This step is very important, since Vision customizes the tool settings, peripherals, and dialogs for that particular device. The Select Device1,2 dialog box lists all the devices from the Vision Device Database. You may invoke this screen through the Project Select Device for TargetMenu in order to change target later. Copying the Startup Code All embedded programs require some kind of microcontroller initialization or startup code1,2 that is dependent of the tool chain and hardware we will use. It is required to specify the starting configuration of our hardware. All Keil tools include chip-specific startup code for most of the devices listed in the Device Database. Copy the startup code to your project folder and modify it there only. Vision automatically displays a dialog to copy the startup code into our project folder. Answer this question with YES. Vision will copy the startup code to our project folder and adds the startup file to the project. The startup code files are delivered with embedded comments used by the configuration wizard to provide us with a GUI interface for startup configuration. Using the Project Windows Once we have created a project file successfully, the Project Window shows the targets, groups, and files of our project. By default, the target name is set to Target 1, while the groups name is Source Group 1. The file containing the startup code is added to the source group. Any file, the startup file included, may be moved to any other group we may define in future. The Books Window, also part of the Project Windows, provides the Keil product manuals, data sheets, and programmers guides for the selected microcontroller.Double-click a book to open it. Creating Source Files Use the button on the File Toolbar or the select the File New Menu to create a new source file This action opens an empty Editor Window to enter our source code. Vision enables color syntax highlighting based on the file extension (after you have saved the file). To use this feature immediately, save the empty file with the desired extension prior to starting coding. Save the new source file using the button on the File Toolbar or use the File Save Menu.

Adding Source Files to the Project After we have created and saved our source file, add it to the project.Files existing in the project folder,but not included in the current project structure, will not be compiled.Right click a file group in the Project Window and select Add Files to Group from the Context Menu. Then, select the source file or source files to be added.A self-explanatory window will guide through the steps of adding a file. Using Targets, Groups, and Files The Visions very flexible project management structure allows you to create more than one Target for the same project.A Target is a defined set of build options that assemble,compile, and link the included files in a specific way for a specific platform. Multiple file groups may be added to a target and multiple files may be attached to the same file group. Building the Project Several commands are available from the Build Toolbar or Project Menu to assemble, compile, and link the files of your project. Before any of these actions are executed, files are saved. Translate File compiles or assembles the currently active source file Build Target compiles and assembles those files that have changed, then links the project Rebuild compiles and assembles all files, regardless whether they have changed or not, then links the project While assembling, compiling, and linking, Vision displays errors and warnings in the Build Output Window.Highlight an error or warning and press F1 to get help regarding that particular message. Double-click the message to jump to the source line that caused the error or warning.Vision displays the message 0 Error(s), 0 Warning(s) on successful completion of the build process.Though existing warnings do not prevent the program from running correctly, you should consider solving them to eliminate unwanted effects, such as time consumption, undesirable side effects, or any other actions not necessary for your program. Creating a HEX File Check the Create HEX File box under Options for Target Output, and Vision will automatically create a HEX file during the build process.Select the desired HEX format through the drop-down control to generate formatted HEX files, which are required on some Flash programming utilities.

PROTEUS
The Proteus Design Suite is wholly unique in offering the ability to co-simulate both high and low-level micro-controller code in the context of a mixed-mode SPICE circuit simulation. With this Virtual System Modelling facility, we can transform our product design cycle, reaping huge rewards in terms of reduced time to market and lower costs of development.The hardware design may be changed just as easily as the software design. In larger organisations where the two roles are separated, the software designers can begin work as soon as the schematic is completed; there is no need for them to wait until a physical prototype exists. In short, Proteus VSM improves efficiency, quality and flexibility throughout the design process.

SCREEN LAYOUT
The Menu Bar The Menu Bar runs across the top row of the screen and its main purpose (the selection of commands from the menus) is the same as with any other Windows application. In addition, the title bar area above the menu names is used to display certain prompt messages which indicate when the program has entered a particular editing or processing mode. The Toolbars ISIS provides access to a number of its commands and modes through the use of toolbars. The toolbars can be dragged to any of the four edges of the ISIS application window. Command Toolbars The tools located along the top of the screen (by default) provide alternative access to the menu commands, as follows: File/Print commands Display Commands Editing Commands Design Tools If you are working on a relatively small monitor, you can hide any or all of the command toolbars using the Toolbars command on the View menu. Mode Selector Toolbar The toolbar located down the left hand edge of the screen select the editor mode, i.e. what happens when you click the mouse on the Editing Window. Main Modes Gadgets 2D Graphics

Note that the mode toolbar cannot be hidden, as its functions are not duplicated on the menus. Orientation Toolbar The orientation toolbar displays and controls the rotation and reflection for objects placed onto the layout. Rotation Reflection The edit box allows you type a rotation angle in directly; but note that in ISIS, only orthogonal angles may be entered. When an existing object is tagged, the rotation and reflections icons highlight in red to show that they will modify the orientation of an object on the layout. When the icons are not highlighted, they serve to determine the orientation for new objects. The Editing Window The Editing Window displays the part of the schematic that you are currently editing. The contents of the Editing Window may be redrawn using the Redraw command on the View menu. This also redraws the Overview Window. We can use this feature after any other command that has left the display somewhat untidy. Panning You can reposition the Editing Window over different parts of the design in several ways: By clicking left at a point on the Overview Window - this re-centres the Editing Window about the marked point. By moving the mouse over the Editing Window, holding down the SHIFT key, and 'bumping' the pointer against one of its edges. This pans the display in the appropriate direction. We refer to this feature as Shift-Pan. By pointing in the Editing Window and pressing the Zoom key (see below).This recentres the display about the cursor position. By using the Pan icon on the toolbar. Zoom In / Zoom Out We can magnify or reduce the display of the board using the Zoom In and and Zoom Out commands which are also invoked by the F6 and F7 shortcut keys. Pressing F8 will display a view of the entire board. We can also use the corresponding icons on the toolbar. If the keyboard is used to invoke the command, then the Editing Window will be redrawn to display a region centred around where the mouse cursor was pointing before. This also provides a way to effect a pan by pressing the zoom key for the current level and simultaneously pointing with the mouse at where you want centre of the new display to be. Variable Zoom An arbitrary degree of magnification can be achieved using the Shift-Zoom feature. A given area of the board can be selected to fill the Editing Window by holding down the SHIFT key, pressing the left mouse button and dragging out a box around the desired area. The area can be marked on either the Editing Window or the Overview Window. We can also zoom to an area by clicking the Zoom Area icon on toolbar.

10

The Overview Window This window normally shows a simplified representation of the whole drawing, and has a half-inch grid on it. The cyan box marks the outline of the sheet border, whilst the green box indicates the area of the design currently visible in the Editing Window. Clicking left at a point on the grid re-centres the Editing Window around this point, and redraws the Editing Window. At other times, Overview Window is used to display a preview of an object that is selected for placement. This Place Preview feature is activated in the following circumstances for any object which may be oriented: When an object is selected from the object selector. When the rotate or mirror icons are adjusted. When an object type icon is selected for an object whose orientation can be set (e.g. the Component icon, Device Pin icon, etc.). The place preview display is cleared automatically as soon as you proceed the place the object, or when you perform any operation other than those listed above. The width and height of the Overview Window can be adjusted by dragging its borders. If you drag the vertical border right over to the other side of the application Window, ARES will re-organize the display so that the Overview Window and Object Selector are located at the right hand side. The Object Selector The Object Selector is used for picking components, terminals, generators, graph types and so on from those that are available. It always carries a label indicating what it is listing and this serves as a prompt additional to the state of the Icon Panel as to which mode is current. The width and position of the Object Selector can be adjusted in conjunction with the width and height of the Overview Window, as described above. The buttons at the top left of the object selector activate various functions such as library browsing and library management. The exact functions available depend on the current editor mode. Starting a New Design The New Design command will clear out all existing design data and present a single, empty A4 sheet. The design name is set to UNTITLED.DSN and this name will be used by the Save Design command and also as the default filestem in other file selectors. Should you wish to start a new design and give it a name at the same time, you can use the Load Design command and enter the new filename in the file selector. Saving the Design We can save your design when quitting ISIS via the Exit command, or at any other time, using the Save Design command. In both cases it is saved to the same file from which it was loaded. The old version will be prefixed with the text Backup of. The Save As command allows you to save the design to a different file.

11

GENERAL EDITING FACILITIES


Object Placement 1. Select the appropriate icon from the Mode Selector toolbar for the category of object that you want to place. 2. If the object type is Component, Terminal, Pin, Graph, Symbol or Marker, select the name of the object that you want from the selector. For Components, Terminals, Pins and Symbols, this may first involve picking it from the libraries. 3. If the object is orientable, it will have appeared in the Overview Window. You should now adjust its orientation to that which you require by clicking on the Rotation and Mirror icons. 4. Finally, point on the Editing Window and click left to place or drag the object. Tagging an Object Any object may be tagged by pointing at it and clicking right. This action highlights the object and selects it for further editing operations. Any wires connected to an object that is tagged are also tagged. A group of tagged objects may be assembled either by clicking right on each object in turn, or by dragging a box around the objects using the right button. Only objects wholly enclosed in the box will be tagged. All the objects may be untagged by pointing at no object and clicking right. Deleting an Object We can delete any tagged object by pointing at it and clicking right. All wires connected to the object will also be deleted, except in the case of a dot connected to exactly 2 wires, in which case the wires will be joined. Dragging an Object We can drag (i.e. re-position) any tagged object by pointing at it and then dragging with the left button depressed. This applies not only to whole objects, such a components, but also individually to their labels. If the Wire Auto Router is enabled and there are wires connected to it, then these will be re-routed or 'fixed up'. This can take some time (10 seconds or so) if the object has a lot of connected wires; the pointer becomes an hour glass while this is happening. If you drag an object by mistake, and all the wiring goes horribly wrong, you can use the Undo command, key U to restore things to their original state. Resizing an Object Sub-circuits, graphs, lines, boxes and circles may be resized. When you tag these objects, little white squares called handles will appear and the object can be re-sized by dragging the handles. To resize an object: 1. Tag the object by pointing at it and clicking right. 2. If the object can be resized, a set of little square handles will appear on it.

12

3. Resize the object by pointing at a handle, pressing the left mouse button, and dragging it to a new position. The handles disappear whilst you are dragging so that they do not obscure your view of the object itself. Editing an Object Many of the objects have graphical and/or textual properties that may be edited through a dialogue form, and because this is a very common operation we have provided a variety of ways to achieve it. To edit a single object using the mouse: 1. Tag the object by pointing at it and clicking right. 2. Click left on it, as if to drag, but release the mouse button immediately, without moving the mouse. To edit a succession of objects using the mouse: 1. Select the Instant Edit icon. 2. Point at each object in succession and click left. To edit an object and access special edit modes: 1. Point at the object. 2. Press CTRL+'E'. For text scripts, this will invoke the external text editor. Also, if the mouse is not over any object, this command will edit the current graph, if any. To edit a component by name: 1. Key 'E'. 2. Type in the reference name (part ID) of a component.

WIRING UP
Wire Placement We may have noticed that there is no Wire icon. This is because ISIS is intelligent enough to detect automatically when you want to place a wire. This avoids the tedium of having to select a wire-placement mode. To connect a wire between two objects: 1. Click left on the connection point of the first object. 2. If you want ISIS to auto-route the wire, just click left on a second connection point. On the other hand, if you wish to determine the wire's route yourself, you can click left on one or intermediate points which will become corners in the wire's route. We can abort the routing of a wire by pressing ESC at any stage of the process. The Wire Auto-Router The Wire Auto-Router (WAR) saves you the chore of having to mark out the exact route of each wire. The feature is enabled by default, but can be overridden in two ways. If you simply click left at two connection points, the WAR will attempt to chose a sensible path for the wire. If, however, you click on one connection point, and then click at one or more positions which are not connection points, ISIS will assume you are manually routing the wire and will let you click at each

13

corner of the wire's route. The route is completed by clicking left on a second connection point. The WAR can be completely disabled using the Wire Auto-Router command on the Tools menu. Steps to create a project To start the ISIS program, click on the Start button and select Programs, Proteus 6 Professional, and then the ISIS 6 Professional option. The ISIS schematic editor will then load and run. Begin by pointing at the P button at the top left of the Object Selector and clicking left. This causes the Device Library Selector dialogue form to appear and we can now select devices from the various device libraries. There are a number of selectors labelled Objects, Libraries, Extensions and a Browser. After selecting the appropriate objects, we need to do wiring. After wiring is completed, load the program for microcontroller by double clicking it and giving the path of the file. Save the design. Click on the run button to simulate the project.

14

15

16

EX.NO:1 17.09.2013

PULSE GENERATION AND LCD DISPLAY

AIM:
To write an embedded C program for pulse generation and LCD display using Keil software and implement using Proteus software.

APPARATUS REQUIRED:

S.No 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11.

COMPONENTS Keil Software Proteus Software Microcontroller Crystal Oscillator Resistor Resistor Pack Capacitor Capacitor LCD Display DIP Switch DSO

CONFIGURATION

QUANTITY

AT89C51 11.059MHz 10Kohm 10Kohm 33pF 4.7F LM016L DIPSW_4 -

1 No 1 No 1 No 1 No 1 No 1 No 1 No 1 No 1 No

THEORY: PULSE GENERATION:


A pulse is a single disturbance that moves through a medium from one point to the next point.Frequency is the number of occurrence of a repeating event per unit time. The time or period, usually denoted by T, is the length of time taken by one cycle, and is the reciprocal of the frequency f. T=1/f The SI unit for period is the second.

17

PIN DIAGRAM OF 8051:

18

LCD INTERFACING WIH 8051:

8 data pins D7:D0

Bi-directional data/command pins. Alphanumeric characters are sent in ASCII format. RS: Register Select RS = 0 -> Command Register is selected RS = 1 -> Data Register is selected R/W: Read or Write 0 -> Write, 1 -> Read E: Enable (Latch data) This pin is used to latch the data present on the data pins. A high-to-low edge is needed to latch the data. VEE : contrast control When writing to the display, data is transferred only on the high to low transition of this signal. However, when reading from the display, data will become available shortly after the low to high transition and remain available until the signal falls low again. Busy Flag (BF) When the busy flag is 1, the LCD is in the internal operation mode, and the next instruction will not be accepted. When RS = 0 and R/W = 1, the busy flag is output to DB7 (MSB of LCD data bus). The next instruction must be written after ensuring that the busy flag is 0. LCD Commands The LCDs internal controllers accept several commands and modify the display accordingly. These commands would be things like: Clear screen, Return home, Shift display right/left INSTRUCTION Function set (8-bit interface, 2 lines, 5*7 Pixels) Function set (8-bit interface, 1 line, 5*7 Pixels) Function set (4-bit interface, 2 lines, 5*7 Pixels) Function set (4-bit interface, 1 line, 5*7 Pixels) Entry mode set DECIMAL 56 48 40 32 See Below HEX 38 30 28 20 See Below

19

TABULATION:
0 means ON STATE 1 means OFF STATE I04 8KHz 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 I03 6KHz 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 I02 4KHz 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 I01 2KHz 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 OUTPUT IN KHz 20 18 16 14 14 12 10 8 12 10 8 6 6 4 2 0

20

Scroll display one character right (all lines) Scroll display one character left (all lines) Home (move cursor to top/left character position) Move cursor one character left Move cursor one character right Turn on visible underline cursor Turn on visible blinking-block cursor Make cursor invisible Blank the display (without clearing) Restore the display (with cursor hidden) Clear Screen Set cursor position (DDRAM address) Set pointer in character-generator RAM (CG RAM address)

28 24 2 16 20 14 15 12 8 12 1 128 + addr 64 + addr

1E 18 2 10 14 0E 0F 0C 08 0C 01 80+ addr 40+ addr

SOURCE CODE:
#include<regx51.h> sfr out=0x90; sbit rs=0xa0; sbit rw=0xa1; sbit e=0xa2; sfr p1=0xb0; sbit in1=0xb0; sbit in2=0xb1; sbit in3=0xb2; sbit in4=0xb3; sbit freqout=0xa5; unsigned int t1,f,sum; void in_init(void); void ex_init(void); void command(unsigned char); void ldatas(unsigned char const *dat); void delay(unsigned int); void main(void) { f,sum=0x00; in_init(); ex_init(); while(1) { f=0x00; if(in1==0) {

21

TMOD Register (Timer Mode):


The TMOD register selects the operational mode of the timers T0 and T1. As seen in figure below, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4 bits (bit4 - bit7) refer to the timer 1. There are 4 operational modes and each of them is described herein. BIT 7 GATE1 BIT 6 C/T1 BIT 5 T1M1 BIT 4 T1M0 BIT 3 GATE0 BIT 2 C/T0 BIT 1 T0M1 BIT 0 T0M0

GATE1 enables and disables Timer 1 by means of a signal brought to the INT1 pin (P3.3)
o o

1 - Timer 1 operates only if the INT1 bit is set. 0 - Timer 1 operates regardless of the logic state of the INT1 bit.

C/T1 selects pulses to be counted up by the timer/counter 1:


o o

1 - Timer counts pulses brought to the T1 pin (P3.5). 0 - Timer counts pulses from internal oscillator.

T1M1, T1M0 These two bits select the operational mode of the Timer 1. T1M1 0 0 1 1 T1M01 0 1 0 1 MODE 0 1 2 3 DESCRIPTION 13- bit timer 16- bit timer 8- bit auto- reload Split mode

GATE0 enables and disables Timer 1 using a signal brought to the INT0 pin (P3.2):
o o

1 - Timer 0 operates only if the INT0 bit is set. 0 - Timer 0 operates regardless of the logic state of the INT0 bit.

C/T0 selects pulses to be counted up by the timer/counter 0:


o o

1 - Timer counts pulses brought to the T0 pin (P3.4). 0 - Timer counts pulses from internal oscillator.

T0M1, T0M0 These two bits select the operational mode of the Timer 0.

22

f=f+2; } if(in2==0) { f=f+4; } if(in3==0) { f=f+6; } if(in4==0) { f=f+8; } if((p1&0x0f)==0x0f) { TR0=0; t1=0x00; command(0x80); ldatas("GOOD MORNING"); command(0xc0); ldatas("freq. Adder off"); } else { sum=(255-(1000000/(f*2*1000))); TH0=TL0=sum; TR0=1; command(0x80); ldatas("WELCOME "); command(0xc0); ldatas("freq. Adder on "); } } } void in_init() { IE=0x82; TMOD=0x02; freqout=0x00; out=0x00; rs=rw=e=0; p1=0xff; } void ex_init() { command(0x38); delay(200); command(0x06);

23

T0M1 T0M0 0 0 1 1 0 1 0 1

MODE 0 1 2 3

DESCRIPTION 13- bit timer 16- bit timer 8- bit auto- reload Split mode

Timer Control (TCON) Register:


TCON register is also one of the registers whose bits are directly in control of timer operation.

BIT 7 TF1

BIT 6 TR1

BIT 5 TF0

BIT 4 TR0

BIT 3 IE1

BIT 2 IT1

BIT 1 IE0

BIT 0 IT0

TF1 bit is automatically set on the Timer 1 overflow. TR1 bit enables the Timer 1.
o o

1 - Timer 1 is enabled. 0 - Timer 1 is disabled.

TF0 bit is automatically set on the Timer 0 overflow. TR0 bit enables the timer 0.
o o

1 - Timer 0 is enabled. 0 - Timer 0 is disabled.

IE Register (Interrupt Enable):

BIT 7 EA

BIT 6 X

BIT 5 X

BIT 4 ES

BIT 3 ET1

BIT 2 EX1

BIT 1 ET0

BIT 0 EX0

EA - global interrupt enable/disable:


o o

0 - disables all interrupt requests. 1 - enables all individual interrupt requests.

ES - enables or disables serial interrupt:


o o

0 - UART system cannot generate an interrupt. 1 - UART system enables an interrupt.

24

delay(200); command(0x0c); delay(200); command(0x01); delay(200); } void command(unsigned char a) { out=a; rs=0; e=1; delay(1000); e=0; } void ldatas(unsigned char const *dat) { while(*dat) { out=(*dat); rs=1; e=1; delay(1000); e=0; dat++; } } void delay(unsigned int x) { while(x--); } void inte(void) interrupt 1 { freqout=~freqout; }

25

ET1 - bit enables or disables Timer 1 interrupt:


o o

0 - Timer 1 cannot generate an interrupt. 1 - Timer 1 enables an interrupt.

EX1 - bit enables or disables external 1 interrupt:


o o

0 - change of the pin INT0 logic state cannot generate an interrupt. 1 - enables an external interrupt on the pin INT0 state change.

ET0 - bit enables or disables timer 0 interrupt:


o o

0 - Timer 0 cannot generate an interrupt. 1 - enables timer 0 interrupt.

EX0 - bit enables or disables external 0 interrupt:


o o

0 - change of the INT1 pin logic state cannot generate an interrupt. 1 - enables an external interrupt on the pin INT1 state change.

26

27

PROTEUS OUTPUT:

28

29

MODIFICATION:
In the main program, the data to LCD is changed from WELCOME to APP. ELECTRONICS for frequency adder on condition.

30

RESULT:
Thus an embedded C program for pulse generation and LCD display is written using keil vision and the hardware is implemented and simulated using proteus tool.

31

32

Ex.no:2 24.09.2013

SERIAL COMMUNICATION AND RTC

AIM:
To develop a source code for serial communication and real time clock display in seven segment LED display using Keil vision and to implement in hardware using Proteus tool.

APPARATUS REQUIRED:
S.No 1. 2. 3. 4. 5. 6. 7. 8. 9. COMPONENTS Keil Software Proteus Software Microcontroller Crystal Oscillator Resistor Resistor Pack Capacitor Capacitor 7 Segment Display CONFIGURATION QUANTITY

AT89C51 11.059MHz 10Kohm RESPACK-8 33pF 4.7F 7SEG-MPX6-CA

1 No 1 No 1 No 1 No 1 No 1 No 2 No

THEORY:
A real time clock(RTC) is a computer clock that the keeps track of the current time. Although the term often refers to the devices in personal computers, servers and embedded system , RTCs are present in almost any electronic device which needs to keep accurate time. Although keeping time can be done without an RTC, using one has benefits:

Low power consumption (important when running from alternate power) Frees the main system for time-critical tasks Sometimes more accurate than other methods

A seven-segment display(SSD) or seven-segment indicator , is a form of electronic display device for displaying decimal numerals that is an alternative to the more complex dot matrix displays. Seven-segment displays are widely used in digital clocks, electronic meters and other electronic devices for displaying numerical information.

33

Common Anode 7 Segment LED display:

7 Segment LED display:

LOOKUP TABLE:
Dp 1 1 1 1 1 1 1 1 1 1 0 G 1 1 0 0 0 0 0 0 0 0 1 F 0 1 1 1 0 0 0 1 0 0 1 SEGMENTS e d 0 0 1 1 0 0 1 0 1 0 1 1 0 0 1 1 0 0 1 1 1 1 C 0 0 1 0 0 0 0 0 0 0 1 b 0 0 0 0 0 1 1 0 0 0 1 a 0 1 0 0 1 0 0 0 0 0 1 HEX CODE C0 F9 A4 B0 99 92 82 F8 80 90 7F DISPLAY 0 1 2 3 4 5 6 7 8 9 .

34

Each of the numbers 0,6,7 and 9 may be represented by two or more different glyphs on seven-segment displays. 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. Additionally ,the seventh segment bisects the rectangle horizontally. There are also fourteen-segment displays and sixteensegment displays(for full alphanumeric); however, these have mostly been replaced by dot-matrix displays. The segments of a 7-segment display are referred to by the letters A to G, 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-emitted diodes(LEDs), or other light-generating or controlling techniques such as cold cathode gas discharge, vacuum fluorescent ,incandescent filaments and others.

SOURCE CODE:
#include<regx51.h> sfr LED_DATA=0x80; sbit COM1=0xa0; sbit COM2=0xa1; sbit COM3=0xa2; sbit COM4=0xa3; sbit COM5=0xa4; sbit COM6=0xa5; sfr LED_DATA1=0x90; sbit DCOM1=0xb2; sbit DCOM2=0xb3; sbit DCOM3=0xb4; sbit DCOM4=0xb5; sbit DCOM5=0xb6; sbit DCOM6=0xb7; unsigned char const*dat="Real time clock starts now"; unsigned char const lookup[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; unsigned char const lookup1[10]={0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x10}; unsigned char out[12]={0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0}; unsigned int i,temp; unsigned char hour,min,sec,a,year,mon,date; void var_init(void); void in_phinit(void); void timeanddatefunction(void); void buffer_upgrade(void); void timedisplay_count(void); void datedisplay_count(void); void main(void) { var_init(); in_phinit(); while(1) {

35

TMOD 0X01
Gate 0 C/T 0 M1 0 M2 0 Gate 0 C/T 0 M1 0 M0 1

TIMER0 in 16 bit timer mode.

TMOD 0X20
Gate 0 C/T 0 M1 1 M2 0 Gate 0 C/T 0 M1 0 M0 0

TIMER1 in 8 bit auto reload is enabled.

Baud Rate:
The rate at which the bits are transmitted bits for second or number of signal changes for second is called baud rate. Baud rate = (2smod x oscillator freq) / (32 x 12 x(256-TH1)) If SMOD in PCON = 0, then 2smod = 1 If SMOD in PCON = 1, then 2smod = 2 Overall rate = Count rate /(256-TH1)

Common Anode 7 Segment LED display

36

if(*dat) { TR0=0; TR1=1; SBUF=*dat; TI=0; while(TI==0); for(i=0;i<=3500;i++); dat++; } else { TR1=0; IE=0x82; TMOD=0x01; TR0=1; } } } void twenty_ms_upgrade(void)interrupt 1 { TH0=0xb7; TL0=0xfe; TR0=1; timeanddatefunction(); buffer_upgrade(); timedisplay_count(); datedisplay_count(); } void var_init(void) { hour=0x03; min=0x1e; sec=0x1e; year=0x0c; mon=0x09; date=0x18; } void in_phinit(void) { LED_DATA=0Xff; SCON=0x40; TMOD=0x20; TH1=0xfd; TL1=0x00; }

37

PROTEUS OUTPUT:

38

void timeanddatefunction(void) { a++; if(a==50) { a=0x00; sec++; if(sec==60) { sec=0x00; min++; } if(min==60) { min=0x00; hour++; } if(hour==24) { hour=0x00; date++; } if(date==31) { date=0x01; mon++; } if(mon==13) { mon=0x01; year++; } } } void buffer_upgrade(void) { out[0]=(lookup[sec%10]); out[1]=(lookup[sec/10]); out[2]=(lookup1[min%10]); out[3]=(lookup[min/10]); out[4]=(lookup1[hour%10]); out[5]=(lookup[hour/10]); out[6]=(lookup[year%10]); out[7]=(lookup[year/10]); out[8]=(lookup1[mon%10]); out[9]=(lookup[mon/10]); out[10]=(lookup1[date%10]); out[11]=(lookup[date/10]); }

39

40

void timedisplay_count(void) { unsigned char temp; LED_DATA=out[5]; COM1=1; temp=100; while(temp--); COM1=0; LED_DATA=out[4]; COM2=1; temp=100; while(temp--); COM2=0; LED_DATA=out[3]; COM3=1; temp=100; while(temp--); COM3=0; LED_DATA=out[2]; COM4=1; temp=100; while(temp--); COM4=0; LED_DATA=out[1]; COM5=1; temp=100; while(temp--); COM5=0; LED_DATA=out[0]; COM6=1; temp=100; while(temp--); COM6=0; } void datedisplay_count(void) { unsigned char temp; LED_DATA1=out[11]; DCOM1=1; temp=100; while(temp--); DCOM1=0; LED_DATA1=out[10]; DCOM2=1; temp=100; while(temp--); DCOM2=0; LED_DATA1=out[9]; DCOM3=1; temp=100;

41

42

while(temp--); DCOM3=0; LED_DATA1=out[8]; DCOM4=1; temp=100; while(temp--); DCOM4=0; LED_DATA1=out[7]; DCOM5=1; temp=100; while(temp--); DCOM5=0; LED_DATA1=out[6]; DCOM6=1; temp=100; while(temp--); DCOM6=0; }

RESULT:
Thus the source code for serial communication and real time clock display in seven segment LED display is developed using Keil and implemented in Proteus and verified.

43

44

EX.NO:3 01.10.2013

MANUAL TIMER SET PROGRAM

AIM:
To write a source code for manual timer using keil vision and implement it in hardware using proteus tool.

APPARATUS REQUIRED:
S.No 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. COMPONENTS Keil Software Proteus Software Microcontroller Crystal Oscillator Resistor Resistor Pack Capacitor Capacitor 7 Segment Display Button Switch Motor Resistor CONFIGURATION QUANTITY

AT89C51 12MHz 10Kohm RESPACK_8 33pF 4.7F 7SEG-MPX4-CA BUTTON LED BIRG 470 ohm

1 No. 1 No. 1 No. 1 No. 2 Nos. 1 No. 1 No. 3 Nos. 1 No. 1 No.

THEORY:
A manual timer is a specialized type of clock for measuring time intervals.A timer which counts upwards from zero for measuring elapsed time and which counts down from a specified time interval is called a manual timer. Time switches or timing mechanisms which activate a switch, are sometimes called "timers". Timing functionality can be provided by software, the program is often called a "timer". As the number of hardware timers in a computer processor is finite and limited, operating systems and embedded systems often use a single hardware timer to implement an extensible set of software manual timers. In this scenario, the hardware timer's interrupt service routine would handle house-keeping and management of as many software timers as are required, and the hardware timer would be set to expire when the next software timer is due to expire. At expiry, the interrupt routine would update the hardware timer to expire when the next software timer is due, and any actions would be triggered for the software timers that had just expired. Expired timers that are continuous would also be reset to a new expiry time based on their timer interval, and one-shot timers would be disabled or removed from the set of timers.

45

LOOK UP TABLE (COMMON CATHODE):


SEGMENTS Dp 0 0 0 0 0 0 0 0 0 0 1 G 0 0 1 1 1 1 1 0 1 1 0 F 1 0 0 0 1 1 1 0 1 1 0 E 1 0 1 0 0 0 1 0 1 0 0 D 1 0 1 1 0 1 1 0 1 1 0 C 1 1 0 1 1 1 1 1 1 1 0 b 1 1 1 1 1 0 0 1 1 1 0 A 1 0 1 1 0 1 1 1 1 1 0 HEX CODE 3F 06 5B 4F 66 6D 7D 07 7F 6F 80

DISPLAY 0 1 2 3 4 5 6 7 8 9 .

ANALYSIS OF SOURCE CODE:


Change common anode into common cathode 1. Change the unsigned char const lookup[10] into common cathode hexcode. 2. Change the display common anode into common cathode. 3. Change the terms COM2=1; temp=100; into into COM2=0; temp=100; while(temp--); COM@=1;

while(temp--); into COM2=0; into

There are two types of LED 7-segment displays: common cathode (CC) and common anode (CA). The difference between the two displays is the common cathode has all the cathodes of the 7segments connected directly together and the common anode has all the anodes of the 7-segments connected together. Shown below is a common anode seven segment.

46

When working with a CA seven segment displays, power must be applied externally to the anode connection that is common to all the segments. Then by applying a ground to a particular segment connection (a-g), the appropriate segment will light up. An additional resistor must be added to the circuit to limit the amount of current flowing through each LED segment. A common cathode seven segment is different from a common anode segment in that the cathodes of all the LEDs are connected together. For the use of the seven segments, the common cathode connection must be grounded and power must be applied to appropriate segment in order to illuminate that segment. The 89C51 microcontroller has two 16 bit timers/counters. These two timer/counter can be programmed independently. There is a bit in the TMOD SFR that specifies whether it is a timer/counter. If this bit is set, the timer/counter will work as counter and if the bit is zero. The timer/counter will work as a timer.

TIMER MODE:
When a timer/counter is functioning as a timer, the timer register (TH1 and/or TL1 for timer 1 or TH0 and/or TL0 for timer 0) is incremented after every machine cycle. That is it will be working at 1/12th of the oscillator frequency because each machine cycle has 12 oscillation periods.

SOURCE CODE:
#include<REGX51.H> #define ON 1 #define OFF 0 #define U2 unsigned int #define U1 unsigned char #define U4 unsigned long sfr LED_DATA=0x80; sbit COM1=0xa0; sbit COM2=0xa1; sbit COM3=0xa2; sbit COM4=0xa3; sbit RST=0x90; sbit SET=0x91; sbit DEC=0x92; sbit MOTOR=0xb0; U2 u2_Dcount=0, u2_Scount=50; U1 u1_DISP_BUF[4]={0xc0,0xc0,0xc0,0xc0}; code unsigned char const lookup[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; void Port_Init(void); void Set_Count(void); void EventTimer_Init(void); void show_Scount(void); void second_update(void); void display_count(void); void delay(U4);

47

PROTEUS OUTPUT:

ANALYSIS OF SOURCE CODE:


1. Change the default 50sec to 35sec. U2_scount=35 2. Count 2 digits up to 99 Initialize u2_scount=99 If(u2_scount<99)

48

void main(void) { Port_Init(); EventTimer_Init(); while(1) { if(u2_Dcount>=u2_Scount) { MOTOR=OFF; u2_Dcount=0; } Set_Count(); } } void Event_20ms(void)interrupt 1 { second_update(); display_count(); TH0=0xb1; TL0=0xbf; TF0=0; } void Port_Init(void) { MOTOR=0; LED_DATA=0x00; COM1=COM2=COM3=COM4=0; RST=SET=DEC=1; } void EventTimer_Init(void) { IE=0x82; TMOD=0x01; TH0=0xb1; TL0=0xbf; TF0=0; TR0=1; } void Set_Count(void) { if(RST==0) { while(RST==0); if(MOTOR==OFF) { MOTOR=ON; u2_Dcount=0; }

49

50

else { MOTOR=OFF; u2_Dcount=0; } } if(SET==0) { if(MOTOR==OFF) { while(SET==0); do { show_Scount(); if(DEC==0) { while(DEC==0); delay(5000); if(u2_Scount>0) u2_Scount--; else u2_Scount=9999; } if(SET==0) { while(SET==0); delay(5000); if(u2_Scount<9999) u2_Scount++; else u2_Scount=0; } u2_Dcount=0; } while(RST==1); while(RST==0); } } } void show_Scount(void) { U1 tho,hun,ten,one,temp; U2 temp1; tho=u2_Scount/1000; temp1=u2_Scount%1000; hun=temp1/100; temp=temp1%100; ten=temp/10; one=temp%10; u1_DISP_BUF[0]=lookup[tho];

51

52

u1_DISP_BUF[1]=lookup[hun]; u1_DISP_BUF[2]=lookup[ten]; u1_DISP_BUF[3]=lookup[one]; } void second_update(void) { U1 u1_Time_reg; U1 tho,hun,ten,one,temp; U2 temp1; if(MOTOR==ON) { u1_Time_reg++; if(u1_Time_reg==50) { u1_Time_reg=0; if(u2_Dcount==10000) { u2_Dcount=0; } else u2_Dcount++; } tho=u2_Dcount/1000; temp1=u2_Dcount%1000; hun=temp1/100; temp=temp1%100; ten=temp/10; one=temp%10; u1_DISP_BUF[0]=lookup[tho]; u1_DISP_BUF[1]=lookup[hun]; u1_DISP_BUF[2]=lookup[ten]; u1_DISP_BUF[3]=lookup[one]; } } void display_count(void) { U1 temp; LED_DATA=u1_DISP_BUF[0]; COM1=1; temp=100; while(temp--); COM1=0; LED_DATA=u1_DISP_BUF[1]; COM2=1; temp=100; while(temp--); COM2=0; LED_DATA=u1_DISP_BUF[2]; COM3=1;

53

54

temp=100; while(temp--); COM3=0; LED_DATA=u1_DISP_BUF[3]; COM4=1; temp=100; while(temp--); COM4=0; } void delay(U4 con) { while(con--); }

RESULT:
Thus, the source code for manual timer has written using keil vision and the hardware was implemented and simulated using proteus tool.

55

56

EX.NO:4 08.10.2013

I2C EEPROM WRITE AND READ

AIM:
To develop a source code for I2C program using keil vision and to implement it using proteus.

APPARATUS REQUIRED:
S.No 1. 2. 3. 4. 5. 6. 7. 8. COMPONENTS Keil Software Proteus Software Microcontroller Crystal Oscillator Resistor Capacitor Capacitor IC CONFIGURATION QUANTITY

AT89C51 12MHz 10Kohm 33Pf 4.7F 24LC256

1 No. 1 No. 1 No. 2 No. 1 No. 1 No.

THEORY:
I2C is a serial bus interconnecting ICs. It has a start bit and a stop bit like in a UART. It has seven fields for the start, seven bit address, defining a read or write, defining a byte as an acknowledging byte, data byte, NACK and end. The I2C bus has two lines that carry its signals. One line is for clock and another is for bidirectional data. There is protocol for I2C bus. Each device has an address using which the data transfer takes place. The master can address 127 other slaves at an instance. It has a processing element functioning as bus controller or a microcontroller with I2C bus interface circuit. Each circuit have optionally have an I2C bus controller and a processing element. A number of masters can also be connected to the bus. However, at any instance, there can be only one master, which is one that indicates the data transfer on SDA (serial data) line and which transmits the SCL (serial clock) pulses. From the master or slaver, a data frame has fields beginning from start bit. The disadvantage of the bus is the time taken by the algorithm in the master hardware the analyses the bits through I2C in case the slave hardware do not provide for the hardware that supports it. Some I2C support the protocol and some do not. In that case, interface circuits for those ICs are also required. Also there are open collector drivers at the master. Therefore, a pull-up resistor of 2.2K or an active circuit for pull-up of line to logic one for on each line is essential.

57

PROTEUS OUTPUT:

58

SOURCE CODE:
#include<regx51.h> #include<intrins.h> sbit SDA=P2^1; sbit SCL=P2^0; unsigned char i; unsigned char EData; void initserial(void); void Delayms(unsigned int count); void writebyte(unsigned int addr, unsigned char Data); unsigned char readbyte(unsigned int addr); unsigned char readi2c(void); void writei2c(unsigned char Data); void stop(void); void start(void); void main(void) { initserial(); writebyte(0x0050,0x30); Delayms(5); readbyte(0x0050); EData=readbyte(0x0050); writebyte(0x0080,EData); Delayms(5); while(1); } void initserial(void) { SCON=0X52; TMOD=0X20; TH1=0XFD; TR1=1; } void writebyte(unsigned int addr, unsigned char Data) { start(); writei2c(0xa0); writei2c((unsigned char)(addr>>8)&0xff); writei2c((unsigned char)addr&0xff); writei2c(Data); stop(); } void start(void) { SDA=1; SCL=1;

59

60

_nop_(); _nop_(); SDA=0; _nop_(); _nop_(); SCL=0; _nop_(); _nop_(); } void stop(void) { SDA=0; _nop_(); _nop_(); SCL=1; _nop_(); _nop_(); SDA=1; _nop_(); _nop_(); } void writei2c(unsigned char Data) { for(i=0;i<8;i++) { SDA=(Data&0x80)?1:0; SCL=1; SCL=0; Data<<=1; } SCL=1; _nop_(); _nop_(); SCL=0; } void Delayms(unsigned int count) { unsigned int i; while(count) { i=109; while(i>0) i--; count--; } }

61

62

unsigned char readbyte(unsigned int addr) { unsigned char Data; start(); writei2c(0xa0); writei2c((unsigned char)(addr>>8)&0xff); writei2c((unsigned char)addr&0xff); start(); writei2c(0xa1); Data=readi2c(); stop(); return(Data); } unsigned char readi2c(void) { unsigned char Data=0; SDA=1; for(i=0;i<8;i++) { SCL=1; Data<<=1; Data=(Data|SDA); SCL=0; _nop_(); } SDA=0; _nop_(); _nop_(); SCL=1; _nop_(); _nop_(); SCL=0; return(Data); }

RESULT:
Thus the source code for I2C program was developed using keil vision and implemented using proteus tool.

63

64

Ex.no:5 08.10.2013

KEYBOARD INTERFACING

AIM:
To develop a source code for keyboard interfacing using keil vision and to implement using proteus.

APPARATUS REQUIRED:
S.No 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. COMPONENTS Keil Software Proteus Software Microcontroller Crystal Oscillator Resistor Capacitor Capacitor IC LCD Keyboard CONFIGURATION QUANTITY

AT89C51 12MHz 10Kohm 33Pf 4.7F MM74C922 LM016L KEYPAD-PHONE

1 No. 1 No. 1 No. 2 No. 1 No. 1 No. 1 No. 1 No.

THEORY:
The MM74C922 CMOS key encoders provide all the necessary logic to fully encode an array of SPST switches. The keyboard scan can be implemented by either an external clock or external capacitor. These encoders also have on-chip pull-up devices which permit switches with up to 50 k on resistance to be used. No diodes in the switch array are needed to eliminate ghost switches. The internal debounce circuit needs only a single external capacitor and can be defeated by omitting the capacitor. A Data Available output goes to a high level when a valid keyboard entry has been made. The Data Available output returns to a low level when the entered key is released, even if another key is depressed. The Data Available will return high to indicate acceptance of the new key after a normal debounce period; this two-key roll-over is provided between any two switches. An internal register remembers the last key pressed even after the key is released. The 3-STATE outputs provide for easy expansion and bus operation.

SOURCE CODE:
#include<regx51.h> void l_data(unsigned char); void l_command(unsigned char);

65

PROTEUS OUTPUT:

66

void delay(int); void lcddisp(long int); sfr ldata=0xa0; sfr keyin=0x90; sbit OE=P1^4; sbit rs=P3^0; sbit rw=P3^1; sbit e=P3^2; int i,j,k,s,count,sec=0; long int tempdata='x'; unsigned char str1[12]="147*2580369#"; void main() { IE=0x84; IT1=1; OE=0; l_command(0x38); delay(100); l_command(0x0e); delay(100); l_command(0x01); delay(100); l_command(0x06); delay(100); l_command(0x80); delay(100); while(1); } void l_data(unsigned char tempdata1) { ldata=tempdata1; rs=1; rw=0; e=1; delay(10); e=0; } void l_command(unsigned char tempdata2) { ldata=tempdata2; rs=0; rw=0; e=1; delay(100); e=0; }

67

68

void delay(int n) { for(i=0;i<n;i++) for(j=0;j<n;j++); } void lcddisp(long int q) { if(q=='*') l_command(0x01); l_data(q); } void switch1() interrupt 2 { lcddisp(str1[0x0f & keyin]); }

RESULT:
Thus the source code for keyboard interfacing was developed using keil vision and implemented using proteus tool.

69

70

Das könnte Ihnen auch gefallen