P. 1
Micro Controller Lab Manual (1) (1)

Micro Controller Lab Manual (1) (1)

|Views: 4,966|Likes:
Published by Sameer Sadiq

More info:

Published by: Sameer Sadiq on May 28, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less










Exp No. 1- Familiarity and use of 8051 Micro controller Trainer. Exp No. 2- Instruction set for simple programs for data transfer, & 3 manipulation, arithmetic operations, branching operations, logical operations and testing condition of bit in a byte. Exp No. 4- Code conversion programs. Exp No. 5- Timer and counter programming using 8051 Exp No. 6- Serial mode operation of 8051 Exp No. 7- Interfacing DAC module using 8051 Exp No. 8- Interfacing Traffic signal control using 8051 Exp No. 9- Interfacing 7-segment display using 8051 Exp No.10-Interfacing Stepper motor control using 8051 Exp No.11-Familiarity with MCBX51 board and writing programs for MCBX51. Program for Blinking of LEDs. Exp No.12-Real time clock using 8051.


Experiment No.1: Familiarity and use of 8051 (ESA-31) Micro controller kit trainer. Experiment No.2: Simple programs in 8051 Assembly code and their execution. Program 1: Addition of two 16 bit numbers using registers. Program 2: Copying of byte data in RAM memory locations using a) Direct addressing b) Register indirect addressing c) Using loop structure. Program 3: Sum of a series of byte elements Program 4: Copying a data block from source to destination. Program 5: Count number of 1’s in a byte. Program 6: Multiplication of two unsigned 8-bit binary numbers. Program 7: Division of two unsigned 8-bit binary numbers. Program 8: Searching of a byte element in a data block. Experiment No.3: Arithmetic, Logical & Branching operations. Program 9: Multi byte binary addition Program 10: Multi byte BCD addition

Program 17: BCD to Binary conversion. Experiment No. Program 14: Checking a character string for a palindrome. 4: Code conversion Programs. Experiment No. Experiment No. 6: Communication with host computer system. 4 . Experiment No. 8: Interfacing of traffic signal control using 8051 and its programming. 9: Interfacing of 7-segment display using 8051 and its programming. 5: Timer Programming using 8051 Experiment No. Program 16: Packed BCD to ASCII conversion.Program 11: Multi byte binary subtraction Program 12: Testing condition of a bit in a byte of data. Program 13: Finding largest element in a block of data array. Experiment No. 7: Interfacing of DAC using 8051 and its programming. Program 15: ASCII to Packed BCD conversion.

11: Introduction to KEIL Software and MCBX51 kit. 10: Program to control Stepper motor using 8051 . 12: Blinky : LED flasher program. 5 . Experiment No. Experiment No.Experiment No. 13: Interfacing elevator simulator control using 8051. Experiment No.

Standard bus compatible signals available on the bus connector for easy expansion. editing. The monitor of the trainer occupies 32KB out of 64KB of program memory. 1 Familiarity with ESA 31 micro controller kit: Main features of ESA 31 (8031 based): ESA 31 can be operated either from on board keyboard or from a CRT terminal through its RS 232-C interface. Keyboard and serial monitor programs support the entry of users program. 6 . debug facilities like breakpoints & single stepping.0592 MHz Memory follows. 1-pass Dis assembler dis assembles the object code into standard INTEL mnemonics. : Four 28-pin JEDEC sockets offer 120KB of memory as 32KB of firmware in one 27256 (Program memory) 32KB of SRAM using one 62256 (User program memory) 56KB of SRAM as data memory using two 62256s. Total of 120KB memory is provided of which 64KB of memory is program memory and 56KB of memory is data memory. SPECIFICATIONS: Microcontroller: 8031/8051 operated at 11.EXPERIMENT NO. & full execution of user programs. 1-pass Assembler can assemble any memory resident assembly language program.

The RESET key causes a hardware reset and restarts the monitor.The memory map is as follows: DEVICE 27256 62256 62256 62256 ADDRESS RANGE 0000-7FFF 8000-FFFF 0000-7FFF 8000-DFFF TYPE OF MEMORY Program memory User program memory User data memory User data memory. separated into three fields. Last two digits form the data field. The monitor displays the sign-on message – ESA 51 across the address & data fields of the display. KEYBOARD & DISPLAY The display consists of 7 seven segment LED displays. The leftmost single digit forms the special field. The dip switch settings for either mode of operation are as follows: For Hexadecimal keypad mode: All switches in OFF position. the user enters the commands and data by pressing the appropriate keys on the keypad. Note: address can be 64KB or 256B max. For Serial mode : Switches 1 and 4 in ON position. 7 . KEYBOARD MONITOR In the keyboard mode. Next four digits form the address field. Responses are displayed by the system on the seven-digit 7-segment LED display.

enter the type of memory by pressing PRGMEM. MONITOR COMMANDS The keyboard monitor is capable of executing fifteen individual commands.] EXEC After pressing EXAM MEM key. A). (Memory address are evaluated modulo 64K if it is program memory or data memory and modulo 256 if it is internal data memory or bit memory). EXTDATA.  EXAMINE/MODIFY MEMORY Displays/modifies the contents of a memory location. D). Enter the memory address of the byte to be examined. A dot appears at the last digit of the address field indicating that an address entry is required. Memory Group – 4 keys (PRGMEM. BITMEM. or INTDATA key. INTDATA) to select the type of memory. Command Group – 13 command keys. System Operation keys – RESET. The value is displayed in the address field of the display. BREAK. and EXEC keys BREAK can be used to stop the execution without affecting the register contents. Hex pad – 16 keys representing hex digits 0 through F.  EXAMINE/MODIFY REGISTER 8 . B). Syntax Format: EXAM MEM {PRG MEM/EXT DATA/BIT MEM/INT DATA} Addr1 NEXT [[[data] NEXT/PREV]….The 36 key keypad consists of the following group of keys. EXTDATA. C). BITMEM.

If BREAK key is pressed. In any case. It displays U on the special field of 7-segment display. contents of the user portion of the RAM area are not altered by the monitor. and enable them b) Press ‘BREAK’ key. The displayed registers contents of R0-R7 is w. EXAM REG [reg key] [[Data] NEXT/PREV]….This command is used to examine and optionally modify the contents of some of the 8031/8051’s registers. Note: When any of the registers R0-R7 has to be examined. Now press keys 0-7 on the hex keypad.r.] EXEC.t the current bank selected. 9 . press EXAMREG key and then BITMEM key. By doing so all registers information about user program is lost. GO [Starting addr] EXEC To abort execution of user program press RESET key. which corresponds to registers R0-R7. There are two ways to break the user program execution.  GO COMMAND: Is used to transfer control of the system from the monitor to the user’s program. control returns to the monitor which saves all the registers and displays the address where the program broke and the data at that address on the display. a) Set breakpoints at specific addresses.

#3CH ADDC A.<NXT>EXEC Note: After executing the program using GO<8000>EXEC press BREAK key. Press EXAMREG key twice to check result in regs R6 and R7 respectively.. Program Examples: 1. 10 . R6 has the lower byte. #0E7H ADD A. Address 8000 8001 8003 8005 8006 8008 800A 800B OBJECT Code C3 74 E7 24 8D FE 74 3C 34 3B FF 80 FE Mnemonic CLR C MOV A. #3BH MOV R7. <EXAMMEM><PRGMEM> 8000 <NXT> DATA <NXT>…. Write a program in 8051 to add two 16-bit numbers.EXPERIMENT NO – 2 & 3 Execution of simple programs using ESA-31 in keyboard mode. A MOV A. The numbers are 3CE7H and 3B8DH. #8DH MOV R6. A HERE:SJMP HERE (Relative address = Target address – PC contents ) Enter the codes using the format given below. Place the sum in registers R7 and R6.

3.#55h MOV 40h. Six bytes of data are stored in memory locations starting at 50H. (50) = 10h. Write an 8051 program to copy the value 55H into RAM memory locations 40H to 44H using A) Direct addressing mode B) Register addressing mode without using Loop and C) With a Loop. Store the sum at memory locations 60H&61H.A MOV 43h.Format: <EXAMREG><EXAMREG><BITMEM>6<NEXT><NEXT> 2. Add all the bytes.A MOV 42h. Use reg R7 to save any carries gtenerated.A MOV 41h.copy A to RAM Location 11 . (54) = 60H. (52) = 2AH. (55) = 3FH 2) A)Using direct addressing mode MOV A. (53) = 4FH. (51) = 25H.A MOV 44h.A HERE : SJMP HERE .

#05h .#55h MOV R0. MOV A.A HERE :SJMP HERE 2) C) With Loop.A INC R0 DJNZ R2.A INC R0 MOV @R0.#55h MOV R0.2.B) Using reg-indirect addressing mode without loop MOV A.A INC R0 MOV @R0.A INC R0 MOV @R0.A INC R0 MOV @R0.AGAIN HERE :SJMP HERE 12 .Counter AGAIN : MOV @R0.#40h MOV @R0.#40h MOV R2.

<EXEC> <EXM MEM> <INTDATA> 60 <NXT>00XT>00<EXEC> Run the Program <GO><8000> <EXEC> Reset Check Results <EXM MEM> <INT DATA> 60 <NXT>…. initial sum=0 . store MSBy of sum 1) Format: for entering. A MOV 61h. <EXEC> Feed Sample Data <EXM MEM> <INTDATA> 50 <NXT> DATA <NXT> DATA……. Enter source code <EXM MEM> <PRG MEM> 8000 <NXT> DATA <NXT>……. @R0 JNC NEXT INC R7 NEXT : INC R0 DJNZ R2. (53)=4Fh. AGAIN MOV 60h. #06h CLR A MOV R7. clear R7 to save carry . (54)=60h. executing & Checking results. 13 . R7 HERE : SJMP HERE . (51)=25h..3) Sample data: (50) =10h. #50h MOV R2. store LSBy of sum . (55)=3Fh Result = (60)=4Dh (61)=01h (MS byte) 014Dh Source Code MOV R0. Keep track of carries . Counter . A AGAIN: ADD A. (52)=2AH.

Write an 8051 program to copy a block of 10 bytes of data from RAM locations starting at 35h to RAM locations starting at 60h. #08h LOOP: RLC A JNC CONT INC R2 CONT: DJNZ R1. #AAh MOV A. A INC R0 INC R1 DJNZ R3. #35h MOV R1. #00h MOV R1.4. Sample Prob Source block (35)=10h. destination pointer . Write a 8051 Program to find the Number of 1’s in a byte stored in RO and Store the number of 1’s in register R2. (3D) = 90h. 5. BACK HERE: SJMP HERE. (36) =20h. . Let R0 = AAh MOV R0. (38) = 40h. #60h MOV R3. (3E) =A0h MOV R0. (39) = 50h. #0Ah BACK: MOV A. (3B) = 70h. counter A byte is stored in register R0. (3A) = 60h. (3C) = 80h. Source pointer . R0 MOV R2. LOOP HERE: SJMP HERE 10101010 14 .@R0 MOV @R1. (37) = 30h.

Use instruction DIV AB in place of MUL AB. After division operation. A INC DPTR MOV A.e. Division of two unsigned 8-bit binary numbers.6.Store the quotient and remainder in 8060h & 8061h of data memory respectively.@DPTR MUL AB MOV DPTR. The numbers are stored in memory locations 8050h and 8051h. multiplicand in A reg 7. #8050h MOVX A. Write a 8051 program to multiply two unsigned 8-bit binary Numbers. Sample data: (8050)= 41h (65)10 (8051)= 08h (8060)= 08h (8061)= 02h i. Store the result in 8060h and 8061h. Divide the number in 8050h by the number in 8051h.@DPTR MOV 0F0h. A MOV DPTR. 0F0h MOVX @DPTR. quotient is in A reg & remainder is in B reg. 15 . 65X8 = (520)10 = 0208h MOV DPTR. multiplier in B reg . Store initial divisor in B reg and dividend in A reg. #8051H MOVX A. Sample data: (8050) =41h dividend (8051)=08h divisor Result : (8060) =08h quotient (8061)=01h reminder Hint: Similar to multiplication program. #8060h MOVX @DPTR. A HERE: SJMP HERE .

