M Cmanual 2020-UPDATED
M Cmanual 2020-UPDATED
MICROCONTROLLER 8051
2 Write a C program to (i) transmit and (ii) to receive a set of characters CO4
50-80
serially by interfacing 8051 to a terminal.
3 Write ALPs to generate waveforms using ADC interface CO3
4 Write ALP to interface an LCD display and to display a message on it. CO3
5 Write ALP to interface a Stepper Motor to 8051 to rotate the motor. CO3
6 Write ALP to interface ADC-0804 and convert an analog input connected CO3
to it.
4. Create a source file (using File->New), type in the assembly or C program and save this
(filename.asm/ filename.c) and add this source file to the project using either one of the
following two methods. (i) Project-Components,Environmentand Books->addfiles-> browse to
the required file -> OK “OR”
(ii) right click on the Source Group in the Project Window and the Add Files to Group
option.
5. Set the Target options using -> Project – Options for Target opens the Vision2 Options
for Target – Target configuration dialog. Set the Xtal frequency as 11.0592 Mhz, and also the
Options for Target – Debug – use either Simulator / Keil Monitor- 51 driver.
If Keil Monitor- 51 driver is used click on Settings -> COM Port settings select the COM
Port to which the board is connected and select the baud rate as 19200 or 9600 (recommended).
Enable Serial Interrupt option if the user application is not using on-chip UART, to stop
program execution.
6. Build the project; using Project -> Build Project. Vision translates all the user application
and links. Any errors in the code are indicated by – “Target not created” in the Build window,
along with the error line. Debug the errors. After an error free build, goto Debug mode
7. Now user can enter into Debug mode with Debug- Start / Stop Debug session dialog. Or by
clicking in the icon.
8.The program is run using the Debug-Run command & halted using Debug-Stop Running.
Also the (reset, run, halt) icons can be used. Additional icons are
(step, step over, step into, run till cursor).
9. If it is an interface program the outputs can be seen on the LCD, CRO, motor, led status, etc.
If it is a part A program, the appropriate memory window is opened using View -> memory
window (for data RAM & XRAM locations), Watch window (for timer program), serial
window, etc.
(SL) Source Locations: 8100H; (DL) Destination location: 8120H; (BS) Block size: 03H
ORG 0000H
LJMP 8000H
ORG 8000H
MOV R7, #03H
MOV DPH, #81H
MOV R2, #20H
MOV R3, #00H
L1: MOV DPL, R3
MOVX A, @DPTR
MOV DPL, R2
MOVX @DPTR, A
INC R2
INC R3
DJNZ R7, L1
HERE: SJMP HERE
END
RESULT:
ORG 0000H
LJMP 8000H
ORG 8000H
MOV R5, #05h
MOV R0, #40H
MOV R1, #50H
LOOP: MOV A, @R0
MOV @R1, A
INC R0
INC R1
DJNZ R5, LOOP
HERE: SJMP HERE
END
ORG 0000H
LJMP 8000H
ORG 8000H
MOV DPH, #81H
MOV R2, #00H
MOV R3, #02H
MOV R1, #05H
MOV A, R2
ADD A, R1
DEC A
MOV R2, A
MOV A, R3
ADD A, R1
DEC A
MOV R3, A
L2: MOV DPL, R2
MOVX A, @DPTR
MOV DPL, R3
MOVX @DPTR, A
DEC R2
DEC R3
DJNZ R1, L2
HERE: SJMP HERE
END
RESULT:
4. Write a program to interchange ‘N’ bytes of data stored at location x with ‘N’
bytes of data stored at location y. Use external memory
ORG 00H
LJMP 8000H
ORG 8000H
MOV R7, #03H
MOV R1, #81H
MOV R2, #82H
MOV R3, #83H
MOV R4, #00H
L1: MOV DPH, R1
MOV DPL,R4
MOVX A,@DPTR
MOV DPH,R3
MOVX @DPTR,A
MOV DPH,R2
MOVX A, @DPTR
MOV DPH, R1
MOVX @DPTR, A
MOV DPH, R3
MOVX A,@DPTR
MOV DPH, R2
MOVX @DPTR, A
INC R4
DJNZ R7, L1
HERE: SJMP HERE
END
RESULT:
X:8200H X:8200H
ORG 00H
LJMP 8000H
ORG 8000H
MOV R7, #05H
MOV R0, #30H
MOV R1, #40H
NEXT: MOV A, @R0
MOV R2, A
MOV A,@R1
MOV @R0, A
MOV A, R2
MOV @R1, A
INC R0
INC R1
DJNZ R7, NEXT
HERE: SJMP HERE
END
D:40H D:40H
ORG 0000H
LJMP 8000H
ORG 8000H
MOV R0, #09h (no. of comparisons)
L1: MOV DPTR, #9000h
MOV A, R0
MOV R1, A
L2: MOVX A, @DPTR
MOV B, A
INC DPTR
MOVX A, @DPTR
CLR C
MOV R2, A
SUBB A, B
JNC NOEXCHG //JC for descending
MOV A, B
MOVX @DPTR, A
DEC DPL
MOV A,R2
MOVX @DPTR,A
INC DPTR
NOEXCHG: DJNZ R1, L2
DJNZ R0, L1
HERE: SJMP HERE
END
RESULT:
Before Execution After Execution
Memory loc Data Memory loc Data
X:9000h X:9000h
ORG 0000H
LJMP 8000H
ORG 8000H
MOV R3, #06H (no. of comparisons)
MOV DPTR, #9000H
MOVX A,@DPTR
MOV R1,A
NEXTBYTE: INC DPTR
MOVX A,@DPTR
CLR C
MOV R2, A
SUBB A, R1
JC skip // JNC for smallest element
MOV A, R2
MOV R1,A
skip: DJNZ R3,NEXTBYTE
MOV A, R1
INC DPTR
MOVX @DPTR, A
HERE: SJMP HERE
END
RESULT: Largest
Before Execution After Execution
Memory Data Memory Data
loc loc
X:900H X:900H
Smallest
Before Execution After Execution
Memory Data Memory Data
loc loc
X:900H X:900H
VIVA QUESTIONS
1. Which are the most common 8051 series of microcontrollers
Atmel series AT89C2051 and Philips family P89C51RD2 are the two most common
microcontrollers of 8051 families.
2. What is the internal RAM size of 8051
128 bytes
3. When 8051 wakes up then 0x00 is loaded to which register?
Program Counter
4. How many bytes of bit addressable memory is present in 8051 based microcontrollers?
16 bytes
5. List Interrupts available in 8051 microcontroller
External interrupt 0 (IE0) has highest priority among interrupts.
Timer interrupt 0 (TF0)
External interrupt 1 (IE1)
Timer interrupt 1 (TF1) has lowest priority among other interrupts.
Serial port Interrupt
Reset
6. What is the meaning of the instruction MOV A,05H?
Address 05H is stored in the accumulator
ORG 0000H
LJMP 8000H
ORG 8000H
MOV R0, #40H
MOVX A,@R0
MOV R1, A
INC R0
MOVX A,@R0
MOV B, A
INC R0
MOVX A,@R0
CJNE R1, #00H, CKSUB
ADD A, B
MOV B, #00H
JNC SKIP
MOV B, #01H
SKIP: SJMP LAST
CKSUB: CJNE R1, #01H, CKMUL
CLR C
SUBB A, B
MOV B, #00H
JNC SKIP1
MOV B, #0FFH
SKIP1: SJMP LAST
CKMUL: CJNE R1, #02H, CKDIV
MUL AB
SJMP LAST
CKDIV: CJNE R1, #03H, OTHER
DIV AB
SJMP LAST
OTHER: MOV A, #00H
MOV B, #00H
LAST: INC R0
MOVX @R0, A
INC R0
MOV A, B Memory Data to be operation
MOVX @R0, A location entered
HERE: SJMP HERE X:40h 00 ADD
END X:40h 01 SUB
X:40h 02 MUL
OBSERVATION & RESULT: X:40h 03 DIV
Enter the data in location 41h & 42h. Check the results in 43h& 44h
ORG 0000H
LJMP 8000H
ORG 8000H
MOV DPTR, #8050H
MOVX A,@DPTR
MOV B,A
PUSH B
INC DPTR
MOVX A,@DPTR
MUL AB
MOV R1,A
MOV R2,B
INC DPTR
MOVX A,@DPTR
POP B
MUL AB
ADD A,R2
PUSH 0E0H
MOV DPTR, #8055H
MOV A,R1
MOVX @DPTR,A
INC DPTR
POP 0E0H
MOVX @DPTR,A
MOV A,B
ADDC A, #00H
INC DPTR
MOVX @DPTR,A
HERE: SJMP HERE
END
ORG 0000H
LJMP 8000H
ORG 8000H
MOV DPH, #81H
MOV R2, #00H
MOV R3, #20H
MOV R4, #50H
MOV R5, #02H (data size)
L2: MOV DPL,R2
MOVX A,@DPTR
MOV B,A
MOV DPL,R3
MOVX A, @DPTR
ADDC A,B
MOV DPL,R4
MOVX @DPTR,A
INC R2
INC R3
INC R4
DJNZ R5,L2
INC DPTR
JC L3
MOV A,#00H
MOVX @DPTR,A
SJMP HERE
L3: M0V A,#01H
MOVX @DPTR,A
HERE: SJMP HERE
END
ORG 0000H
LJMP 8000H
ORG 8000H
MOV DPH, #81H
MOV R2, #00H
MOV R3, #20H
MOV R4, #50H
MOV R5, #02H ( data size) (2 bytes=16 bits)
L2: MOV DPL,R2
MOVX A, @DPTR
MOV B, A
MOV DPL, R3
MOVX A, @DPTR
SUBB A, B
MOV DPL, R4
MOVX @DPTR, A
INC R2
INC R3
INC R4
DJNZ R5, L2
INC DPTR
CLR A
SUBB A,#00H
MOVX @DPTR, A
HERE: SJMP HERE
END
ORG 0000H
LJMP 8000H
ORG 8000H
MOV DPTR, #9000H
MOVX A, @DPTR
MOV R0, A Bit addressable location
MOV B, A 20H 07 06 05 04 03 02 01 00
MUL AB
CLR C
JB 01, LAST
PUSH B
MOV B, A
MOV A, R0
MUL AB
INC DPTR
MOVX @DPTR, A
MOV A, B
MOV R2, A
POP B
MOV A, R0
MUL AB
ADD A, R2
LAST: INC DPTR
MOVX @DPTR, A
MOV A, B
ADDC A, #00H
INC DPTR
MOVX @DPTR, A
HERE: SJMP HERE
END
D:20H OPERATION
02/03/0f/ff square
00/05/08 cube
ORG 0000H
LJMP 8000H
ORG 8000H
MOV DPTR, #8100H
MOV R5, #00H
MOVX A, @DPTR
MOV R7, A
DEC R7
CLR C
INC DPTR
MOVX A,@DPTR
L1: MOV B, A
INC DPTR
MOVX A, @DPTR
ADD A, B
JNC L2
INC R5
L2: DJNZ R7, L1
MOV DPTR, #9100H
MOVX @DPTR, A
INC DPTR
MOV A, R5
MOVX @DPTR, A
HERE: SJMP HERE
END
RESULT:
Note: N- size of the array. Store N in location 8100h and elements from 8101h onwards
ORG 0000H
LJMP 8000H
ORG 8000H
MOV DPTR, #8100H
MOV R5, #00H
MOVX A,@DPTR
MOV R7, A
DEC R7
CLR C
INC DPTR
MOVX A,@DPTR
L1: MOV B, A
INC DPTR
MOVX A, @DPTR
ADD A, B
DA A
JNC L2
INC R5
L2: DJNZ R7, L1
MOV DPTR, #9100H
MOVX @DPTR, A
INC DPTR
MOV A, R5
ADD A, #00H
DA A
MOVX @DPTR, A
HERE: SJMP HERE
END
RESULT:
Note: N- size of the array. Store ‘N’ in location 8100h and elements from 8101h onwards.
Enter only BCD numbers.
Mem Loc Data
X:8100H Size of
array
X:8101H
X:8102H
X:8103H
Result
Mem Loc Data
X:9100H
X:9101H
VIVA QUESTIONS
1. How are the status of the carry, auxiliary carry and parity flag affected if the write
instruction
MOVA,#9C
ADD A,#64H
CY=1,AC=1,P=0
2. When the microcontroller executes some arithmetic operations, then the flag bits of
which register are affected?
PSW
3. How are the bits of the register PSW affected if we select Bank2 of 8051?
PSW.3=0 and PSW.4=1
4. DJNZ R0, label is how many bit instructions?
2
5. JZ, JNZ, DJNZ, JC, JNC instructions monitor the bits of which register?
PSW
6. DAA command adds 6 to the nibble if:
Either CY or AC is 1
Counters.
ORG 0000H
LJMP 8000H
ORG 8000H
MOV A, #00H
BACK: ACALL DELAY
INC A //DEC A for binary down counter
JNZ BACK
HERE: SJMP HERE
ORG 00H
SJMP 30H
ORG 30H
MOV A, #00H
BACK: ACALL DELAY
ADD A, #01H //ADD A, #99H for BCD up counter,
DA A
JNZ BACK
HERE: SJMP HERE
VIVA QUESTIONS
Y=A’BC+AB’C+ABC’
ORG 0000H
LJMP 8000H
ORG 8000H
SETB 00H
CLR 01H
SETB 02H
MOV C,01H
ANL C,02H
ANL C,/00H
MOV 03H,C
MOV C,00H
ANL C,/01H
ANL C,02H
MOV 04H,C
MOV C,00H
ANL C,01H
ANL C,/02H
ORL C,04H
ORL C,03H
MOV 08H,C
HERE: SJMP HERE
END
21H 0F 0E 0D 0C 0B 0A 09 08
20H 07 06 05 04 03 02 01 00
C B A
Results:
Mem.Loc Result
D:21H
D:21H
LOGICAL INSTRUCTIONS
Algorithm:
1. Point to the data RAM register 20h and store the condition x.
2. Point to 21h and 22h and move the first number to A register.
3. Compare the contents of r1 and perform the operations accordingly.
4. The result will be stored in 23H register.
RESULT:
1)Before Execution: D:020H =00, 21=0f, 22 = 12
After Execution D:023H = 02
2)Before Execution: D:020H =01, 21=0f, 22 = 12
After Execution D:023H = 1F
3)Before Execution: D:020H =02, 21=0f, 22 = 12
After Execution D:023H = 1D
4)Before Execution: D:020H =34, 21=0f, 22 = 12
After Execution D:023H = 00
The above program can also be written as shown below (using indirect addressing)
ORG 0000H
SJMP 30H
ORG 30H
MOV R0,#20h
MOV A,@R0 //ON CHIP DATA RAM-DONOT USE MOVX
MOV R1,A //X IN R1
INC R0
MOV A,@R0 //A -NUM1
INC R0 // R0 POINTS TO NUM2
CJNE R1,#0,CKOR
ANL A, @R0
SJMP END1
CKOR:CJNE R1,#01,CKXOR
ORL A, @R0
SJMP END1
CKXOR:CJNE R1,#02,OTHER
XRL A, @R0
SJMP END1
OTHER: CLR A
END1:INC R0
MOV @R0,A //STORE RESULT
HERE:SJMP HERE
END
19. Boolean variable instructions are also called as bit level logical instructions
3 eight bit numbers X, NUM1 & NUM2 are stored in internal data RAM locations 20h, 21h &
22H respectively.
Write an ALP to compute the following.
IF X=0; THEN LSB OF NUM1 (AND) LSB OF NUM2,
IF X=1; THEN MSB OF NUM1 (OR)MSB OF NUM2 ,
IF X=2; THEN COMPLEMENT MSB OF NUM1
STORE THE BIT RESULT IN RES, WHERE RES IS MSB OF 23H LOCATION
ORG 00H
SJMP 30h
ORG 30h
MOV R0,20H //R0-X
CJNE R0,#0,CK1
MOV C,08H //LSB OF NUM1 (21H) - BIT ADDRESS -08
ANL C,10H //LSB OF NUM2 (22H) - BIT ADDRESS -10
SJMP LAST
CK1:CJNE R0,#1,CK2
MOV C,0FH //MSB OF NUM1 (21H) - BIT ADDRESS -0F
ANL C,17H //MSB OF NUM2 (22H) - BIT ADDRESS -17
SJMP LAST
CK2:CJNE R0,#2,CK3
CPL 0FH
MOV C,0FH //MSB OF NUM1 (21H) - BIT ADDRESS -0F
SJMP LAST
CK3:CLR C
LAST:MOV 1FH,C //RES IS MSB OF 23H LOCATION -1FH
HERE:SJMP HERE
END
RESULT: 20h = 00 => AND OF LSBs=1 (hence 80 in 23h location)
20h = 01 =>complement of MSB of 21h location. Hence 21h is changed to A1 and 23h
location has 80h
Before Execution After Execution
Algorithm:
1. Move the condition X (from 20h location) into R0 register.
2. If X=0; then move LSB bit of 21h to carry flag and ‘AND’ Carry flag with LSB bit of
22h. Goto step5
3. If X=1; then move MSB bit of 21h to carry flag and ‘OR’ Carry flag with MSB bit of
22h. Goto step5
4. If X=0; then complement MSB bit of 21h and move it to carry flag. Goto step5
5. Store Carry flag at MSB bit of 23h location.
VIVA QUESTIONS
20. Write an ALP to demonstrate call and return instruction using a program to find
factorial of a number.
VIVA QUESTIONS
ORG 0000H
SJMP 30h
ORG 30h
MOV DPTR,#40H //2-digit decimal number to be converted is given in data memory
40h
MOVX A, @DPTR
ANL A, #0F0H //obtain upper decimal digit
SWAP A //bring to the units place
MOV B,#0AH //MULTIPLY tens digit with #0A-toget tens in hex
MUL AB
MOV R1,A //temporarily store the converted tens value
MOVX A,@DPTR //get the decimal number again
ANL A,#0FH //obtain the units digit
ADD A,R1 //add to the converted tens value
INC DPTR //increment data address
MOVX @DPTR,A //converted hexadecimal number in next location
HERE:SJMP HERE
END
Algorithm
1. Move the decimal data to be converted from external memory 40h to accumulator.
2. AND A reg with 0f0h and obtain the upper MSB of the decimal digit and swap the LSB
and MSB of accumulator to bring the same to units place.
3. Move 0ah to B register and multiply with A reg to convert to hex value, store the
converted tens value in r1
4. Get the LSB of the decimal number and add to the converted tens value
5. point to the next memory location and store the result (hexadecimal).
Algorithm
1. Move the hex data to be converted to accumulator.
2. Move 10 to B register and divide with A reg to convert to ascii value
3. Store the converted LSB value in r7
4. Repeat the step 2 to obtain the converted MSB value
5. Store the same in r6
ORG 0000H
SJMP 30h
ORG 30h
MOV R1,#50H
MOV A,@R1 //get BCD data byte from RAM location 50h
MOV R2,A //Store in R2
ANL A,#0FH //Get the lower nibble
ORL A,#30H //Add/or with 30h i.e., 0-9 converted to 30-39h
INC R1
MOV @R1,A //Store the lower digit's ASCII code
MOV A,R2 //Get back the number
SWAP A //Swap nibbles in A
ANL A,#0FH //Get the upper BCD digit
ORL A,#30H //Convert to ASCII
INC R1
MOV @R1,A //Store the upper digit's ASCII code
here: sjmp here
END
Algorithm :
//Converts the BCD byte in A into two ASCII characters.
1. Move the BCD data to be converted to accumulator.
2. Get the lower nibble(BCD digit) & ADD (or ORL) with 30h
3. Store the converted ASCII value
4. Get the higher nibble(tens BCD digit) & ADD (or ORL) with 30h
5. Store the converted ASCII value
ORG 0000H
SJMP 30h
ORG 30h
MOV R1,#50H
MOV A,@R1 //get hexadecimal data byte from RAM location 50h
MOV R2,A //Store in R2
ANL A,#0FH //Get the lower nibble
ACALL ASCII //Convert to ASCII
INC R1
MOV @R1,A //Store the lower digit's ASCII code
MOV A,R2 //Get back the number
SWAP A //Swap nibbles in A
ANL A,#0FH //Get the upper BCD digit
ACALL ASCII
INC R1
MOV @R1,A //Store the upper digit's ASCII code
HERE: SJMP HERE
ASCII:MOV R4,A //Store a
CLR C
SUBB A,#0AH //Check if digit >=0A
MOV A,R4
JNC SKIP
ADD A,#07H //Add 07 if >09
SKIP:ADD A,#30H //Else add only 30h for 0-9
RET
END
RESULT: The BCD code 2C at D:0050h is converted to 2 ASCII codes-43h(for 0B) & 32h
(for 02) Another Example-BA
Algorithm :
//Converts the hexadecimal byte in A into two ASCII characters.
1. Move the hexadecimal data to be converted to accumulator.
2. Get the lower nibble & call ASCII routine
3. Store the converted ASCII value
4. Get the higher nibble & call ASCII routine
5. Store the converted ASCII value
ASCII subroutine
1. If digit greater than 09,(for A-F) add 07h & 30h
2. Else (i.e., for 0-9) add only 30h
3. return
Dept., of Electronics & Communication 37 S JBIT, B’lore
IV Sem E&C Microcontrollers lab[18ECL47]
Note: For this program the input data should be only in the range 30h-39h & 41h to 46h.
Algorithm :
//Converts the ASCII characters into hexadecimal number.
1. Move the ASCII character to be converted to accumulator.
2. If character is greater than 41h,(for A-F), then subtract 07h & 30h
3. Else (i.e., for 0-9) subtract only 30h
4. Store the converted hexadecimal number.
ORG 0000H
LJMP 8000h
ORG 8000h
MOV R1, #50H
MOV A,@R1
MOV R2, A
ANL A, #0FH
ORL A, #30H
INC R1
MOV @R1, A
MOV A, R2
SWAP A
ANL A, #0FH
ORL A, #30H
INC R1
MOV @R1, A
HERE: SJMP HERE
END
BCD ASCII
0 30
1 31
2 32
3 33
4 34
5 35
6 36
7 37
8 38
9 39
EXAMPLE:
D:50H 65
D:51H 35
D:52H 36
Results:
27. Write an ALP to convert 8 bit binary (hex) to its equivalent ASCII.
ORG 0000H
SJMP 30h Binar Equivalent
ORG 30h y ASCII
MOV R1,#50H 0 30
MOV A,@R1 1 31
MOV R2, A 2 32
ANL A, #0FH 3 33
ACALL ASCII
4 34
INC R1
5 35
MOV @R1, A
6 36
MOV A, R2
7 37
SWAP A
ANL A, #0FH 8 38
ACALL ASCII 9 39
INC R1 A 41
MOV @R1, A B 42
HERE: SJMP HERE C 43
D 44
ASCII: MOV R4, A E 45
CLR C F 46
SUBB A, #0AH
MOV A, R4
JC SKIP
ADD A, #07H
SKIP: ADD A, #30H
RET
END
D:50H
Results
D:51H
D:52H
ORG 0000H
SJMP 30h
ORG 30h
MOV R1,#50H
MOV A,@R1 //get ASCII byte from RAM location 50h
CLR C
SUBB A,#41H
MOV A,@R1
JC SKIP
SUBB A,#07H
SKIP: CLR C
SUBB A,#30H
INC R1
MOV @R1, A
HERE: SJMP HERE
END
Note: this program works for ASCII to BCD conversion, if the input data is between 30-39
D:50H D:51H
Dept., of Electronics & Communication 41 S JBIT, B’lore
IV Sem E&C Microcontrollers lab[18ECL47]
37 07
42 0B
D:50H D:51H
37 07
42 0B
D:50H D:51H
37 07
39 09
D:50H D:51H
37 07
42 0B
D:50H D:51H
37 07
42 0B
ORG 0000H
LJMP 8000h
ORG 8000h
MOV DPTR,#9000H
MOVX A,@DPTR
MOV B, #10
DIV AB
Dept., of Electronics & Communication 42 S JBIT, B’lore
IV Sem E&C Microcontrollers lab[18ECL47]
XCH A, B
MOV r2, A
XCH A, B
MOV B, #10
DIV AB
INC DPTR
XCH A, B
SWAP A
ADD A, R2
MOVX @DPTR, A
INC DPTR
MOV A, B
MOVX @DPTR, A
ORG 0000H
LJMP 8000h
ORG 8000h
MOV DPTR, #40H
MOVX A, @DPTR
ANL A, #0F0H
SWAP A
MOV B, #0AH
MUL AB
MOV R1, A
MOVX A,@DPTR
ANL A, #0FH
ADD A, R1
INC DPTR
MOVX @DPTR, A
HERE: SJMP HERE
END
VIVA QUESTIONS
ORG 0H
SJMP 30H
ORG 30H
MOV TMOD,#20H //timer 1; mode 2
MOV TH1,#-3 //-3=FD loaded into TH1 for 9600 baud, 11.0592MHz.
MOV SCON,#50H //8-bit, 1 stop bit, REN enabled
SETB TR1 //Start timer 1
AGAIN:MOV A,#’y’ //transfer “y”
ACALL TRANS
MOV A,#’E’ //transfer “E”
ACALL TRANS
AGAIN1:SJMP AGAIN1
TRANS: MOV SBUF,A //load SBUF
HERE:JNB TI,HERE //Wait for last bit to transfer
CLR TI //get ready for next byte
RET
END
RESULT: yE is printed on the serial window each time the program is executed.
Theory: In serial transmission as opposed to parallel transmission, one bit at a time is
transmitted. In serial asynchronous transmission, the data consists of a Start bit (high), followed
by 8 bits of data to be transmitted and finally the stop bit. The byte character to be transmitted is
written into the SBUF register. It transmits the start bit. The 8-bit character is transferred one bit
at a time. The stop bit is transferred. After the transmission, the TI flag = 1 indicating the
completion of transmission. Hence in the subroutine wait until TI is set. Later clear the TI flag
and continue with transmission of the next byte by writing into the SBUF register. (The
program can also be written in interrupt mode). The speed of the serial transmission is set by the
baud rate which is done with the help of timer 1. (Refer Ayala). Timer1 must be programmed in
mode 2 (that is, 8-bit, auto reloads).
Baud rate Calculation: Crystal freq/ (12*32) = (11.0592MHz)/(12*32) = 28800.
Serial communication circuitry divides the machine cycle frequency (11.0592MHz)/(12) by 32
before it is being used by the timer to set the baud rate.
To get 9600, 28800/3 is obtained by loading timer1 with -3 (i.e., FF – 3 = FD) for further clock
division. For 2400 baud rate, 28800/12 => -12 = F4 in TH1.
Algorithm:
1. Initialize timer 1 to operate in mode 2 by loading TMOD register.
2. load TH1 with -3 to obtain 9600 baud.
3. Initialize the asynchronous serial communication transmission (SCON) register.
4. Start timer1 to generate the baud rate clock.
5. Transmit the characters “y” & “E” by writing into the SBUF register and waiting for the
TI flag.
Dept., of Electronics & Communication 46 S JBIT, B’lore
IV Sem E&C Microcontrollers lab[18ECL47]
32. Generate a 1second delay continuously using the on chip timer in interrupt mode.
ORG 0H //Reset Vector
SJMP 30H
ORG 0BH //TF0 vector
SJMP ISR
ORG 30H
MOV A,#00
MOV R0,#0
MOV R1,#0
MOV TMOD,#02H //00000010-Run timer0 in mode 2
MOV TH0,#118 //Set up timer 0 to overflow in 0.05msec
MOV IE,#82H //%10000010 – Enable timer0 interrupt
SETB TCON.4 //Start the timer0
HERE:SJMP HERE
ISR: CLR TCON.4 //Disable timer0
INC r1 //r1*r2 = 100*200 = 20000 * 0.05msec = 1sec
CJNE R1,#100,SKIP
MOV R1,#00
INC R0
CJNE R0,#200,SKIP
MOV R0,#00H
INC A
SKIP: SETB TCON.4 //Enable Timer
RETI //Return from interrupt subroutine
END
RESULT: Accumulator A is incremented in binary from 00, 01,02…09,0A, 0B, …, 0F, 10, 11,
…FF every 1 second (for 33MHz clock setting & every 3 seconds for 11.0598MHz)
Algorithm:
1. Set up timer0 in mode 2 operation
2. Load TH1 with 118 to generate an interrupt every 0.05msec.
3. Reset registers a, r1 & r0.
4. Repeat step 4 continuously
5. On interrupt; ISR at 000B loaction goes to step 6
6. disable timer0
7. Update r1 & r0
8. Check if 20000 interrupts (=1 sec) over. Yes –increment accumulator a.
9. enable timer & return from ISR.
Timerdelay = 12*(257-delay)/frequency
Timerdelay=0.05msec
Delay=256-((timerdelay * frequency)/12) =256-(0.05*10 -3 * 33*106)/12
=256-137.5 =118.5 //loaded in TH0
To get 1sec delay
1/0.05msec = 200*100 in the ISR
(assuming 33 MHZ crystal frequency. For 11 MHz, the calculations change).
ORG 0000H
LJMP 8000H
ORG 0BH
LJMP ISR
ORG 8000H
MOV A, #00H
MOV R0, #00H
MOV R1, #00H
MOV TMOD, #02H
MOV TH0, #118
MOV IE, #82H
SETB TCON.4
HERE: SJMP HERE
ISR: CLR TCON.4
INC R1
CJNE R1, #100, SKIP
MOV R1, #00
INC R0
CJNE R0, #200, SKIP
MOV R0, #00H
INC A
SKIP: SETB TCON.4
RETI
END
34. Write an ALP to transfer the message “WELCOME” using serial port with a baud
rate of 9600.
ORG 0000H
MOV TMOD, #20H
MOV TH1, #0FDH (count for given baud rate)
MOV SCON, #50H
SETB TR1
MOV DPTR, #MESSG
NEXT: CLR A
MOVC A,@A+DPTR
JZ HERE
ACALL SEND
INC DPTR
SJMP NEXT
HERE: SJMP HERE
MESSG: DB “WELCOME”, 0
RESULT:
Note: Check the result in serial window.
Change the baud rate and the message to note the second result.
VIVA QUESTIONS
1. Which devices are specifically being used for converting serial to parallel and from
parallel to serial respectively?
Registers
2. What is the difference between UART and USART communication?
One uses asynchronous means of communication and the other uses asynchronous and
synchronous means of communication
3. Which of the following best describes the use of framing in asynchronous means of
communication?
It tells us about the start and stops of the data to be transmitted or received
4. Which of the following is the logic level understood by the micro-controller/micro-
processor?
TTL logic level
5. What is a null modem connection?
The RxD of one is the TxD for the other
6. Which of the following best states the reason that why baud rate is mentioned in serial
communication?
To make the two devices compatible with each other, so that the transmission becomes
easy and error free
PART-B: INTERFACING:
1. Interface a simple toggle switch to 8051 and write an ALP to generate an
interrupt which switches on an LED (i) continuously as long as switch is on
and (ii) only once for a small time when the switch is turned on.
a).LED ON/OFF
ORG 000H
CLR A
MOV P1,0FFH
READSW: MOV A,P1 // Moving the port value to Accumulator.
;MOV A,R0
XRL A,#81H
JZ NXT // If switch 1 is OFF then jump to NXT to check if switch 2 is ON
CLR P0.0 // Turn ON LED because Switch 1 is ON
//MOV P0,#00H
CLR A
SJMP READSW // Read switch status again.
NXT:
SETB P0.0 // Turning OFF LED because Switch 2 is ON
//MOV P0,#0FFH
SJMP READSW // Jumping to READSW to read status of switch 1 again.
END
b) LED ON/OFF
ORG 000H
CLR A
MOV P1,0FFH
READSW: MOV A,P1 // Moving the port value to Accumulator.
;MOV A,R0
XRL A,#81H
JZ NXT // If switch 1 is OFF then jump to NXT to check if switch 2 is ON
//CLR P0.0 // Turn ON LED because Switch 1 is ON
MOV P0,#00H
CLR A
SJMP READSW // Read switch status again.
NXT:
//SETB P0.0 // Turning OFF LED because Switch 2 is ON
MOV P0,#0FFH
SJMP READSW // Jumping to READSW to read status of switch 1 again.
END
c) BLINK LED CONTINOUSLY
ORG 000H
CLR A
MOV P1,0FFH
READSW: MOV A,P1 // Moving the port value to Accumulator.
;MOV A,R0
XRL A,#81H
;CLR P0.0
JZ NXT // If switch 1 is OFF then jump to NXT to check if switch 2 is ON
CLR P0.0 // Turn ON LED because Switch 1 is ON
CLR A
SJMP READSW // Read switch status again.
NXT:
//ACALL DELAY
SETB P0.0 // Turning OFF LED because Switch 2 is ON
ACALL DELAY
CLR P0.0
//SJMP READSW // Jumping to READSW to read status of switch 1 again.
DELAY:
MOV R7,#0C8H
MOV TMOD,#01H
L2: MOV TH0,#0DBH
MOV TL0,#0FFH
SETB TCON.4
L3: JNB TCON.5,L3
CLR TCON.4
CLR TCON.5
DJNZ R7,L2
RET
END
ORG 000H
CLR A
MOV P1,0FFH
READSW: MOV A,P1 // Moving the port value to Accumulator.
;MOV A,R0
XRL A,#81H
;CLR P0.0
JZ NXT // If switch 1 is OFF then jump to NXT to check if switch 2 is ON
CLR P0.0 // Turn ON LED because Switch 1 is ON
CLR A
SJMP READSW // Read switch status again.
NXT:
//ACALL DELAY
SETB P0.0 // Turning OFF LED because Switch 2 is ON
ACALL DELAY
CLR P0.0
RET
//SJMP READSW // Jumping to READSW to read status of switch 1 again.
DELAY:
MOV R7,#0FFH
MOV TMOD,#01H
L2: MOV TH0,#0DBH
MOV TL0,#0FFH
SETB TCON.4
L3: JNB TCON.5,L3
CLR TCON.4
CLR TCON.5
DJNZ R7,L2
RET
END
2. Write a C program to (i) transmit and (ii) to receive a set of characters serially
by interfacing 8051 to a terminal.
#include <REG51.h>
#include <stdio.h>
#include <intrins.h>
//#include "lcd.h"
main()
{
char chr; /* variable to hold characters in */
SCON = 0x52; /* mode 1, 8-bit uart, enable receiver */
TMOD = 0x20; /* timer 1, mode 2, 8-bit reload */
TH1 = 0xFD; /* reload value for 2400 baud *//* Setting TR1 will start the timer, and
serial communications */
TR1 = 1; /** Set the Transmit Interrupt flag to send the character in* the serial
buffer, clearing it for use by the program.*/
TI = 1;
while (1==1)
{ /* read the next character from the serial port */
chr = getchar(); /* send it back to the original sender */
//putchar("\n");
printf("\n");
putchar(chr);
//putchar("\n");
printf("\n"); //Print the digital value
//sendCharacter (chr);}
}
}
//SIRI 02.09//
************************************************************************
ORG 0x00
LJMP 0x30
ORG 0x13 /* External inerrupt1 */
MOV R4,#0x00
LCALL DISPLAY
RETI /* Return from inerrupt1 */
ORG 0x03 /* External inerrupt0 */
MOV R4,#0xFF
LCALL DISPLAY
RETI /* Return from inerrupt0 */
ORG 0x30
LCALL lcdstatus /* Read LCD busy flag and wait */
LCALL lcdinit /* Initialize the LCD */
MOV IE,#0x85
MOV R4,#0x00
MOV P0,#0x00 /* PO & p1 as output */
MOV P1,#0x00
ACALL DISPLAY
LEDs (lights), interfaced with 8051 microcontroller, can be used to display binary numbers or
on/off states while Seven Segment Displays (SSD) can display digits but that's not enough.
What if you wanted to display a proper message consisting of numbers, letters, characters,
symbols e.t.c.? That's where LCD Screens are better. LCDs make it convenient to display
anything to the user.
LCD
Stands for Liquid Crystal Display and is definitely an output device. It comes in many popular
shapes and sizes but here is the one that you will most probably face at the beginner's level.
COMMON LCD
It is basically called 16x2 LCD because it has sixteen columns and two rows thus it can
display thirty-two (32) characters at a time (sixteen characters in each row). There are sixteen
hardware pins as shown.
1. Control Register Used for instructing LCD on what to do next. It's like talking to your
LCD using this register.
2. Data Register Used for displaying data on LCD.
Control Register is used for sending commands to LCD and when it's ready, only then you can
use Data Register to display your data on the LCD. In other words, first you have to talk to your
LCD (by sending commands) about what you want it to do and then send all the useful data for
display.
PINS
The RS (Register Select) control pin is used to select either command or data register as
described in the pin configuration table. Once selected, all data sent on the 8-bit data lines will
be latched to that register.
The R/W (Read/Write) control pin is used to determine the flow of data. You have to select
Write Mode when you're sending something to the LCD (data or command)
Read Mode when you're reading from the LCD
The E (Enable) control pin acts as a guard to allow exchange of data. This pin is very important
in this whole process and must be handled precisely. The following animation explains its
function
COMMANDS
LCDs have some useful handful of commands that can be used for different operations. You can
check a comprehensive list of commands here. commands required to initialize an LCD because
they are fairly sufficient to get things done and they are as follows
HARDWARE CONNECTIONS
Here is the optimized version of LCD hardware Connections. It takes the minimum possible
time and works most of the time
In the Download Package below, it is included the Assembly Language Code as well as the C
language Code for the very same program. The LCD program code in a stepwise fashion. Let's
get started.
To differentiate between command and data , two separate functions. As you can see,
the only difference is that of using RS pin according to requirement.
The delay function is a general one and can use it safely at this stage but remember that
it's not accurate.
Delay Function
To send a command to LCD, use the lcdcmd function with the command as input.
To send data to LCD, use the lcddata function with the data as input.
The LCD has to be initialized using the appropriate commands as it can be seen in the main
function. Once initialized, you can send data for display. It is very important to note that the
LCD accepts only ASCII characters which means that every character you send for display must
be in ASCII. It can be checked here for a complete list of ASCII characters and their
corresponding values.
There are many ways in which you can send an ASCII character to LCD. For instance, you can
display A in the following ways
x='A' lcddata ( x )
x=65 //decimal value lcddata ( x )
x=0x41 //hexa decimal value lcd data ( x )
or directly as lcddata ( 'A' )
As discussed above, the enable pin (e) is given a high-to-low transition for data transfer.
Here is the Proteus Simulation Diagram for LCD interface used a BUS in this simulation for
simplicity.
Proteus Simulation
16×2 LCD module is a very common type of LCD module that is used in 8051 based embedded
projects. It consists of 16 rows and 2 columns of 5×7 or 5×8 LCD dot matrices. The module
were are talking about here is type number JHD162A which is a very popular one. It is available
in a 16 pin package with back light, contrast adjustment function and each dot matrix has 5×8
dot resolution. The pin numbers, their name and corresponding functions are shown in the table
below.
VEE pin is meant for adjusting the contrast of the LCD display and the contrast can be adjusted
by varying the voltage at this pin. This is done by connecting one end of a POT to the Vcc (5V),
other end to the Ground and connecting the center terminal (wiper) of of the POT to the VEE
pin.
The JHD162A has two built in registers namely data register and command register. Data
register is for placing the data to be displayed, and the command register is to place the
commands. The 16×2 LCD module has a set of commands each meant for doing a particular job
with the display. High logic at the RS pin will select the data register and Low logic at the RS
pin will select the command register. If we make the RS pin high and the put a data in the 8 bit
data line (DB0 to DB7), the LCD module will recognize it as a data to be displayed. If we make
RS pin low and put a data on the data line, the module will recognize it as a command.
R/W pin is meant for selecting between read and write modes. High level at this pin enables
read mode and low level at this pin enables write mode.
E pin is for enabling the module. A high to low transition at this pin will enable the module.
DB0 to DB7 are the data pins. The data to be displayed and the command instructions are
placed on these pins.
LED+ is the anode of the back light LED and this pin must be connected to Vcc through a
suitable series current limiting resistor. LED- is the cathode of the back light LED and this pin
must be connected to ground.
16×2 LCD module has a set of preset command instructions. Each command will make the
module to do a particular task. The commonly used commands and their function are given in
the table below.
Command Function
0F LCD ON, Cursor ON, Cursor Blinking ON
01 Clear screen
02 Return home
04 Decrement cursor
06 Increment cursor
0E Display ON ,Cursor blinking OFF
80 Force cursor to the beginning of 1st line
C0 Force cursor to the beginning of 2nd line
38 Use 2 lines and 5×7 matrix
83 Cursor line 1 position 3
3C Activate second line
08 Display OFF, Cursor OFF
C1 Jump to second line, position1
OC Display ON, Cursor OFF
C1 Jump to second line, position1
C2 Jump to second line, position2
LCD initialization.
The steps that has to be done for initializing the LCD display is given below and these steps are
common for almost all applications.
The steps for sending data to the LCD module is given below. I have already said that the LCD
module has pins namely RS, R/W and E. It is the logic state of these pins that make the module
to determine whether a given data input is a command or data to be displayed.
Circuit diagram.
The circuit diagram given above shows how to interface a 16×2 LCD module with AT89S1
microcontroller. Capacitor C3, resistor R3 and push button switch S1 forms the reset circuitry.
Ceramic capacitors C1,C2 and crystal X1 is related to the clock circuitry which produces the
system clock frequency. P1.0 to P1.7 pins of the microcontroller is connected to the DB0 to
DB7 pins of the module respectively and through this route the data goes to the LCD module.
P3.3, P3.4 and P3.5 are connected to the E, R/W, RS pins of the microcontroller and through
Dept., of Electronics & Communication 69 S JBIT, B’lore
IV Sem E&C Microcontrollers lab[18ECL47]
this route the control signals are transffered to the LCD module. Resistor R1 limits the current
through the back light LED and so do the back light intensity. POT R2 is used for adjusting the
contrast of the display. Program for interfacing LCD to 8051 microcontroller is shown below.
#define RS P3.7 *LCD Register select (0)- Instruction reg & (1) Data Reg*/
#define RW P3.6 /*Read (1) or Write (0)*/
#define E P3.5 /*LCD Enable*/
org 0h
sjmp 30h
org 30h
anl P3,#1fh /*Make P3 & P2 as output*/
anl P2,#00h
acall status /*Routine to read Busy Flag of LCD*/
acallinit /*Routine initialize the LCD*/
mov dptr,#msg /*Point to message to be displayed*/
disp: clr a /*clear acc*/
movca,@a+dptr /*Get the character to be displayed*/
jz here /*if it is last char terminate the routine*/
acalldat /*Routine to write into LCD display RAM*/
incdptr /*increment the pointer*/
mov a,dpl
cjne a,#10h,disp /*check for first line completion*/
mov a,#0c0h /*Select the second line of LCD*/
acall cmd
sjmp disp /* display again*/
here: sjmp $
mov P2,a /*move Command DATA into P2 , i.e. LCD Data BUS*/
nop
setbE /*Enable the LCD by making high */
nop /*1-Cycle Delay for enable pulse*/
clr E /*Disable the LCD*/
mov r2,#03h /*1500usec(approx) delay for data settling*/
acall delay
acall status /*Read the Busy flag of LCD & wait if busy*/
ret
org 100h
msg: db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',00h
end
Dept., of Electronics & Communication 71 S JBIT, B’lore
IV Sem E&C Microcontrollers lab[18ECL47]
Stepper motor.
Stepper motor is a brush less motor which converts electrical pulses into mechanical rotation.
As the name indicates it rotates in steps according to the input pulses. A stepper motor usually
have a number of field coils (phases) and a toothed rotor. The step size of the motor is
determined by the number of phases and the number of teeth on the rotor. Step size is the
angular displacement of the rotor in one step. If a stepper motor has 4 phases and 50 teeth, it
takes 50×4=200 steps to make one complete rotation. So step angle will be 360/200=1.8°.
The stepper motor we are using has 4 poles and a 1/64 reduction gear mechanism for increasing
torque. The step angle of the motor is 5.64°. But when considering the reduction gear, the step
angle of the output shaft is 5.64/64°. The internal schematic of the stepper motor is given below.
The stepper motor is rotated by switching individual phases ON for a given time one by one.
The sequence is given in the graph below.
Circuit diagram.
The circuit diagram for interfacing stepper motor to 8051 is shown above. P1.0, P1.1,
P1.2 and P1.3 pins are used for controlling the phases A1, A2, A3 and A4 of the stepper motor
respectively. ULN2003 is used for driving the individual phases of the stepper motor.
ULN2003 is a darlington transistor array used for driving high current loads such as relays and
motors. ULN2003 has 8 individual channels each with 1A capacity. The channels can be
paralleled to increase the current capacity. Each channels are fitted with individual freewheeling
diodes. The ULN2003 is operated in current sinking mode. Each channel is activated by giving
a logic LOW at the corresponding input. For example if we make pin 1 of ULN2003 LOW,
phase A1 of the stepper motor gets switched ON.
Program.
*****************************************************************************
/*Lcd Monitor Routines*/
#define lcdinit 0x0E267
#define lcdstatus 0x0E2D3
#define lcdstr 0x0E39E
#define gotoxy 0x0E380
ORG 0x00
LJMP 0x30
ORG 0x13 /* External inerrupt1 */
MOV R4,#0x00
RETI /* Return from inerrupt1 */
ORG 0x03 /* External inerrupt0 */
MOV R4,#0xFF
RETI /* Return from inerrupt0 */
ORG 0x30
LCALL lcdstatus /* Read LCD busy flag and wait */
LCALL lcdinit /* Initialize the LCD */
MOV IE,#0x85
MOV R4,#0x00
MOV P0,#0x00 /* PO as output */
-> This is a Sample Program to demonstrate the working of Stepper Motor Interface.
-> Plug in 4pin polarised connector of the motor to interface & 3 pin connector of the motor
to the 3 pin connector of interface marked as "WHT BLK".
-> Connect the 3 pin female connector of the stepper motor power supply to the connector on
the interface marked as "GND +5/12V".
-> Connect J1connector of Stepper Motor Interface & J7connector of ESA MCB 51 with the
26pin
FRC connector cable given by ESA.
-> The direction of the motor will be displayed on LCD of ESA MCB 51 Board.
3. ADC 0804.
ADC0804 pinout
The voltage at Vref/2 (pin9) of ADC0804 can be externally adjusted to convert smaller input
voltage spans to full 8 bit resolution. Vref/2 (pin9) left open means input voltage span is 0-5V
and step size is 5/255=19.6V. Have a look at the table below for different Vref/2 voltages and
corresponding analogue input voltage spans.
Vref/2 (pin9) (volts) Input voltage span (volts) Step size (mV)
Left open 0–5 5/255 = 19.6
2 0–4 4/255 = 15.69
1.5 0–3 3/255 = 11.76
1.28 0 – 2.56 2.56/255 = 10.04
1.0 0–2 2/255 = 7.84
0.5 0–1 1/255 = 3.92
Circuit diagram.
The figure above shows the schematic for interfacing ADC0804 to 8051. The circuit initiates
the ADC to convert a given analogue input , then accepts the corresponding digital data and
displays it on the LED array connected at P0. For example, if the analogue input voltage Vin is
5V then all LEDs will glow indicating 11111111 in binary which is the equivalent of 255 in
decimal. AT89s51 is the microcontroller used here. Data out pins (D0 to D7) of the ADC0804
Dept., of Electronics & Communication 77 S JBIT, B’lore
IV Sem E&C Microcontrollers lab[18ECL47]
are connected to the port pins P1.0 to P1.7 respectively. LEDs D1 to D8 are connected to the
port pins P0.0 to P0.7 respectively. Resistors R1 to R8 are current limiting resistors. In simple
words P1 of the microcontroller is the input port and P0 is the output port. Control signals for
the ADC (INTR, WR, RD and CS) are available at port pins P3.4 to P3.7 respectively. Resistor
R9 and capacitor C1 are associated with the internal clock circuitry of the ADC. Preset resistor
R10 forms a voltage divider which can be used to apply a particular input analogue voltage to
the ADC. Push button S1, resistor R11 and capacitor C4 forms a debouncing reset mechanism.
Crystal X1 and capacitors C2,C3 are associated with the clock circuitry of the microcontroller.
Program.
Write ALP to interface ADC-0804 and convert an analog input connected to it.
//SIRI 02.09//
*************************************************************************
ORG 0x00
SJMP 0x30
ORG 0x30
MOV P2,#0xFF
MOV R3,#0x00
NXTCHANL: LCALL CONVERT
LCALL DISPLAY
LCALL UPDATE
LJMP NXTCHANL
MOV A,#0x20
ORL A,R3
MOV P0,A
MOV A,#0x00
ORL A,R3
MOV P0,A
MOV A,R3
CLR C
DA A
MOV R4,A
LCALL LL1
Dept., of Electronics & Communication 79 S JBIT, B’lore
IV Sem E&C Microcontrollers lab[18ECL47]
MOV DPTR,#DIGITAL
CLR PSW.5
LCALL DISPSTR
POP 0xE0
MOV R4,A
LCALL LL1
MOV DPTR,#CR
LCALL DISPSTR
RET
UPDATE:
S2: LCALL GETCH /* get the key */
LCALL PUTCH /* display the pressed key */
CJNE A,#0x2C,S1 /* check whether it is ',' */
SJMP CHINR
UP: DEC R3
RET
DOWN: INC R3
RET
-> This is a Sample Program to demonstrate the working of 16 Channel ADC Interface.
-> Connect the external DC power supplies +12V & GND to the pins marked as +12V & GND
-> Connect J1connector of 16 Channel ADC Interface & J7connector of ESA MCB 51 with the
26pin FRC connector cable given by ESA.
-> The euqivalent digital value for the applyed analog input will be displayed on
Serial Window of KEIL or HyperTerminal of PC as shown below:
NOTE: Dont apply input at screw( named as GND) terminals on the interface.
VIVA QUESTIONS
1. How many rows and columns are present in a 16*2 alphanumeric LCD?
rows=2, columns=16
2. How many data lines are there in a 16*2 alphanumeric LCD?
8
3. For writing commands on an LCD, RS bit is
Reset
4. Mention the steps to detect the key in a 4*4 keyboard matrix about the key that is being
pressed?
Masking of bits, ensuring that initially, all keys are open and checking that whether the key is
actually pressed or not
5. To detect that in which column, the key is placed?
We can mask the bits and then check it , we can rotate the bits and then check that particular bit
which is set or reset(according to the particular condition)
6. To identify that which key is being pressed, we need to
Ground pins of the port one at a time
7. Why two pins for ground are available in ADC0804?
For controlling the analog and the digital pins of the controller. There are two pins, that are
available for ground in the ADC0804. one is for analog and the other is for digital pins
8. Step size is selected by which two bits?
Vref/2. Step size is selected by the Vref/2 bit as its value is Vref/256.
9. INTR, WR signal is an input/output signal pin?
One is input and the other is output. INTR pin tells about the end of the conversion (output) and
WR pin tells us to start the conversion (input).
10. Why MOVX instruction is being used to access the ports of the 8255?
8255 is used to access the memory mapped I/O. MOVX instruction is used to access the external
memory, so it is used to access the memory mapped I/O.
Viva Questions
S J B Institute of Technology
No. 67, BGS Health & Education City, Dr. VishnuvardhanRoadKengeri,Bengaluru -560060
Department of Electronics & Communication Engg.
COURSE EXIT SURVEY:2019-20
Signature of Student
ensure my own safety, and that of my fellow students, instructors, and staff members. I will
cooperate to the fullest extent to maintain a safe laboratory environment. I will follow all
written and oral instructions provided by my instructor. I am aware any violation of these rules
may result in not being allowed to participate in the laboratory experiment, receiving a failing
Student Name:
USN:
Section: Batch: