9:39 AM
Interfacing of ADC with 8051 Microcontroller with Program code

Aim: Interfacing of ADC with 8051 Microcontroller

Requirements: 8051, 11.0592MHz Crystal, 33pF (2), 10uF, 10K, push button, 1K (10), Analog to Digital Convertor (ADC0808), Bread Board, Connecting wires, 5V power supply

Circuit Diagram:

 

 

Program Code :

 

ORG 0000H

LJMP MAIN ;jump to main progam

ORG 000B ;address of Timer 0 interrupt

CPL P2.3 ;generation of less than 100MHz frequency

RETI

MAIN:

ORG 0300H

LCALL LCD ;              Initialisaiton of LCD

ACALL DISPLAY

MOV TMOD,#02H ;    initialisation of timer 0

MOV TH0,0D8H ;        delay for more than 100MHz frequency

MOV IE,#82H ;            Enable Timer interrut 0

SETB TR0 ;                Start timer

MOV P0,#0FFH ;       Make P0 as input port

SETB P2.7 ;              make EOC an input port

CLR P2.4 ;clear ALE

CLR P2.6 ;clear WR i.e. start of conversion

CLR P2.5 ;clear RD i.e. out enable

CLR P3.7 ;For the selection of data bus for 3.

SETB P3.6

SETB P3.5

BACK:ACALL DELAY

SETB P2.4 ;ALE

ACALL DELAY

SETB P2.6 ;SC

ACALL DELAY

CLR P2.4 ;ALE

CLR P2.6 ;SC

HERE:JB P2.7,HERE ;wait untill done

SETB P2.5

ACALL DELAY_1

MOV A,P0

CLR P2.5

ACALL CONVERSION

ACALL DISPLAY

SJMP BACK

CONVERSION: ;conversion from HEX to BCD

MOV B,#0AH

DIV AB

MOV R0,B

MOV B,#10

DIV AB

MOV R1,B

MOV R2,A

MOV A,R0

ADD A,#30H

MOV R0,A

MOV A,R1

ADD A,#30H

MOV R1,A

MOV A,R2

ADD A,#30H

MOV R2,A

RET

LCD: ;Initialization of LCD

MOV A,#38H

ACALL COMM

ACALL DELAY_1

MOV A,#0EH

ACALL COMM

ACALL DELAY_1

MOV A,#01H

ACALL COMM

ACALL DELAY_1

MOV A,#06H

ACALL COMM

ACALL DELAY_1

MOV A,#80H

ACALL COMM

ACALL DELAY_1

RET

DISPLAY:

MOV A,#'T'

ACALL WRITE

MOV A,#'E'

27 | P a g e

ACALL WRITE

MOV A,#'M'

ACALL WRITE

MOV A,#'P'

ACALL WRITE

MOV A,#'.'

ACALL WRITE

MOV A,#' '

ACALL WRITE

MOV A,R2

ACALL WRITE

MOV A,R1

ACALL WRITE

MOV A,R0

ACALL WRITE

MOV A,#'`'

ACALL WRITE

MOV A,#'C'

ACALL WRITE

ACALL DELAY_1

MOV A,#80H

ACALL COMM

RET

COMM:

MOV P1,A

CLR P2.0

CLR P2.1

SETB P2.2

ACALL DELAY_1

CLR P2.2

RET

WRITE:

MOV P1,A

SETB P2.0

CLR P2.1

SETB P2.2

ACALL DELAY_1

CLR P2.2

RET

DELAY_1:

MOV R4,#01H

HERE11:MOV R5,#0FFH

HEREE:DJNZ R5,HEREE

DJNZ R4,HERE11

RET

DELAY:

MOV R6,#50

HERE55:DJNZ R6,HERE55

RET

END

 

Learning outcomes: to be written by the students in 50-70 words.

 

Views: 111 | Added by: vijoriya | Tags: interfacing, Program code, 8051 Microcontroller, ADC | Rating: 0.0/0
Total comments: 0
avatar