THE MICROCONTROLLER LAST TIME MATERIAL

fiercebunΗλεκτρονική - Συσκευές

2 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

159 εμφανίσεις

THE MICROCONTROLLER LAST TIME MATERIAL

PREPARED BY PUNIT LATHIYA

1


IMP QUESTIONS OF MICROCONTROLLER



1.

Compare the microprocessor with microcontroller.

2.

Comparison of microcontroller to microprocessor.

3.

Discuss the important features of 8051 microcontroller. What are its areas of applications?

4.


Draw the block diagram of 805
1 and explain it.

5.

Programming model of 8051 microcontroller.

6.

Internal memory of 8051 microcontroller.

7.

Draw the internal RAM organization of 8051 and explain it in detail.

8.

Explain the I/O ports of 8051.

9.

Draw and explain the port
-
1 of 8051 with its configura
tion.

10.

Draw and explain the port
-
0 of 8051 with its configuration.

11.

Explain the external memory connection of 8051.

12.

Explain SCON,PCON,IE,IP,TCON,

13.

Write the difference between the counting and timing.

14.

Draw and explain the timer/Counter logic circuit. Explain
the timer mode 3 with diagram.

15.

Explain the different timer modes of 8051.
(6)

16.

Serial data transmission modes (mode 0 and mode 1.)

17.

Give the interrupt priorities for 8051.Explain interrupt in detail

18.

Different addressing modes of 8051 microcontroller.

19.

With th
e neat sketch explain external data moves.

20.

Singed and unsigned addition and subtraction.

21.

Different range of JUMP and CALL address modes

22.

Explain the function of Boolean processor in 8051 .How does it differ from the BYTE processor.

23.

Briefly explain the memor
y access time.


24.

Different methods for expanding I/O capabilities of 8051 microcontroller.

25.

Explain the time delay subroutine of 8051.

26.

Difference between the Software and Hardware time delay.

27.

Look up tables for 8051
microcontroller
.

28.

Explain the technique to
construct and read look up tables for 8051.

29.

Character transmission by time delay and polling.

30.

Polling for received data and interrupt driven serial data reception.

31.

Intelligent LCD display

32.

Interfacing of intelligent LCD display.

33.

Explain the pulse measuremen
t.

34.

The 8096 microcontroller (block diagram and explanation).

35.

Differences between 8051 and 8096 microcontroller.

THE MICROCONTROLLER LAST TIME MATERIAL

PREPARED BY PUNIT LATHIYA

2



THE PROGRAM THAT ARE ASKED IN UNIVERSITY


PROGRAM 1: WRITE A PROGRAM TO TREAT THE REGISTER R0 AND R1 AS A 16 BIT REGISTER AND
ROTATE THEM ONE
PLACE TO LEFT.


ORG 00H


ROT16:

MOV R0, #81H; R0=1000 0001, R1=1000 0001, CY=0;




MOV R1, #81H; LOAD R0 AND R1 WITH RANDOM VALUES




MOV A, R0 ; ROTATE R0 1 BIT




RLC A ;




MOV R0, A ; R0=0000 0010, CY=1;





MOV A, R1 ; ROTATE R1 1 BIT




RLC A ;




MOV R1, A ; R1=0000 0011, CY= 1;




MOV A, R0 ; FINAL ADJUSTMENT FOR 16 BIT ROTATIONS




MOV 0E0H, C;




MOV R0, A ; R0=0000 0011, R1=0000 0011, CY=1;




RET ; WHICH IS REQUIRED OP: R1R0=0303H


PROGRAM 2: WRITE A PROGRAM TO COUNT NO OF 0'S IN ANY NO. IN REGISTER B AND PUT THE
COUNT IN REGISTER R5.


ORG 00H




MOV R0, #08H




MOV B, #66H




MOV A, B

AGAIN:

RLC A




JC NO_
INC




INC R5

NO_INC:

DJNZ R0, AGAIN




