Microprocessor Observation 6,7,8,9,10
Microprocessor Observation 6,7,8,9,10
AIM:
To interface subroutine using assembly language program
PROGRAM:
start:
; scan row0
SETB P0.3 ; set row3
CLR P0.0 ; clear row0
CALL colScan ; call column-scan subroutine
JB F0, finish ; | if F0 is set, jump to end of program
; | (because the pressed key was found and its number is in
R0)
; scan row1
SETB P0.0 ; set row0
CLR P0.1 ; clear row1
CALL colScan ; call column-scan subroutine
JB F0, finish ; | if F0 is set, jump to end of program
; | (because the pressed key was found and its number is in
R0)
; scan row2
SETB P0.1 ; set row1
CLR P0.2 ; clear row2
CALL colScan ; call column-scan subroutine
JB F0, finish ; | if F0 is set, jump to end of program
; | (because the pressed key was found and its number is in
R0)
; scan row3
SETB P0.2 ; set row2
CLR P0.3 ; clear row3
CALL colScan ; call column-scan subroutine
JB F0, finish ; | if F0 is set, jump to end of program
; | (because the pressed key was found and its number is in
R0)
finish:
JMP $ ; program execution arrives here when key is found - do
nothing
; column-scan subroutine
colScan:
JNB P0.4, gotKey ; if col0 is cleared - key found
INC R0 ; otherwise move to next key
JNB P0.5, gotKey ; if col1 is cleared - key found
INC R0 ; otherwise move to next key
JNB P0.6, gotKey ; if col2 is cleared - key found
INC R0 ; otherwise move to next key
RET ; return from subroutine - key not found
gotKey:
SETB F0 ; key found - set F0
RET ; and return from subroutine
Output:
RESULT:
Thus ALP- to implement subroutine concept was completed successfully.
EX NO: 7 ALP- INTERFACING MATRIX KEYBOARD
AIM:
To interface matrix keyboard using assembly language program.
ALGORITHM:
1. Start the program
2. Set a row and column list
3. Each and every press scan all rows and column
4. Make the row and column of the pressed key and others as one
5. Show the result in R0
6. Stop the program
PROGRAM:
MOV DPL, #LOW(LEDcodes) ; | put the low byte of the start address of the
; | 7-segment code table into DPL
CLR P3.4 ;|
CLR P3.3 ; | enable Display 0
again:
CALL setDirection ; set the motor's direction
MOV A, TL1 ; move timer 1 low byte to A
CJNE A, #10, skip ; if the number of revolutions is not 10 skip next
instruction
CALL clearTimer ; if the number of revolutions is 10, reset timer 1
skip:
MOVC A, @A+DPTR ; | get 7-segment code from code table - the
index
into the table is
; | decided by the value in A
; | (example: the data pointer points to the start of
the
; | table - if there are two revolutions, then A will
contain two,
; | therefore the second code in the table will be
copied to A)
setDirection:
PUSH ACC ; save value of A on stack
PUSH 20H ; save value of location 20H (first bit-addressable
needs to be reversed
JMP finish ; if they are the same, motor's direction does not
need to be changed
changeDir:
CLR P3.0 ;|
CLR P3.1 ; | stop motor
clearTimer:
CLR A ; reset revolution count in A to zero
CLR TR1 ; stop timer 1
MOV TL1, #0 ; reset timer 1 low byte to zero
SETB TR1 ; start timer 1
RET ; return from subroutine
LEDcodes: ; | this label points to the start address of the 7-segment code table which is
; | stored in program memory using the DB command below
OUTPUT:
RESULT:
Thus ALP –to interface matrix keyboard was executed successfully.
AIM:
To interface 7- Segment LED using assembly language program.
PROGRAM:
start:
SETB P3.3 ;|
SETB P3.4 ; | enable display 3
MOV P1, #11111001B ; put pattern for 1 on display
CALL delay
CLR P3.3 ; enable display 2
MOV P1, #10100100B ; put pattern for 2 on display
CALL delay
CLR P3.4 ;|
SETB P3.3 ; | enable display 1
MOV P1, #10110000B ; put pattern for 3 on display
CALL delay
CLR P3.3 ; enable display 0
MOV P1, #10011001B ; put pattern for 4 on display
CALL delay
JMP start ; jump back to start
; a crude delay
delay:
MOV R0, #200
DJNZ R0, $
RET
Output:
RESULT:
Thus ALP - to interface 7-Segment LED was executed successfully.
EX NO: 9 ALP-To generate square wave using Timer/Counter for different
Frequencies.
Aim:
To write ALP to generate square wave using Timer/Counter for different Frequencies.
1. Connect the 9 pin D typeconnector from the DAC module to the Mp/Mc kit.
2.Connect the 26-pin connector from the DAC module to Mp/Mc kit.
6.Execute it and measure the output voltage/waveform at the front panel of the DAC module.
7.Vary the digital count,execute the program and measure the output analog voltage.
8.Take number of reading and if required draw the graph,DAC input counts Vs output voltage to
check the linearity.
9.Switch off the power supply and remove all the connections.
User can change the delay period in order to get the desired frequency of the wave
form.User can view the output at DAC O/P,through the CRO.
ADDRESS OP-CODE MNEMONICS COMMENTS
DELAY
9104 00 nop
9105 00 nop
9106 00 nop
9107 00 nop
9108 14 dec a
910D 22 ret
CALCULATION:
=5/256
=0.0196v
RESULT:
Thus the program of ALP-To generate square wave using Timer/Counter for different
Frequencie was executed successfully.
EX NO: 10 INTERFACING STEPPER MOTOR WITH 8051
MICROCONTROLLER
AIM:
APPARATUS REQUIRED:
PROGRAM:
ORG (16-bit)H
4100
RESULT:
Thus the program to interface the stepper motor with 8051 was executed.