Microcontroller and Applications

Similar documents
MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller Subject Code:

8051 Overview and Instruction Set

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

Microcontroller Intel [Instruction Set]

WINTER 14 EXAMINATION

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

MODEL ANSWER WINTER 17 EXAMINATION Subject Title: Microcontroller and applications

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Module Contents of the Module Hours COs

MODEL ANSWER SUMMER 17 EXAMINATION Subject Title: Microcontroller and Applications Subject Code:

Embedded Controller Programming

MODEL ANSWER SUBJECT- MICROCONTROLLER(12187) CLASS-EJ5E CLASS TEST-02 Q1.)Attempt any THREE of the following.

8051 Microcontroller

8051 Microcontrollers

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

SUMMER 13 EXAMINATION

8051 Microcontroller

Vidyalankar T.E. Sem. V [ETRX] Microprocessors and Microcontrollers I Prelim Question Paper Solution

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

Digital Blocks Semiconductor IP


EE6502- MICROPROCESSOR AND MICROCONTROLLER

Question Bank Microprocessor and Microcontroller

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

Microcontroller and Embedded Systems:

Programming of 8085 microprocessor and 8051 micro controller Study material

Digital Blocks Semiconductor IP

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

Principle and Interface Techniques of Microcontroller

Department of Electronics and Instrumentation Engineering Question Bank

8051 microcontrollers

WINTER 14 EXAMINATION Subject Code: Model Answer Page No: 1/ 26

Timer-1 can be run using the internal clock, fosc/12 (timer mode) or from any external source via pin T1 (P3.5) (Counter mode).

Digital Blocks Semiconductor IP

Q.1. A) Attempt any THREE of the following:

CS 320. Computer Architecture Core Architecture

2. Write an 8051 program to generate a square wave of 25 khz at pin P2.3 using XTAL = 12 MHz. Solution:

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Summer 2016 EXAMINATIONS.

Module I. Microcontroller can be classified on the basis of their bits processed like 8bit MC, 16bit MC.

MODULE-1. Short Answer Questions

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) SUMMER 14 EXAMINATION Model Answer

TUTORIAL Assembly Language programming (2)

SN8F5000 Family Instruction Set

~: Simple Programs in 8051 assembly language :~

Assembly Language programming (2)

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

CPEG300 Embedded System Design. Lecture 8 Timer

Unit-I. 1. INTRODUCTION TO MICROCONTROLLERS. Micro controller, types, selection of a microcontroller and applications

MICROPROCESSORS AND MICROCONTROLLERS MATERIAL. Features of 8051:

Introduction To MCS-51

T.Y. Diploma : Sem. V [EJ/EN/ET/EX/DE/IS/IC/IE/EV/MU] Micro-controller

S.J.P.N Trust's. Hirasugar Institute of Technology, Nidasoshi.

MCS-51 Serial Port A T 8 9 C 5 2 1

Principle and Interface Techniques of Microcontroller

Interrupt Programming: Interrupts vs. Polling Method:

CoE3DJ4 Digital Systems Design. Chapter 5: Serial Port Operation

Q 1 a) Attempt any THREE of the following: 12 TMOD.7 TMOD.6 TMOD.5 TMOD.4 TMOD.3 TMOD.2 TMOD.1 TMOD.0 GATE C/T M1 M0 GATE C/T M1 M0

ELEG3924 Microprocessor

The Timers/Counters The Serial Interface The Interrupt System Reset P0.0-P0.7 P2.0-P2.7. Port 2 Drivers. Port 2 Latch

UNIT-III ASSEMBLY LANGUAGE PROGRAMMING. The CPU can access data in various ways, which are called addressing modes

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

8051 Programming using Assembly

TUTORIAL. Donal Heffernan University of Limerick May Tutorial D.Heffernan 2000,

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

80C51 family programmer s guide and instruction set. 80C51 Family. PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization. Philips Semiconductors

8051 Core Specification

MCS -51 Programmer s Guide and Instruction Set

Microcontrollers. Fig. 1 gives a comparison of a microprocessor system and a microcontroller system.

8051 Microcontrollers

UNIT IV MICROCONTROLLER

DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING EC6504 MICROPROCESSOR AND MICRO CONTROLLER

Mod-3: Interrupts,Timer operation,serial communication 1

VRS540-4kB Flash, 128B RAM, 25~40MHz, 8-Bit MCU

Dodatak. Skup instrukcija


UNIT MICROCONTROLLER AND ITS PROGRAMMING

Q. Classify the instruction set of 8051 and list out the instructions in each type.

C51 Family. C51 Family Programmer s Guide and Instruction Set. Summary

DR bit RISC Microcontroller. Instructions set details ver 3.10


Experiment# 8: Photo-Interrupter Control

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: 8051 Architecture Module No: CS/ES/5 Quadrant 1 e-text

VRS550-8kB Flash, 256B RAM, 25~40MHz, 8-Bit MCU VRS560-16kB Flash, 256B RAM, 40MHz, 8-Bit MCU

Contents. Join the Technical Community Today!


Lecture 5. EEE3410 Microcontroller Applications Department of Electrical Engineering Assembly Language Programming (1)

8051 Microcontroller Assembly Programming

BHARATHIDASAN ENGINEERING COLLEGE. III Year / V Semester / EEE MICROPROCESSORS AND MICROCONTROLLERS (R-2013)

ELEG3923 Microprocessor Ch.6 Arithmetic and Logics

8051 Timers and Serial Port

C51 Family. Architectural Overview of the C51 Family. Summary

VALLIAMMAI ENGINEERING COLLEGE

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

Microcontroller. Instruction set of 8051

Scheme I. Sample Question Paper

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

CPEG300 Embedded System Design. Lecture 6 Interrupt System

MICROPROCESSOR LABORATORY MANUAL

ELEG3923 Microprocessor Ch.9 Timer Programming

Transcription:

S.Y. Diploma : Sem. IV [DE/EJ/ET/EN/EX/EQ/IS/IC/IE] Microcontroller and Applications Time: 3 Hrs.] Prelim Question Paper Solution [Marks : 70 Q.1 Attempt any FIVE of the following : [10] Q.1(a) Define the term BUS. List out the different types of BUSES. [2] Bus: The CPU is connected to memory and I/O through strips of wire called a bus. The bus carried information from place to place inside a computer. There are three types of bus address Bus Data Bus Control Bus Q.1(b) Find out the number of address lines required to access 8 kb of RAM. [2] Number of address lines for memory is given as 2 number of address lines = Memory Size 8 KB = 2 n 8 1KB = 2 n 2 3. 2 10 = 2 n 2 13 = 2 n Number of address lines = 13 Q.1(c) Compare between microprocessor and microcontroller. (any two points) [2] Sr. Parameter Microprocessor Microcontroller No. 1. No. of instructions used Many instructions to read/write data to/ from external memory. 2. Memory Do not have inbuilt RAM or ROM. 3. Registers Microprocessor contains general purpose registers, Stack pointer register, Program counter register 4. Timer Do not have inbuilt Timer. 5. I/O ports I/O ports are not available requires extra device like 8155 or 8255. 6. Serial port Do not have inbuilt serial port, requires extra devices like 8250 or 8251. 7. Multifuncti on spins 8. Boolean Operation Less Multifunction pins on IC. Boolean operation is not possible directly. Few instruction to read/ write data to/ from external memory Inbuilt RAM /or ROM Microcontroller contains general purpose registers, Stack pointer register, Program counter register additional to that it contains Special Function Registers (SFRs) for Timer, Interrupt and serial communication etc Inbuilt Timer I/O ports are available Inbuilt serial port Many multifunction pins on the IC Boolean Operation i.e. operation on individual bit is possible directly - 1 -

Vidyalankar : S.Y. Diploma MCA 9. Applications General purpose, Computers and Personal Uses. Single purpose(dedicated application), Automobile companies, embedded systems, remote control devices. Q.1(d) Comparison of Von-Neumann and Harvard architecture. [2] Von-Neumann architecture Harvard Architecture Q.1(e) List and explain the important features fo 8051 microcontroller (any four) [2] Features of 8051 micro controller are as follows: 1) 8- bit data bus and 8- bit ALU. 2) 16- bit address bus can access maximum 64KB of RAM and ROM. 3) On- chip RAM -128 bytes (Data Memory ) 4) On- chip ROM 4 KB (Program Memory ) 5) Four 8-bit bi- directional input/output ports Four 8-bit bi- directional input/ output ports. 6) Programmable serial ports i.e. One UART (serial port) 7) Two 16- bit timers- Timer 0& Timer 1 8) Works on crystal frequency of 11.0592 MHz. 9) Has power saving and idle mode in microcontroller when no operation is performed. 10) Five interrupts with six sources are available: Two interrupts Timers i.e. Timer 0 and Timer 1, two external hardware interrupts - INT0 and INT1, Serial communication interrupt ( two sources for receive and transmit). Q.1(f) Write the operation of the following instructions of 8051 : [2] (i) CJNE A, direct, rel (ii) SWAP A (i) CJNE A, direct, rel Compare the contents of the accumulator with the 8 bit data in memory address mentioned in the instruction and if they are not equal then jump to the relative address mentioned in the instruction. Example: CJNE A, 04H, UP Compare the contents of the accumulator with the contents of 04H memory and if they are not equal then jump to the line of instruction where UP label is mentioned. (ii) SWAP A Description: This instruction exchanges bits 0-3 of the Accumulator with bits 4-7 of the Accumulator. This instruction is identical to executing "RR A" or "RL A" four times. No of bytes: 1 byte Addressing mode: register specific Example: MOV A, #59H ; A= 59H SWAP A ; A= 95H - 2 -

Prelim Question Paper Solution Q.1(g) Give the different applications of Stepper Motor. [2] Applications of Stepper Motor 1. Tape recorders 2. Disk drivers 3. Matrix printers 4. Robotics Q.2 Attempt any THREE of the following : [12] Q.2(a) Explain the interfacing diagram of DAC to 8051. Write and ALP to generate triangular waveform using DAC. ORG 0000H CLR A Loop 1: MOV P0, A INC A ACALL DELAY CJNE A, # 0FF, Loop1 SJMP Loop 2 Loop 2: MOV P0, A DEC A ACALL DELAY CJNE A, # 00H, Loop2 SJMP Loop1 DELAY: MOV R0, # 05H MOV R1, # 05H Here: DJNZ R0, Here Here 1: DJNZ R1, Here 1 RET - 3 -

Vidyalankar : S.Y. Diploma MCA Q.2(b) Draw pin diagram of 8051 microcontroller. Q.2(c) Draw the format of PSW register of 8051 C and state the function of each flag. CY AC F0 RS1 RS0 OV P CY PSW.7 Carry Flag. AC PSW.6 Auxiliary carry flag. F0 PSW.5 Available to the user for general purpose. RS1 PSW.4 Register bank selector bit 1. RS0 PSW.3 Register bank selector bit 0. OV PSW.1 Overflow flag. PSE.1 User-definable bit. P PSW.0 Parity flag. Set/cleared by hardware each instruction cycle to indicate and Odd/even number of 1 bit in the accumulator. 1. CY: Carry flag. 1. This flag is set whenever there is a carry out from the D7 bit. 2. The flag bit is affected after an 8 bit addition or subtraction. 3. It can also be set to 1 or 0 directly by an instruction such as SETB C and CLR C where SETB C stands for set bit carry and CLR C for clear carry. 2. AC: Auxiliary carry flag If there is a carry from D3 and D4 during an ADD or SUB operation, this bit is set; it is cleared. This flag is used by instructions that perform BCD (binary coded decimal) arithmetic. 3. F0: Available to the user for general purposes 4. RS0, RS1: Register bank selects bits 1. These two bits are used to select one of the four register banks n internal RAM in the table. By writing zeroes and ones to these bits, a group of registers R0- R7 can be used out of four registers banks in internal RAM. - 4 -

RS1 RS0 Space in RAM 0 0 Bank 0 (00H 07H) 0 1 Bank 1 (08H 0FH) 1 0 Bank 2 (10H 17H) 1 1 Bank 3 (18H 1FH) Prelim Question Paper Solution 5. OV: Overflow flag This flag is set whenever the result of a signed number operation is too large, causing the high-order bit to overflow into the sign bit. In general, the carry flag is used to detect errors in unsigned arithmetic operations. The overflow flag is only used to detect errors in signed arithmetic operations. 6. P: Parity flag 1. The parity flag reflects the number of 1s in the A (accumulator) register only. If the A register contains an odd number of 1 s, then P=1, P=0 if A has an even number of 1 s. Q.2(d) State and describe the alternate functions of port 3 pints of 8051. Pin Name Alternate Function P3.0 RXD Serial input line P3.1 TXD Serial output line P3.2 INT0 External interrupt 0 P3.3 INT1 External interrupt 1 P3.4 T0 Timer 0 external input P3.5 T1 Timer 0 external input P3.6 WR External data memory write strobe P3.7 RD External data memory read strobe Q.3 Attempt any THREE of the following : [12] Q.3(a) Explain the following directives with example : (i) ORG, (ii) DB, (iii) EQU, (iv) END (i) ORG: ORG stands for Origin Syntax: ORG Address The ORG directive is used to indicate the beginning of the address. The number that comes after ORG can be either in hex or in decimal. If the number is not followed by H, it is decimal and the assembler will convert it to hex. Some assemblers use.org (notice the dot) instead of ORG for the origin directive. (ii) DB: (Define Byte) Syntax: Label: DB Byte Where byte is an 8-bit number represented in either binary, Hex, decimal or ASCII form. There should be at least one space between label & DB. The colon (:) must present after label. This directive can be used at the beginning of program. The label will be used in program instead of actual byte. There should be at least one space between DB & a byte. (iii) EQU: Equate It Syntax: Label EQU Numeric value By means of this directive, a numeric value is replaced by a symbol. For e.g. MAXIMUM EQU 99 After this directive every appearance of the label MAXIMUM in the program, the assembler will interpret as number 99 (MAXIMUM=99) - 5 -

Vidyalankar : S.Y. Diploma MCA (iv) END: This directive must be at the end of every program meaning that in the source code anything after the END directive is ignored by the assembler. This indicates to the assembler the end of the source file. Once it encounters this directive, the assembler will stop interpreting program into machine code. e.g. END ; End of the program. Q.3(b) Develop a program to transfer block of 10 numbers from memory location 7000 to 8000 H stored in internal memory. MOV R5, # 0AH MOV R0, # 40H MOV DPTR, # 7000H up 1: MOVX A, @ DPTR MOV @ R0, A INC DPTR INC R0 DJNZ R5, up 1 MOV DPTR, # 8000 H MOV R5, # 0AH MOV R0, # 40H up 2: MOV A, @ R0 MOVX @ DPTR, A INC DPTR INC R0 DJNZ R5, up 2 Here: SJMP Here Q.3(c) Describe the function of following instructions of 8051 microcontroller : (i) XCH A, R1 (ii) RRA (iii) MOV A, #40H (iv) SWAP A (i) XCHG A, R1 Description: This instruction exchanges byte of the Accumulator with byte of the register(r1) of RAM. Example: MOV A, #59H ;A= 59H MOV R1, #30H ;R1= 30H XCHG A, R1 ; A= 30H and R1= 59H (ii) RRA Rotate accumulator right. It stands for rotate accumulator right. The contents of the Accumulator are rotated right bit-wise. Example: Before execution A= 0AH After Execution A=05H - 6 -