SJMP $


PROGRAM 3: WRITE A PROGRAM TO EXCHANGE THE HIGHER NIBBLES OF BYTES WITHOUT USE
OF XCH, XCHD, ROTATE AND SWAP INSTRUCTION.


ORG 00H

MOV R3, #82H

MOV R4, #28H

MOV A, R3

ANL A, #0F0H

MOV R5, A

MOV

A, R4

ANL A, #0F0H

MOV R6, A

MOV A, R3

ANL A, #0FH

ADD A, R6

MOV R3, A

MOV A, R4

ANL A, #0FH

ADD A, R5

MOV R4, A

SJMP $


THE MICROCONTROLLER LAST TIME MATERIAL

PREPARED BY PUNIT LATHIYA

3


PROGRAM 4: WRITE A PROGRAM TO STORE THE MOST SIGNIFICANT NIBBLE OF A REGISTER IN
BOTH NIBBLES OF R5.


ORG 00H

MSBAR52:

MOV A, #68H

; LOAD A WITH ANY RANDOM VALUE.




PUSH 0E0H ; PUSH A TO STACK.




MOV R5, A ; MOV A TO R5




RL A ; ROTATE 4 TIMES SO THAT




RL A ; MSB BECOMES LSB




RL

A




RL A




MOV R0, #05H ; MOV ADDRESS OF R5 IN R0




XCHD A,@R0 ; XCHANE THE LOWER NIBBLES OF A AND R5.




POP 0E0H ; RESTORE ACC.




SJMP $


PROGRAM 5: WRITE A PROGRAM TO PUT ONE RANDOM N
UMBER INTO R2 AND ANOTHER IN R5.
INCREMENT R2 AND DECREMENT R5 UNTIL THEY BECOME EQUAL.


ORG 00H

MOV R2, #00H

MOV R5, #066H

COMPARE:

MOV A, R2




SUBB A, R5




CLR C




JNZ PROCESS




SJMP $

PROCESS:

DEC R5




INC R
2




SJMP COMPARE

PROGAM 6: WRITE A PROGRAM TO COUNT THE NO OF 1'S IN A WORD STORED IN EXTERNAL
RAM.STORE THE RESULT IN R5.

ORG 00H




MOV R0, #08H




MOV A, #66H

AGAIN:

RLC A




JNC NOCAR




INC R1

NOCAR:

DJNZ R0, AGAIN





MOV DPTR, #1234H




MOV A, R1




MOVX @DPTR, A




SJMP $


PROGRAM 7: MULTIPLY THE DATA IN RAM LOCATION 22H BY THE DATA IN RAM LOCATION 15H
AND PUT THE RESULT IN RAM LOCATION 19H(LSB) AND 1AH(MSB)


ORG 00H

MOV A, #66H

MOV B, #10H

MUL

AB

MOV 19H, A

MOV 1AH, B

SJMP $


THE MICROCONTROLLER LAST TIME MATERIAL

PREPARED BY PUNIT LATHIYA

4

PROGRAM 8: FIND THE ADDRESS OF THE FIRST TWO RAM LOCATION BETWEEN 20H AND 60H
WHICH CONTAIN CONSECUTIVE NUMBERS.

IF SO, SET THE CARRY FLAG OTHERWISE RESET.


ORG 00H




MOV R0, #20H




MOV R1, #21H

AGAIN:

MO
V A,@R0




INC A




CLR C




SUBB A,@R1




JZ FINISH




INC R0




INC R1




CJNE R0, #60H, AGAIN




CLR C




SJMP $

FINISH:

SETB C




SJMP $


PROGAM 9: WRITE A PROGRAM FOR 16 BIT ADDITI
ON WITH OUT USE OF ADDITION INSTRUCTIONS.

;

; THIS PROGRAM MAKES THE USE OF SUBTRACTION INSTRUCTION TO DO THE INSTRUCTION

;

; THE LOGIC IS A+B =A
-
(
-
B)