8. Result = (R0) =00h MOV R1. #64H. (53) =25h. #00h HERE1: SJMP HERE1 CONT: INC R1 DJNZ R2. LOOP MOV R0. If present store 00h in R0. (52) =64h. 16 . #50h MOV R2. (51) =45h. #05h LOOP: CJNE @R1.otherwise store FFh in R0. Write a 8051 program to find the number 64h from the set of five Readings starting from address location 50H to 54h. CONT MOV R0. (54) =22h. #FFh HERE2: SJMP HERE2 Sample prob (2) Replace data in (52) by 94h Result = (R0) =FFh. Sample Problem (1): i) (50) =76h.

(23) =46H (30) =42H.@R1 MOV @R1. A INC R0 INC R1 DJNZ R3. Sample Proof: . (22) =27H.Program No 9: Multi byte Binary Addition.@R0 ADDC A. (32) =DAH. Count=4 CLR C CLR A AGAIN: MOV A. Source Code Listing MOV R0. (32) =B3H. #04H. #20H MOV R1. #30H MOV R3. / 17 . (31) =56H.The two binary strings starts (LSB first) in RAM memory 20H and 30H respectively and save the result in RAM Memory locations starting at 30H replacing the second binary string. (21) =34H. Write a Program to add 4627342AH to 32B35642H. (33) =32H Result= (30) =6CH. (33) =78H.4627342A H +32B35642 H 78DA8A6CH Sample data. (20) =2AH. (31) =8AH. AGAIN HERE: SJMP HERE.

Program N0 10: Multi byte BCD Addition. The two BCD Strings starts (LSB first) from RAM Locations 20H & 30H respectively.@R1 DAA MOV @R1. #30H MOV R3.@R0 ADDC A. Write a Program to add 4 byte packed BCD 46273420H to 32105644H and save the BCD result in RAM memory locations starting at 30H. 18 . #20H MOV R1. 46273420 +32105644 78379064 Source code listing MOV R0. AGAIN HERE: SJMP HERE. #04H. COUNT=4 CLR C CLR A AGAIN: MOV A. A INC R0 INC R1 DJNZ R3.

#04H CLR C CLR A AGAIN: MOV A.14DF35B8H 1A7C720BH Source code listing MOV R0. A INC R0 INC R1 DJNZ R3. #20H MOV R1. and save the result in RAM memory location Starting at 30H.@R0 SUBB A.Program No 11: Multi byte Binary Subtraction Write a Program to subtract 14DF35B8H from 2F5BA7C3H.@R1 MOV @R1. AGAIN HERE: SJMP HERE. COUNT = 4 19 . #30H MOV R3.The two binary strings starts(LSB first)from RAM location 20H & 30H respectively 2F5BA7C3H . .

#’Y’ NEXT: NOP END 20 . move into B the character pointed by R1 . #50H MOV R1. ‘RADAR’. NEXT INC R0 DEC R1 DJNZ R2. Write a program to check if the character string of length 7. take half the string length as counter value . repeat until all characters are compared . #56H Back: MOV A. Solution: A Palindrome is a string in which the characters are the same whether the string is read in the forward or backward direction. @R0 MOV B. @R1 CJNE A. increment the forward counter . B.compare it with the character pointed by R1 . BACK MOV P1. take R1 as pointer for the backward reading Of the string . if not equal. do nothing since it is not a Palindrome . MOV R2. take R0 as pointer to the forward reading . decrement the backward counter . stored in RAM locations 50H onwards is a Palindrome. output ‘Y’ to P1.Program No 12: Checking a character string for a Palindrome. #03 MOV R0. since the string is a Palindrome output ‘Y’ . move into A the character pointed by R0 . Example. If it is. ‘MADAM’.

(30) =34H ‘4’ (31)=37H ‘7’ Result= (40) =47H (packed BCD) Source code listing MOV R0. A=47H. Sample data:.EXPERIMENT -4 CODE CONVERSION 2) ASCII to Packed BCD Conversion Write a program to convert two ASCII decimal digits available in RAM locations 30H and 31H into packed BCD number and store the result in RAM location 40H. #30H MOV R1. 21 .@R0 ANL A. #40H MOV A. A . packed BCD . mask upper nibble (A=04H) : A=40H MOV @ R1. R2 . #0FH. store packed BCD HERE: SJMP HERE.@R0 ANL R2. mask upper nibble (R2=07H) ORL A. #0FH SWAP A INC R0 MOV 02H.