Prelim Question Paper Solution (iii) MOV A, #40H This instruction moves or stores the data 40H in the Accumulator. The # symbols tells that 40 is data not address. Example: MOV A, #50H ;A= 50H (iv) SWAP A Description: This instruction exchanges the nibbles (bits 0-3 with bits 4-7) of the Accumulator. This instruction is identical to executing "RR A" or "RL A" four times. Example: MOV A, #59H ;A= 59H SWAP A ;A= 95H Q.3(d) Write an ALP for 8051 microcontroller to multiply two 8-bit numbers 23H and 15H. (Assume suitable memory addresses to store the result) Program: MOV 50H, # 23H ; store first 8-bit no. in 50H MOV 51H, #15H ; store second 8-bit no. in 51H MOV A, 50H ; move first number to A MOV B, 51H ; move second number to B MUL AB ; multiply the numbers MOV 52H, A ; move LSB to 52H MOV 53H, B ; move MSB to 53H HERE: SJMP HERE Q.4 Attempt any THREE of the following : [12] Q.4(a) Develop an ALP to read temperature from LM 35 sensor. Draw the interfacing diagram with 8051. RD BIT P2.5 WR BIT P2.6 INTR BIT P2.7 Mydata equation P1 MOV P1, # OFFH SETB INTR Back: CLR WR SETB WR - 7 -

Vidyalankar : S.Y. Diploma MCA Here: JB INTR, Here CLR RD MOV A, Mydata ACAu conversion ACAu data_display SETB RD SJMP Back Q.4(b) State and explain the use of SCON and SBUF register of 8051. SCON: It is an 8 bit control register used in serial communication of 8051.Its format is as shown below with functions of each bit. SM0 SM1 SM2 REN TB8 RB8 TI RI SM0 SCON.7 Serial port mode specifier SM1 SCON.6 Serial port mode specifier. SM2 SCON.5 Used for multiprocessor communication (Make it 0.) REN SCON.4 Set/ cleared by software to enable/ disable reception. TB8 SCON.3 9 th bit to be transmitted in mode 2 and 3. RB8 SCON.2 9 th received bit in mode 2 and 3 TI SCON.1 Transmit interrupt flag. Set by hardware at the beginning of the stop Bit in mode 1.Must be cleared by software. RI SCON.0 Receive interrupt flag. Set by hardware halfway through the stop bit time in mode 1.Must be cleared by software. SBUF: It is an 8 bit register used in serial communication of 8051.Serial data sending is done by writing to the register SBUF while data receiving is done by reading the same register. The SBUF is as shown below: Bit 7 Bit 0 SBUF has physically two registers, one write only and other is read only. Both registers use one address 99H Q.4(c) Write assembly language program for 8051 to generate square wave of 10 KHz on port pin P1.7. Assume XTAL, frequency = 12 MHz. CALCULATION: (Assumed Timer 0 in Mode 1) Crystal freq = 12MHz Timer frequency = 12MHz/12 = 1MHz Time = 1/1MHz = 1μss Given frequency = 10KHz, Time Period (T) = 1/10kHz = 0.1ms, Ton = Toff = T/2, Delay = 0.1ms/2 = 0.05ms 0.05ms/1μs = 50 Therefore count to be loaded in TH0 and TL0 can be calculated as 65536-50 = 65486d = FFCEH Program: MOV TMOD, #01H UP: SETB P1.7 ACALL DELAY CLR P1.7-8 -

Prelim Question Paper Solution ACALL DELAY SJMP UP DELAY: MOV TH0, #0FFH MOV TL0, # 0CEH SETB TR0 JNB TF0, $ CLR TF0 CLR TR0 RET END Q.4(d) Draw the interfacing of Stepper Motor and write an ALP to rotate in clockwise direction. +5v +5v P o 8051 r Microcontroller t 1 4Th 4Th 4Th Unipolar Stepper Motor ULN2003 Step no Winding A Winding B Winding C Winding D Clockwise 1 0 0 1 1 2 0 1 1 0 3 1 1 0 0 4 1 0 0 1 Calculation for no. of steps: Re quired Rotation Angle Count = 1.8 degree *no. of steps = 180/1.8*4 steps = 100/4 = 25 PROGRAM: MOV A, #66H ; load step sequence MOV R0, # 25 ; count for 4 steps BACK: MOV P1, A ; issue sequence to motor AGAIN:RL A ; rotate left anticlockwise ACALL DELAY ; wait DJNZ R0, AGAIN SJMP BACK ; keep going DELAY ; delay subroutine. MOV R2, #100 H1 : MOV R3, #255 H2 : DJNZ R3, H2 DJNZ R2, H1 RET +5v - 9 -

Vidyalankar : S.Y. Diploma MCA Q.4(e) Develop an ALP to transmit message WELCOME serially at baud rate of 9600, 8 bit data, 1 stop bit. Assume crystal frequency of 11.0592 MHz. MOV TMOD, #20H ; timer 1, mode2 MOV TH1,#-3 ; 9600 baud rate MOV SCON, #50H ; 8-bit data,1 stop bit, REN enabled SETB TR1 ; Start timer 1 AGAIN:MOV A, #'W" ; transfer "W" ACALL MESSAGE ; Some delay MOV A, #"E" ; transfer "E" ACALL MESSAGE MOV A, #"L" ; transfer "L" ACALL MESSAGE MOV A, #"C" ; transfer "C" ACALL MESSAGE MOV A, #"O" ; transfer "O" ACALL MESSAGE MOV A, #'M" ; transfer "M" ACALL MESSAGE MOV A, #"E" ; transfer "E" ACALL MESSAGE SJMP AGAIN MESSAGE: MOV SBUF, A; JNB T1, HERE; CLR T1; RET Q.5 Attempt any TWO of the following : [12] Q.5(a) Write an ALP for 8051 C to find smallest numbers from the array of ten numbers [6] stored in external memory location 3000 H to onwards. Store result at 6000 H. (Assume suitable data) Program: CLR PSW.3 ; Select Bank 0 PSW.3 MOV R1, 0AH ; Initialize byte counter MOV DPTR, # 3000H ; Initialize memory pointer DEC R1 ; Decrement byte counter by 1 MOVX A, @DPTR ; Load number in accumulator MOV 40 H, A ; Store number in memory location UP: INC DPTR ; Increment memory pointer by 1 MOVXA, @DTPR ; Read next number CJNE A, 40 H, DN ; if number next number, and then go to DN DN: JNC NEXT ; If next number > number then go to NEXT MOV 40H, A ; Else replace n ext number with number NEXT: DJNZ R1, UP ; Decrement byte counter by 1, if byte counter 0 then go to UP MOV DPTR,#6000H ; Increment memory pointer by 1 MOV A, 40H MOVX@ DPTR, A ; Store result t external memory location LOOP: AJMP LOOP ; Stop - 10 -

Prelim Question Paper Solution Q.5(b) Write and ALP to arrange the given data in ascending order in 8051 [6] microcontroller : Data : (40 H) = 09 H (41 H) = 07 H (42 H) = 12 H (43 H) = 25 H (44 H) = 01 H Store the result in (50 H) to (54 H) Any registers can be considered for counter but only R0 and R1 for pointers. MOV R4,#04H ; initialize pass counter i.e maximum no (5)-1 UP1: MOV R3,#04H ; initialize byte counter i.e. maximum no (5)-1 as one no is ; compared with four other nos MOV R0,#40H ; initialize memory pointer UP: MOV A,@R0 ; read first number MOV R1,A ; copy to R1 register first no in R1 INC R0 ; point to next no MOV A,@R0 ; next no in A CJNE A,R1,NEXT ; compare the first number with the second 2 nd no 1 st no NEXT: JNC SKIP ; if number 2 nd no > 1 st no next number go to skip else exchange it MOV @R0,R1 ; 1 st no at next position DEC R0 ; point to previous position MOV @R0,A ; 2 nd no at previous position INC R0 ; point to next no SKIP: DJNZ R3,UP ; decrement byte counter if not zero go to UP DJNZ R4,UP1 ; Repeat this process total nos-1 times MOV R0,#40H ; Load source memory pointer MOV R1,#50h ; Load destination memory pointer MOV R5,#05H ; initialize the counter register for 5 nos AGAIN: MOV A,@R0 ; copy the number into accumulator MOV @R1,A ; copy the number into memory pointer 50H INC R0 ; increment memory pointer INC R1 ; increment memory pointer DJNZ R5,AGAIN ; decrement counter register if not zero go to AGAIN SJMP $ ; stops Q.5(c) Sketch 8021 interfacing diagram to interface 4 LED s and 4 switches, interface LED to port 0 upper nibble and switches to port 1. Develop an ALP to read status of switches and operate LEDs as per switch status. [6] - 11 -

