8051 microcontroller programming:Interfacing ADC 0808 and displaying in decimal through LCD using Keil

The output from ADC is binary, it is easier for the user if the output is in decimal.
The output ranges from 00H to FFH. So in decimal it will be from 0 to 256.
  RS EQU P2.3
  RW EQU P0.1
  E EQU P0.0
  ALE EQU P2.4
  START EQU P2.6
  EOC EQU P2.7
  OE EQU P2.4
  AA EQU P2.0
  BB EQU P2.1
  CC EQU P2.2
  ORG 00H
  MOV A,#38H
  ACALL COMMAND
  MOV A,#0EH
  ACALL COMMAND
LOOP: MOV A,#01H
  ACALL COMMAND
  MOV A,#80H
  ACALL COMMAND
  MOV P1,#0FFH
  SETB EOC
  CLR START
  CLR OE
  CLR ALE
  SETB AA
  CLR BB
  CLR CC
  ACALL DELAY
  SETB ALE
  ACALL DELAY
  SETB START
  ACALL DELAY
  CLR START
  CLR ALE
WAIT: JB EOC,WAIT
RESTART:JNB EOC,RESTART
  SETB OE
  ACALL DELAY
  MOV A,P1
  CLR OE
  ACALL CONV
  SJMP LOOP
COMMAND:ACALL READY
  MOV P3,A
  CLR RS
  CLR RW
  SETB E
  ACALL DELAY
  CLR E
  RET
DISPLAY:ACALL READY
  MOV P3,A
  SETB RS
  CLR RW
  SETB E
  ACALL DELAY
  CLR E
  RET
READY: SETB P3.7
  SETB RW
  CLR RS
BACK: CLR E
  ACALL DELAY
  SETB E
  JB P3.7,BACK
  RET
DELAY: MOV R0,#0FFH
HERE: MOV R1,#0FFH
L1:  DJNZ R1,L1
  DJNZ R0,HERE
  RET
CONV: MOV B,#10D
  DIV AB
  MOV R5,B
  MOV B,#10D
  DIV AB
  MOV R6,B
  MOV R7,A
  MOV A,R7
  ADD A,#30H
  ACALL DISPLAY
  MOV A,R6
  ADD A,#30H
  ACALL DISPLAY
  MOV A,R5
  ADD A,#30H
  ACALL DISPLAY
  END

Comments

Popular posts from this blog

8051 microcontroller programming:Tutorial-Fibonacci series in assembly with Keil

8051 microcontroller programming: Interfacing with push button and displaying the button pressed using Keil