mask upper nibble . 07 HERE: SJMP HERE . 06 INC R0 MOV @R0. #40H ANL A. #0FH ORL A.A=32H .A=39H . #30 MOV R6. A MOV R0. copy of BCD data in R2 .save ASCII .make it an ASCII.point to result location .write a program to convert packed BCD to two ASCII numbers and place them in RAM memory location 40H and 41H respectively.mask lower nibble . R2 ANL A. in memory locations 22 .in memory locations .get the packed BCD again . A MOV A.save it . #30H MOV R7.2) Packed BCD to ASCII Conversion PROGRAM: Assume that register A has Packed BCD .store ASCII character . #0F0H SWAP A ORL A. #29H MOV R2. A MOV @R0. Source code listing MOV A.A=29H.packed BCD .

A MOV A. @R0 MOV R2.get packed BCD in A reg . Multiply BCD2 by 10 3. . #40H MOV R1. A HERE : SJMP HERE. R2 ANL A.mask the lower nibble .store binary equivalent .BCD2 in A reg .save it in R2 reg . #50H MOV A. #0F0H SWAP A MOV 0F0H. #0AH MUL AB ADD A. #0FH MOV R3. Split the packed BCD into unpacked BCD digit BCD1 & BCD2 01101001  BCD1 00001001 BCD2 00000110 2.add to BCD1` . Add BCD1 to the answer in step2 Source code listing MOV R0. R3 MOV @R1. 1.BCD1 IN R3 .get packed BCD again .Reg B loaded with 10 decimal .mask the upper nibble .3) BCD to binary Conversion PROGRAM Sample example (40) = 6910 (packed BCD) Result= (50) = 45H (Binary equivalent) Steps. A ANL A.

Note: Observe the output waveform across Pin 6 & 20 on CRO. #1AH MOV TH1. LO . complement P1. #0FFH SETB TR1 BACK: JNB TF1. TR1 = 8EH.EXPERIMENT NO. Delay time = T/2 = 250µs. Stop timer .5 to get HI. BACK CLR TR1 CPL P1. TH1 = 8DH. 6) GND (Pin 20) Steps: T = 1/f = 1/2 KHz = 500µs. TF1 = 8FH. mode1 Note: SFR address of TMOD = 89H. P1. 5 TIMER PROGRAMMING USING 8051 Task: Assuming XTAL = 11. timer1.5 = 95H.0592MHz. write a program for timer 1 in mode 1 to generate a square wave of 2KHz frequency on Pin P1. Stay until timer rolls over .5 CLR TF1 SJMP AGAIN . Start timer 1 . 65536 – 230 = (65306)10 Initial count value = FF1A h TL1 = 1AH TH1 = FFH PROGRAM: MOV TMOD. TL1 = 8BH. reload timer . clear timer flag .5 (Pin No. 250µs/1. . and note down time period. #10H AGAIN: MOV TL1.085µs = 230 clocks.

and note down time period.085µs = 230 clocks. #20h.5 (Pin 6) in mode 2 configuration (auto reload mode) GND (Pin 20) XTAL = 11. PROGRAM: MOV TMOD.5 CLR TF1 SJMP BACK. Delay time = T/2 = 250µs. 250µs/1.Write a program using timer 1 to generate a square wave of 2KHz frequency on Pin P1. 256 – 230 = (26)10 = 1A H Load TH1 with initial count value of 1AH. . BACK CPL P1. timer1. Note: Observe the output waveform across Pin 6 & 20 on CRO.0592 MHz T = 1/f = 500µs. #1Ah SETB TR1 BACK: JNB TF1. mode 2 is auto reload. mode2 MOV TH1.

It is a powerful cross assembler for 8051. ESA 31 is supplied with DOS communication driver package XT51 which allow the user to establish serial communication between the trainer and a host PC thro its Asynchronous com ports (COMI and COM2). INSTALLATION a) Configure ESA 86/88E for serial mode of operation and set the serial port of ESA 86/88E for 9600 Baud rate and No parity(keep DIP switches 1 and 4 in ON position) b) Connect the PC to ESA 31 trainer over COM1/COM2 serial port using the RS232C serial interface cable connecter.6 Communication with a Host Computer System ESA 31 operating in the serial mode. Using of X8051 Cross Assembler A convenient way of creating a file to be downloaded in to ESA31 is to use a cross assembler for 8051 that can generate the object code in extended HEX format. pseudo opcodes (directives) and addressing modes of 8051. can be connected to either a CRT terminal or a host computer system. X8051 is such a package. It can run on any PC/XT/AT compatible system and supports all the standard mnemonics.Experiment No. The Serial mode of operation a) Supports for downloading user programs in to the target ESA 31 kit from a Host computer system in INTEL HEX format. Steps involved in creating a HEX file are as follows:Step1:Select the path folder directory C:\> cd C:\> cd51 C:\> edit filename . When a computer system is the controlling element. it must be executing driver software to communicate with the ESA 31 target kit. b) Also supports for uploading user program to host PC and saving them as HEX files o a system.

