Lab Manual Part 2 Updated
Lab Manual Part 2 Updated
;*********************************************************************
************;;******************;
;
;
;*********************************************************************
************;;***************
;***;******************
; Author : Dr. Sukesh Rao M.
; Email : [email protected] , [email protected]
ORG 00H
MOV P0,#00H ; initialize the port 0 as 00h(output port)
UP: MOV A,#00H
MOV P0,A ; turn off the leds for a specific period using
LCALL DELAY ; delay function
MOV A,#0FFH
MOV P0,A ; turn off the leds for a specific period using
LCALL DELAY ; delay function
SJMP UP
DELAY CALCULATION
Total machine cycles required to execute the delay procedure ={(2x255 + 2 + 1)x255}+ 1
= 130816
1 Machine cycle = 12 clock cycles ,
Clock frequency of 8051 = 11.0592MHz
Time Period = (1/11.0592M) = 0.09042us
1 machine cycle takes 0.09042us x 12 = 1.086us
;
;
;*********************************************************************
************;;***************
;***;******************
; Author : Dr. Sukesh Rao M.
; Email : [email protected] , [email protected]
ORG 00H
MOV P0,#00H ; initialize the port 0 as 00h(output port)
MOV A,#00H
UP:MOV P0,A ; Turn on LED with corresponding value of A for
LCALL DELAY ; specific period using DELAY function
INC A ; increment the counter value
SJMP UP
;*********************************************************************
************;;******************;
;
;
;*********************************************************************
************;;***************
;***;******************
; Author : Dr. Sukesh Rao M.
; Email : [email protected] , [email protected]
ORG 00H
SETB P3.2
SETB P3.3
CLR A;
MOV P0,A;
4. Write a code for 8051 to get BCD up count on single digit seven
segment display
;*********************************************************************
************;;******************;
;
;
;*********************************************************************
************;;***************
;***;******************
; Author : Dr. Sukesh Rao M.
; Email : [email protected] , [email protected]
UP:MOV DPTR,#UPVALUE
CLR P1.0 ; select first seven segment
MOV R0,#00 ;initial value to be displayed
MOV R2,#10 ;count=10
LCALL UPCOUNT ;calling procedure for upcount
SJMP UP
END
;
;
;*********************************************************************
************;;***************
;***;******************
; Author : Dr. Sukesh Rao M.
; Email : [email protected] , [email protected]
; 4 segments are connected to common data line and activated for the
; fixed duration of time. The method is known as time multiplexing.
; 26 FRC cable is connected to IO extension module and 16 FRC is used
;to connect SEVEN SEGMENT module. P1.0 to P1.3 are used as select
lines and P0 as data line.
; keil Monitor-51 driver is selected under debug settings*/
; LCD is internally connected in ESA51 in 8 bit mode. The IO port configuration is same as given in the source code
; Make sure COM port is selected as per your system status under device manager
; keil Monitor-51 driver is selected under debug settings*/
LCD_data EQU P2
RS EQU P3.7
RW EQU P3.6
DISP_STRING:NOP
UP11: CLR A
MOVC A,@A+DPTR ;use lookup table to get ascii character
CJNE A,#0FH,SKIP5 ; check for the end of the character 0fh
RET
SKIP5: INC DPTR
LCALL DISP ; display character on LCD
SJMP UP11
END
;***;******************
; Author : Dr. Sukesh Rao M.
; Email : [email protected] , [email protected]
CS EQU P1.7
RD_A EQU P1.6
WR_A EQU P1.5
INTR EQU P1.4
ADC_DATA EQU P0
LED_DISPLAY EQU P2
ORG 0000H
LJMP START
ORG 0050H
START: MOV ADC_DATA,#0FFH ; make P1 as input to read ADC output
MOV LED_DISPLAY,#0FH ; display value on LED
SETB INTR ; input port line for end of conversion (EOC)