; THIS PROGRAM WILL ADD THE 16 BIT NUMBERS STORED AT

; 1) R0 LSB R1 MSB

; 2) DPL LSB DPH MSB

; THE ADDITI
ON 1234H+4567H=579B


ORG 00H

MOV R0, #34H

MOV R1, #12H

MOV DPTR, #4567H

XCH A, 82H ; THESE STEPS ARE USED TO FIND THE TWO'S COMPLEMENT

CPL A ; OF DATA STORED IN DPTR

XCH A, 82H ;

XCH A, 83H ;

CPL A

;

XCH A, 83H ;

INC DPTR

;


MOV A, #34H; THESE STEPS ARE USED TO ADD THE LSB OF

CLR C

; BOTH NUMBERS AND STORE THE RESULT IN R0.

XCH A, R0

;

CLR C

;

SUBB A, 82H;

XCH A, R0 ;


XCH A, R1 ; THESE STEPS ARE USED TO ADD THE MSB OF

SUBB A, 83H; BOTH NUMBERS AND ST
ORE THE RESULT IN R1.

XCH A, R1

SJMP $

; THE FINAL RESULT IS STORED IN R0 (LSB) AND R1 (MSB).





THE MICROCONTROLLER LAST TIME MATERIAL

PREPARED BY PUNIT LATHIYA

5

PROGRAM 10: WRITE AN ALP TO ADD TWO 32 BIT NUMBER.


; THESE PROGRAM IS USES @R0 AND @R1 TO TWO 32 BIT NONUMBERS.

; THE FIRST NUMBER IS 12345678H S
TORED AT 30H
-
33H (LSB
-
MSB).

; THE SECOND NUMBER IS 87654321H STORED AT 40H
-
43H (LSB
-
MSB).

; THE ANSWER IS = 99999999H.


ORG 00H


MOV 30H, #12H; SAVE THE NO AT THE RAM LOCATION


MOV 31H, #34H;


MOV 32H, #56H;



MOV 33H, #78H;


MOV 40H, #87H;


MOV 41H, #65H;


MOV 42H, #43H;


MOV 43H, #21H;



MOV R0, #30H ; INTIALLISE THE POINTER TO POINT THE ADDRESS


MOV R1, #40H


MOV R3, #04H


CLR C

; DUE TO USE OF ADDC CLEAR CARRY FOR FIRST TIME


ADDITION:

MOV A, @R0 ; IT CAN BE USED FOR MORE THAN 32 BIT JUST R





ADDC A, @R1 ; REPLACE THE CONTENT OF R3 WITH BITS/8





MOV @R0, A ; NUMBER






INC R0 ;



INC R1 ;




DJNZ R3, ADDITION ;




SJMP $

; THE ADDITION IS STORED AT 30
-
33H ADDRESS.


PROGRAM 11: WRITE A PROGRAM TO FIND THE LARGEST NUMBER WITHIN
THE MEMORY BLOCK
OF 256 BYTES.


ORG 00H

MOV DPTR, #100H ; FIND THE BLOCK OF MEMORY 0100
-
01FFH

MOVX A,@DPTR ; USE OF DPTR AS A BASE POINTER

MOV R1, A ; USE INITIAL VALUE AS A MAXIMUM NO

CHECK:

INC DPTR ; INCREMENTS

DPTR




MOV R0, DPH


; COPY DPH TO COMPARE WITH FFH





CJNE R0, #0FFH, L1 ; IF DPH =0FFH STOP COUNTING




SJMP END

L1:


MOVX A,@DPTR


; ELSE TAKE THE BYTE FROM EXTERNAL




CJNE A, 01H, CHANGE; MEMORY AND COMPARE IT
WITH




SJMP CHECK

; MAXIMUM NO STORED IN R0.

CHANGE:

JNC BIG ; IF NO IS LARGE THAN STORED IT IN R0




SJMP CHECK ; ELSE MOVE TO NEXT NUMBER