asm Output Filename : add16.asm Output Filename: 8051 CROSS ASSEMBLER-VERSION 4.asm.#8Dh Mov r6.a Mov a.Step2:Create a source file using the DOS text editor and save it as filename.#3bh Mov r7. Let the source file be saved as add 16.asm Step3:Assemble the source file add16.obj as follows C:\51 x8051 Listing destination <N.asm using X8051 to create an object file add16.E. The numbers are 3CEH and 3B8DH. Org 8000h CLR C Mov a .D.L.P<CR>=N>:d Generate cross reference?<Y/N <CR>=N>:n Input Filename : add16.#3ch Addc a.00f Input Filename : add16. R6 should have the lower byte. Example: Write a source program for 16 bit addition using DOS text editor. Place the sum in R7 and R6.T.obj Lines Assembled:________ Assembly Errors:_______ C:\51 .#0E7h Add a.a Here :sjmp here Save and exit from editor.

T. C:\51 link51 Linker copyright<c>1985-version 4.Step4:Link the single file add16.hex that can download into ESA 31 kit.2.E.H.A.3.obj Enter Offset For ‘CODE’ Input Filename: Output Filename: : 0 Options(D.X.00g Input Filename:add16. This process creates a hex file add16.obj Specify code offset and options H for HEX format.1.(CR)=Default):h Link Errors:________ C:\51 Step5:-(Optional) Check the directory to see the files Created for add 16 C:\51 dir Also check the list file for add16 as C:\51 edit add16.S.list Step6:Set the system in the serial communication mode using the XT51 command Output Format:_______ .M.

’ Appears on the screen otherwise the communication parameters are set appropriately using ALT+S command and continue. ESA 31 MONITOR VERSION x. Subsequently during the POWER ON RESET.hex Specify memory type Specify starting address Specify ending address :P : 8000 : Downloading program Run the program using G command as G 8000 Press Break Key .y Step7:Download the program hex file from host PC to ESA 51 trainer using the CTRL+D command CTRL+D Specify download filename Add16. y_____________________ ELECTRO SYSTEM ASSOCIATES PVT LTD BANGALORE Press any Key to Continue _____________________________________________________________ XT51 Checks for the presence of communication ports COM1 and COM2 If Serial communication is established successfully the command prompt ‘. the following sign on message appears on the screen followed by command prompt.C:\86>xt51 Now the following message will appears on the Screen __________________XT51 Version x.

>MD88220 88220 XX<CR> 88221 XX<CR> 88222 XX 55<CR> > 88220 XX<ESC> EX 2: To enter data at int RAM locations starting at 40H. Press ESC key to return to command Prompt. address1. their contents can be altered if desired. This command is used to display the contents of the Program or External or Internal Memory. >MI 40<CR> 40 XX 21<CR> 41 XX 22<CR> 43 XX 55<CR> >44 XX<ESC> (2) M (Display Memory) Command. if the locations are in RAM. >Md8020.address2<CR> EX: To display the Contents of 5 Bytes from location 8020H. 8024<CR>.M {P|D|I|B} addresses 1[address 2] <cr> Ex 1: Examine a series of RAM locations starting at 8820H and modify the contents of the location 8822H. Format: . > Use the M (Modify memory) command to examine the contents of specified memory locations. Foramt: M {P|D|I}. Further. .Note: If input data is to be entered use >md commands to enter the data.

2. Output data on the appropriate port and observe output wave form at Xout and Yout of the DAC using CRO. initialize 8255A for mode 0 operation with port A and port B as output. ESA 31 Microcontroller trainer kit 2. PROGRAMS: 1. 26 Pin connector cable 5. CRO DESCRIPTION: To use DAC. Power supply units 4. Down going stair case with 5 steps. ORG PORT_A PORT_B PORT_C 8000H EQU E800H EQU E801H EQU E802H . 3. Up going stair case with 5 steps. Write an ALP to generate Symmetrical Square wave.6 Generation of Waveforms using DAC interface module AIM: To write and execute program in 8051 assembly language for interfacing a DAC interface module with ESA 31 microcontroller trainer kit. The 16 bit port addresses for 8255A available at J2 connector are: Port A Equ E800H Port B Equ E801H Port C Equ E802H Port D Equ E803H Note: Port A controls Xout and Port B controls Yout of DAC interface module. Dual channel DAC module 3. Program 7.MICROCONTROLLER LAB EXPERIMENT NO. Assume the DAC interface is connected over J2 of the ESA 31 trainer. B). Write an ALP to generate A).1 . APPARATUS: 1. 4. Write an ALP to generate Saw tooth (Up-going and down-going) Write an ALP to generate Triangular waveform.

#0E800H @DPTR.#00H.Point to Port A @DPTR.A . MOV MOV MOVX CLR AGAIN: MOV MOVX INC MOVX INC SJMP DPTR.#80H @DPTR. .A DPTR @DPTR.A DPTR @DPTR.increment DAC input AGAIN .A A A.Out to Port A and DPTR @DPTR. Program to generate continuous down going Sawtooth MOV MOV MOVX MOV AGAIN: MOV MOVX INC MOVX DEC SJMP DPTR.A DPTR @DPTR.#0E800H @DPTR.A .initialize 8255A for mode 0 with PA&PB as OUT A .#0FFH DPTR.A A AGAIN .A A DPTR. Program to generate continuous triangular waveform MOV MOV MOVX CLR UP: MOV MOVX INC MOVX INC CJNE DOWN :MOV MOVX INC MOVX DEC CJNE DPTR.#0E803H A.#0E803H A.A A A. Program to generate Continuous up going saw tooth.Start with value 00H DPTR.DOWN .A A.#0E803H A.Repeat forever.Out to Port B A .CWR EQU E803H .#80H @DPTR. #0E800H.#80H @DPTR.#0E800H @DPTR.#0FFH.UP DPTR.A .

A R0.DLY1 A.#0FFH R0.#0FFH DPTR.#80H @DPTR.#0E803H A.#0FFH.#0FFH R0.#33H DPTR. Program for Stair case (down-going) with 5 steps MOV MOV MOVX MOV MOV RPT: MOVX MOV DLY1: DJNZ AGAIN:CLR DPTR.A R0.DLY1 A.DLY2 RPT .DLY1 C .#0FFH R0.#00H A.#00H @DPTR.#80H @DPTR.#0E800H @DPTR. Program for Stair case (Up-going) with 5 steps. MOV MOV MOVX MOV RPT: ADD MOV MOVX MOV DLY1: DJNZ CJNE INC MOVX MOV DLY2: DJNZ SJMP DPTR.#0E800H @DPTR.A R0.#80H @DPTR.#0E803H A.DLY2 BACK .A A.A A.A R0.A A. Program to generate Symmetrical Square Wave MOV MOV MOVX BACK:MOV MOV MOVX MOV DLY1:DJNZ MOV MOVX MOV DLY2:DJNZ SJMP DPTR.#0FFH DPTR.#0E803H A.#0E800H @DPTR.SJMP UP .#0FFH R0.#0FFH R0.RPT A @DPTR.A R0.


The last LED marked DL is a set of two dual color LED s and they both will be either RED or GREEN depending on the state of the corresponding port line RED if the port line is logic HIGH and GREEN if the port line is logic LOW. The interface provides a set of 6 LED indicators at each of the four corners. DESCRIPTION OF THE CIRCUIT : The organization of 6 LED s is identical at each of the four corners. if it is at logic ‘LOW’.8 Interfacing of Traffic Light Controller Using 8051 The traffic light interface simulates the control and operation of traffic lights at a junction of four roads. The organization with reference to the LED s at “South-West” corner is shown in figure. if the Port line is Logic ‘HIGH’ and LED is OFF. 24 LEDS AND CORRESPONDING PORT LINES: PORT A: D7 D6 D5 D4 D3 D2 D1 D0 _____________________________________________ ER PORT B: EA ERg EL SR SA SRg SL . Thus the interface allows the user to simulate a variety of traffic simulations using appropriate software routines.1 R = SOUTH RED A = SOUTH AMBER L = SOUTH LEFT S= SOUTH STRAIGHT Rg=SOUTH RIGHT DL=SOUTH PEDESTRIAN The five LED s (except “Pedestrian”) will be ON or OFF depending on the state of corresponding port line LED is ON. Each of these LED s can be controlled by a port line.EXPERIMENT NO.