Vidyalankar : S.Y. Diploma MCA Assumption: 1. Switches are connected to port pin P1.0 to P1.3 2. When switch is pressed port pin is pulled to high logic 1. 3. LED s are connected to port pin P0.4 to P0.7 4. 1 on port pin flows the LED. Logic states S1 S2 S3 S4 D1 D2 D3 D4 1 0 0 0 ON OFF OFF OFF 0 1 0 0 OFF ON OFF OFF 0 0 1 0 OFF OFF ON OFF 0 0 0 1 OFF OFF OFF ON 1 0 0 1 ON OFF FF ON 1 1 1 1 ON ON ON ON Total logic states 00 to FF ORG 0000H LJMP MAIN ORG 0030H main: SETB TCON.0 MOV IE, # 81H here: SJMP here ORG 0003H LJMP Test ORG 0080H Test: SETB P0.1 SETB P0.2 SETB C Test1: MOV C P0.1 JNC sw1 MOV C, P0.2 JNC sw2 MOV P2, # 0FF H RETI sw1: MOV C, P0.2 JNC Both MOV P2, #01H SJMP TEST1 sw2: MOV P2, # 02H SJMP Test1 Both: MOV P2, #0FH SJMP Test1 END Q.6 Attempt any TWO of the following: [12] Q.6(a) Develop an 8051 based system for traffic light controlling. Draw interfacing [6] diagram and write and ALP for the same. Traffic Light Control There are free left turns in all four direction. N - 12 - WR WY W 0 0 0 SG SY SR 0 0 0 0 0 0 S NR NY NG E 0 0 0 EG EY ER

Prelim Question Paper Solution The allowed sequence is P1 Sequence SG SY SR EG EY ER NG NY NR WG WY WR P0 P1 0 0 1 0 0 1 0 0 1 1 0 0 DC 09 0 0 1 0 0 1 0 1 0 1 0 0 14 09 0 0 1 0 0 1 1 0 0 0 0 1 21 09 0 0 1 0 1 0 1 0 0 0 0 1 21 DA 0 0 1 1 0 0 0 0 1 0 0 1 09 OC 0 1 0 1 0 0 0 0 1 0 0 1 09 14 1 0 0 0 0 1 0 0 1 0 0 1 09 21 1 0 0 0 0 1 0 0 1 0 1 0 0A 21 START : MOV R0, # 04 H MOV DDTR, # LED_DATA MOVX A, @ DDTR MOV P0, A INC DPTR MOVX A, @DDTR MOV P0, A INC DPTR MOVX A, @ DPTR MOV P1, A LCALL DELAY1 INC DPTR MOYX A, @DPTR MOV P0, A INC DPTR MOVX A, @DPTR MOV P1, A LCALL DELAY2 INC DPTR DJNZ R0, LOOP SJMP START LED_DATA : DB, OC, 09, 14, 09, 21, 09, 21 OA, 09, 0C, 09, 14, 09, 21, 0A, 21 END Interfacing diagram: P0-13 -

Vidyalankar : S.Y. Diploma MCA Q.6(b) Differentiate between the uses of 8051 as timer and counter. [6] Sr. 8051 USE AS TIMER 8051 USE AS COUNTER No. (i) It is used for delay implementation It is used to measure external event such as pulse width measurement (ii) External pin T0/T1 is not used External pin T0/T1 is monitored (iii) (iv) Counter is incremented for 1/12 th of Fosc THx and TLx is loaded as per required Delay (v) C/T = 0 C/T = 0 Counter is incremented for every pulse on T0 or T1 pin, irrespective of it s frequency. THx and TLx must be initially cleared for counter Q.6(c) State and explain the need of the following development tools microcontroller [6] board : (i) Editor, (ii) Assembler, (iii) Compiler. (i) Editor: It is a program used to create and or edit programs. The editor is capable of producing ASCII files the editor saves file in.asm form at (ii) Assembler: It is a program used to convert the instructions into the machine code. It produces object file and list file. (iii) Compiler: It is a program used for conversion of high level programming language to machine language. - 14 -