BIG:


MOV R1, A




SJMP CHECK

END: SJMP END


P
ROGRAM 12: MOV BIT 6 OF R0 TO BIT 5 OF PORT 3.

ORG 00H

MOV A, R0

MOV C, ACC.6

MOV P3.5, C

SJMP $

THE MICROCONTROLLER LAST TIME MATERIAL

PREPARED BY PUNIT LATHIYA

6


PROGRAM 13: ROTATE THE CONTENT OF DPTR LEFT BY ONE PLACE


ORG 00H

MOV DPTR, #1234H

MOV A, DPL

RLC A

MOV DPL, A

MOV A, DPH

RLC A

MOV DPH, A

MOV A, DPL

MOV ACC.
0, C

MOV DPL, A

SJMP $


PROGRAM 14: SET EVERY THIRD BYTE IN INTERVAL RAM FROM ADDRESSES 20H TO 7FH
TO FFH


ORG 00H

MOV R0, #20H

MOV R1, #03H

SJMP START

LABEL:

INC R0

START:

CJNE R0, #080H, CONTINUE



SJMP FINISH

CON
TINUE:

DJNZ R1, LABEL



MOV @R0, #0FFH



MOV R1, #03H



SJMP LABEL

FINISH:

SJMP FINISH


PROGRAM 15: THE NUMBER F0H IS STORED BETWEEN THE RAM LOCATION 200H TO 800H. FIND THE
NO. AT PUT IT I
N R7 (MSB) & R6 (LSB).


RMSTR EQU 200H

RMSTPHI EQU 80H

RMSTPLO EQU 00H

NUMBER EQU 0F0H


ORG 00H

MOV DPTR, #RMSTR

SJMP FIRSTIME

NOFOUND: INC DPTR

FIRSTIME:

MOV R0, DPH



MOV R1, DPL



CJNE R0, #RMSTPHI, CONTINUE




CJNE R1, #RMSTPLO, CONTINUE



SJMP FINISH

CONTINUE: MOVX A,@DPTR



CJNE A, #NUMBER, NOFOUND

FOUND:

MOV R7, DPH



MOV R6, DPL



SJMP $

FINISH:

MOV R6, #0FFH





MOV R7, #0FFH




SJMP FINISH

THE MICROCONTROLLER LAST TIME MATERIAL

PREPARED BY PUNIT LATHIYA

7


PROGRAM 16: FIND THE ADDRESS OF FIRST TWO INTERNAL RAM LOCATION BETWEEN 20H AND
60H WHICH CONTAIN CONSECUTIVE NUMBERS. IF SO, SET THE CARRY FLAG OTHERWISE RESET.


RMSTR EQU 20H

RMSTP EQU 60H


ORG 00H

MOV R0, #RMSTR

C
ONTINUE:

CJNE R0, #RMSTP, OK




CLR C




SJMP FINISH

OK:


MOV A,@R0




INC R0




MOV B,@R0




INC A




CJNE A, B, CONTINUE




SETB C




JZ FINISH

FINISH:

SJMP FINISH


PROGRAM 19: WRIT
E A PROGRAM TO INCREMENT THE CONTENT OF DPTR UNTIL IT BECOMES
ABCDH


ORG 00H

MOV DPTR, #0000H

SJMP CHECK1

AGAIN:

INC DPTR

CHECK1:

MOV R0, DPH




MOV R1, DPL




CJNE R0, #0ABH, AGAIN




CJNE R1, #0CDH, AGAIN

SJMP $


PROGRAM 18:
WRITE A PROGRAM TO EXCHANGE THE CONTENT OF THE SP AND PSW.


ORG 00H

MOV PSW, #0E2H

MOV SP, #03EH

XCH A, PSW

XCH A, SP

SJMP $


OTHER METHOD:


O
RG 00
h



MOV A
, PSW



XCH A, SP



MOV PSW, A




SJMP $