papunblg
Advanced Member level 3
- Joined
- Oct 22, 2010
- Messages
- 716
- Helped
- 172
- Reputation
- 344
- Reaction score
- 165
- Trophy points
- 1,343
- Location
- Kolkata India
- Activity points
- 6,421
RAM_ADDR EQU 30H
COUNT EQU 3
hundreds equ 30h
tens equ 31h
ones equ 32h
ADC:
[INDENT] mov A,P0 ;Reading from ADC
nop
nop
ret[/INDENT]
Bin2Dec: ;Convert to Decimal
[INDENT] mov b,#100d
div ab
mov hundreds,a ;Store at 30h
mov a,b
mov b,#10d
div ab
mov tens,a ;Store at 31h
mov ones,b ;Store at 32h
ret [/INDENT]
DEC_ASCI_CONVRT:
[INDENT]MOV R0,#RAM_ADDR ;pointing to 30h
MOV R2,#3 ; for 3 location[/INDENT]
BACKk:
[INDENT] MOV A,@R0
ORL A,#30H
ACALL DATA_DISPLAY ; displayed to LCD
INC R0
DJNZ R2,BACKk
RET
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 #include<8051.h> #include<stdio.h> #include<lcd.c> void disp_digits(int n); __sfr __at (0x80) ADC_PORT; unsigned int temp; int thous,hundreds,tens,ones; unsigned int getadc; char strbuff[12]; void main(){ while(1){ getadc=ADC_PORT; MSDelay(100); LCD_init(); LCD_command(0x86); temp=getadc*6; if(temp>=1000) { ones=temp%10; temp=temp/10; tens=temp%10; temp=temp/10; hundreds=temp%10; thous=temp/10; sprintf(strbuff,"%d%d.%d%d Volt",thous,hundreds,tens,ones); LCD_sendstring(strbuff); } else { ones=temp%10; temp=temp/10; tens=temp%10; hundreds=temp/10; sprintf(strbuff,"%d.%d%dV",hundreds,tens,ones); LCD_sendstring(strbuff); } MSDelay(100); } }
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org 0h RAM_ADDR EQU 30H ;ASCI_RSULT EQU 50H COUNT EQU 3 hundreds equ 30h tens equ 31h ones equ 32h ACALL DELAY_200M ACALL ONETIME_LCDINIT STT: ACALL ADC ACALL Bin2Dec ACALL DEC_ASCI_CONVRT ACALL DELAY_200M ACALL DELAY_200M ACALL DELAY_200M sjmp STT ;================================================= ;this subroutine is used to take data from ADC and ;keep to Accumulator ;================================================= ADC: mov A,P0 nop nop ret Bin2Dec: mov b,#100d div ab mov hundreds,a mov a,b mov b,#10d div ab mov tens,a mov ones,b ret DEC_ASCI_CONVRT: MOV R0,#RAM_ADDR MOV R2,#3 BACKk: MOV A,@R0 ORL A,#30H ACALL DATA_DISPLAY INC R0 DJNZ R2,BACKk RET ONETIME_LCDINIT: MOV A,#38H ACALL COMMAND MOV A,#0EH ACALL COMMAND MOV A,#01H ACALL COMMAND MOV A,#06H ACALL COMMAND MOV A,#86H ACALL COMMAND RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; COMMAND: ACALL READY MOV P1,A CLR P2.0 CLR P2.1 SETB P2.2 CLR P2.2 RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATA_DISPLAY: ACALL READY MOV P1,A SETB P2.0 CLR P2.1 SETB P2.2 ACALL DELAY CLR P2.2 RET READY: SETB P1.7 CLR P2.0 SETB P2.1 BACK: CLR P2.2 ACALL DELAY SETB P2.2 JB P1.7,BACK RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DELAY_200M: MOV R7,#30H L1_DELAY: MOV TMOD,#10 MOV TH1,#3CH MOV TL1,#0B0H SETB TR1 AGAIN: JNB TF1,AGAIN CLR TR1 CLR TF1 DJNZ R7,L1_DELAY RET ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DELAY: MOV R3,#50 HERE3: MOV R4,#255 HERE2: DJNZ R4,HERE2 DJNZ R3,HERE3 RET END
Code ASM - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 en_pulse: setb en acall delay1 clr en acall delay1 ret ;================================================================== comnwrt: clr en mov P2,a clr rw acall delay1 clr rs acall delay1 acall en_pulse ret ;================================================================== datawrt: clr en mov P2,a clr rw acall delay1 setb rs acall delay1 acall en_pulse ret ======================================================================== Plz check if I got Lcd interfacing pins in your program correct 2.2 en 2.0 rs 2.1 rw P1 data 1.7 is it connected to some input signal?? Plz help :-?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?