Vehicles from EAST can go WEST and SOUTH Vehicles from WEST can go EAST Vehicles from SOUTH can go WEST Pedestrians can cross on NORTH 3. and PC such that the following traffic situations are simulated. Each port line is inverted and buffered using 7406 (open collector inverter buffers) and is used to control an LED. Vehicles from EAST can go SOUTH Vehicles from NORTH can go SOUTH and EAST Vehicles from SOUTH can go NORTH Pedestrians can cross on WEST 4. Dual color LEDs are controlled by a port line and its complement. INSTALLATION: The interface module has 26 pin connector at one edge of the card. The trainer can be in KEYBOARD MODE or SERIAL MODE.D7 D6 D5 D4 D3 D2 D1 D0 _____________________________________________ WR PORT C: D7 D6 D5 D4 D3 D2 D1 D0 ____________________________________________ EP SP WP NP SS ES NS WS WA WRg WL NR NA NRg NL There are four such sets of LED s and these are controlled by 24 port lines of 8255A. This is used for connecting the interface over J2 of the ESA 31 trainer. Vehicles from SOUTH can go NORTH and WEST Vehicles from WEST can go NORTH Vehicles from NORTH can go SOUTH Pedestrians can cross on EAST 2. Vehicles from EAST can go WEST . 1. PROBLEM STATEMENT: Generate the sequence for PA. PB.

. . .#0E803H A. No vehicle movement Pedestrians can cross on all four roads.#PORTS A.Port C value.A DPTR.A DPH .@DPTR DPL DPH DPTR. The state transition is indicated by turning ON all the AMBER LEDs and all Pedestrians RED LEDs for a fixed duration.0E801H @DPTR. . The system moves from one state to another state after fixed time delay.A DPH DPL DPTR A.@DPTR DPL DPH DPTR. The sequence of the above states is repeated again and again.#80H @DPTR.@DPTR DPL DPH DPTR.Vehicles from WEST can go EAST and NORTH Vehicles from NORTH can go EAST Pedestrians can cross on SOUTH 5. Program memory from 8000H to 804FH ORG PORTA PORTB PORTC CWR MOV MOV MOVX AGAIN: MOV NEXTST: MOVX PUSH PUSH MOV MOVX POP POP INC MOVX PUSH PUSH MOV MOVX POP POP INC MOVX PUSH PUSH MOV MOVX POP EQU EQU EQEU EQU 8000H E800H E801H E802H E803H DPTR.Port B value.#0E802H @DPTR.#0E800H @DPTR.Port A value.A DPH DPL DPTR A.

0B5H 44H.All Ambers ON . #0FFH R3 R3. 81H.LOOP1 R4 R4.#00.DPL A. 11H. 44H. 10H. PORTS: DB DB DB DB DB DB DB DB DB DB DB 10H.LOOP3 .State 2 . 88H. 44H. 0DAH 44H.State 5 . 00H 44H.#1EH. 0F0H 88H.state 1 . 44H.#00.Delay routine . 0E5H 44H. 0F0H 81H.POP INC LCALL MOV CJNE SJMP DELAY: MOV LOOP3: MOV LOOP2: MOV LOOP1: DEC CJNE DEC CJNE DEC CJNE RET DPL DPTR DELAY A. 7AH 44H.State 4 .#00. 44H. Enter the data mentioned below from 0000H to 001EH in data memory. 08H. 0F0 00H .LOOP2 R2 R2. 44H.Dummy . 0F0H 11H.#0FFH R3.NEXTST AGAIN R2.State 3 . 0F0H 08H.Provide delay .All Ambers ON .#06 R4.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->