0% found this document useful (0 votes)
34 views5 pages

JNB p3.6, Null JNB p3.3, Read

This document contains code for a microcontroller program that takes ADC readings, converts them to ASCII values, and displays the readings on a 2-digit 7-segment display. It initializes ports, takes ADC readings in a loop, converts the readings to ASCII using decimal conversion routines, and displays the values. It also contains delay routines to control timing.

Uploaded by

Nikhil Dixit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views5 pages

JNB p3.6, Null JNB p3.3, Read

This document contains code for a microcontroller program that takes ADC readings, converts them to ASCII values, and displays the readings on a 2-digit 7-segment display. It initializes ports, takes ADC readings in a loop, converts the readings to ASCII using decimal conversion routines, and displays the values. It also contains delay routines to control timing.

Uploaded by

Nikhil Dixit
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

ORG 0000H mov p3,#00 loop_start:

MOV DPTR,#MSG4 ACALL MESSAGE mov delay_counter,#09h ACALL DELAY

mov a,#01h acall command

main: loop_1: acall start_conv ;jnb p3.6,null ;jnb p3.3,read mov b,#02 mul ab mov r0,a ACALL HEXTOASCII_2 ACALL DISPLAY_2 ;ACALL DELAY_MS mov delay_counter,#09h call delay ;ljmp main2 jnb p2.7,main2 ljmp main main2: mov r0,#00 good: inc r0 cjne r0,#0ffh,nxt ljmp main mov delay_counter,#09h call delay mov delay_counter,#09h call delay nxt: mov p3,r0 ljmp good

START_CONV:

clr p1.1 setb p1.0

;wr ;rd

MOV ADC_PORT,#0f2h setb p1.1 ;soc

keep:

jb p1.2,keep ;intr clr p1.0 clr p1.3 MOV A,ADC_PORT anl a,#0f0h swap a mov r0,a setb p1.3 mov a,adc_port anl a,#0f0h orl a,r0 RET ;rd

delay: push 06h push 07h dely: s1: s: mov r6,#0ffh mov r7,#0ffh djnz r7,s djnz r6,s1 djnz delay_counter,dely pop 06h pop 07h ret DELAY_MS: push ACC push B mov B,#250 DD: djnz B,$ djnz B,$ djnz ACC,DD pop B ; ~ 500 uS @ 12 Mhz ; ~ 500 uS @ 12 Mhz

pop ACC ret MESSAGE:ACALL READY CLR A MOVC A,@A+DPTR INC DPTR CJNE A,#EOT,COMD RET COMD: CJNE A,#COM,DATAA CLR P2.0 SJMP MESSAGE DATAA:CJNE A,#DAT,SENDIT SETB P2.0 SJMP MESSAGE SENDIT:MOV P0,A CLR P2.1 SETB P2.2 CLR P2.2 SJMP MESSAGE READY:MOV R5,P2 CLR P2.2 MOV P0,#0FFH CLR P2.0 SETB P2.1 WAIT: CLR P2.2 SETB P2.2 JB P0.7,WAIT CLR P2.2 MOV P2,R5 RET COMMAND:ACALL REEADY MOV P0,A CLR P2.0 CLR P2.1 SETB P2.2 CLR P2.2 RET SHOW: ACALL REEADY MOV P0,A SETB P2.0 CLR P2.1 SETB P2.2 CLR P2.2 RET REEADY: SETB P0.7 CLR P2.0 SETB P2.1 PREV: CLR P2.2 SETB P2.2 JB P0.7,PREV RET HEXTOASCII_2:

ACALL CONDEC_2 MOV A,MULTMSB_2 ORL A,#30H MOV S_1,A MOV A,MULTMSB1_2 ORL MOV MOV ORL MOV RET ;LSB OF ASCII NUMBER IS STORED HERE

A,#30H S_2,A A,MULTLSB_2 A,#30H S_3,A ;MSB OF ASCII NUMBER IS STORED HERE

DISPLAY_2:CALL INSTRUC_2 MOV A,#'T' ACALL SHOW MOV A,#'e' ACALL SHOW MOV A,#'m' ACALL SHOW MOV A,#'p' ACALL SHOW MOV A,#' ' ACALL SHOW MOV A,S_1 ACALL SHOW MOV A,S_2 ACALL SHOW MOV A,S_3 ACALL SHOW MOV A,#'c' ACALL SHOW RET

INSTRUC_2: MOV A,#38H ACALL COMMAND MOV A,#0EH ACALL COMMAND MOV A,#06H ACALL COMMAND MOV A,01H ACALL COMMAND MOV A,#0c2H ACALL COMMAND RET

CONDEC_2: MOV DIV MOV MOV MOV DIV MOV

B,#100 AB MULTMSB_2,A A,B B,#10 AB MULTMSB1_2,A

MOV MULTLSB_2,B RET

MSG4: DB COM,38H,0cH,06H,01H,80H,DAT,'ADC DAC',EOT MSG5: DB COM,38H,0cH,06H,01H,80H,DAT,'Heart Beat',EOT

END

You might also like