hello sir,
i want to program a microcontroller based on the following logic: i am using adc(0804) in free-running mode and interfacing it to adc .I am applying a variable voltage at pin no: 6 of adc and also made a look-up-table how the adc reads.for 1volts it reads 33h,for 2 volts 67h......I want to program my microcontroller(89s52) in the following logic, I want to see the display at port 3 of the microcontroller through a seven segment display .I have written a program code but the results are not comming properly.please track the mistakes of my code and help me to write a correct one. please help,it's urgent. i am enclosing my csetb p2.5
setb p2.6
intr bit p2.7
setb intr
adc_port equ p1
adc_val equ 30h
output equ p3
org 0000h
start: acall read_adc
acall compare
acall conversion
sjmp start
conversion: clr wr
setb wr
read_adc: clr rd
mov a,adc_val
setb rd
ret
compare: mov a,adc_val
cjne a,#33h,not_33
mov r3,#01h
acall data_display1
not_33: cjne a,#67h,not_67
mov r3,#02h
acall data_display2
not_67: cjne a,#97h,not_97
mov r3,#03h
acall data_display3
not_97: cjne a,#99h,not_99
mov r3,#04h
acall data_display4
not_99: cjne a,#0ffh,not_0ff
mov r3,#05h
not_0ff: acall data_display5
data_display1: mov a,#33h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#92h
acall delay
mov p3,#0f8h
acall delay
data_display2: mov a,#67h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#0f9h
acall delay
mov p3,#0c0h
acall delay
mov p3,#0b0h
acall delay
data_display3: mov r3,#97h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#0f9h
acall delay
mov p3,#92h
acall delay
mov p3,#0f9h
acall delay
data_display4: mov r3,#99h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#0f9h
acall delay
mov p3,#92h
acall delay
mov p3,#0f9h
acall delay
data_display5: mov r3,#0ffh
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#0a4h
acall delay
mov p3,#92h
acall delay
mov p3,#92h
acall delay
delay: mov r4,#200
here: djnz r4,here
ret
end
ode herewith
i want to program a microcontroller based on the following logic: i am using adc(0804) in free-running mode and interfacing it to adc .I am applying a variable voltage at pin no: 6 of adc and also made a look-up-table how the adc reads.for 1volts it reads 33h,for 2 volts 67h......I want to program my microcontroller(89s52) in the following logic, I want to see the display at port 3 of the microcontroller through a seven segment display .I have written a program code but the results are not comming properly.please track the mistakes of my code and help me to write a correct one. please help,it's urgent. i am enclosing my csetb p2.5
setb p2.6
intr bit p2.7
setb intr
adc_port equ p1
adc_val equ 30h
output equ p3
org 0000h
start: acall read_adc
acall compare
acall conversion
sjmp start
conversion: clr wr
setb wr
read_adc: clr rd
mov a,adc_val
setb rd
ret
compare: mov a,adc_val
cjne a,#33h,not_33
mov r3,#01h
acall data_display1
not_33: cjne a,#67h,not_67
mov r3,#02h
acall data_display2
not_67: cjne a,#97h,not_97
mov r3,#03h
acall data_display3
not_97: cjne a,#99h,not_99
mov r3,#04h
acall data_display4
not_99: cjne a,#0ffh,not_0ff
mov r3,#05h
not_0ff: acall data_display5
data_display1: mov a,#33h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#92h
acall delay
mov p3,#0f8h
acall delay
data_display2: mov a,#67h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#0f9h
acall delay
mov p3,#0c0h
acall delay
mov p3,#0b0h
acall delay
data_display3: mov r3,#97h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#0f9h
acall delay
mov p3,#92h
acall delay
mov p3,#0f9h
acall delay
data_display4: mov r3,#99h
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#0f9h
acall delay
mov p3,#92h
acall delay
mov p3,#0f9h
acall delay
data_display5: mov r3,#0ffh
mov b,#0ah
div ab
mov r7,b
mov b,#0ah
div ab
mov r6,b
mov r5,a
mov p3,#0a4h
acall delay
mov p3,#92h
acall delay
mov p3,#92h
acall delay
delay: mov r4,#200
here: djnz r4,here
ret
end
ode herewith
Last edited: