ADC0809 input voltage converted into LED light display program
;Convert input voltage into LED display.
;//////////////////////////////////////////////
;//define the connection port of ADC
ad_cs equ P3.6
ad_wr equ P3.2
ad_rd equ P3.7
ad_input_port equ p1
org 0000h
ajmp main
org 0030h
main:
lcall adc_demo
ajmp main
;//============================================
;// Start AD conversion
;//=============================================
Adc_Start:
clr ad_cs
nop
clr ad_wr
nop
setb ad_wr
nop
setb ad_cs
nop
ret
;//==========================================
;// Read AD conversion
;//======================================
Adc_Read:
MOV ad_input_port,#0ffh
clr ad_cs
nop
clr ad_rd
nop
nop
MOV a,AD_INPUT_PORT
nop
setb ad_rd
nop
setb ad_cs
ret
;// ==========================================
;// AD conversion read delay program, display the read value
; //=============================================
Adc_Demo:
lcall Adc_Start
lcall delay1ms
lcall adc_read
call l1
MOV r1,#100
disp1:
call disp
djnz r1,disp1
ret
l1:
MOV b,#10
mul ab
MOV r7,b
MOV r6,a
MOV r5,#00h
MOV r4,#51
lcall chu
MOV a,r6
MOV b,#10
div ab
MOV 31h,a
MOV 30h,b
ret
disp:
MOV p2,#0fdh
MOV dptr,#tab
MOV a,31h
MOV c a,@a+dptr
anl a,#7fh
MOV p0,a
call delay
MOV p2,#0ffh
MOV a,30h
MOV c a,@a+dptr
MOV p2,#0feh
MOV p0,a
call delay
ret
delay:
MOV r6,#10
d1:
MOV r7,#248
djnz r7,$
djnz r6,d1
ret
chu:
MOV a,r5
jnz begin
MOV a,r4
jz over
begin:
clr a
MOV r3,a
MOV r2,a
MOV r1,#10h
div0:
acall rlc4
MOV a,r2
subb a,r4
MOV r0,a
MOV a,r3
subb a,r5
jc next
inc r6
MOV r3,a
MOV a,r0
MOV r2,a
next:
djnz r1,div0
MOV a,r3
rlc a
jc round
MOV a,r2
rlc a
MOV r2,a
MOV a,r3
rlc a
subb a,r5
jc done
jnz round
MOV a,r2
subb a,r4
jc done
round:
acall add1
done:
clr a
ret
over:
MOV a,#0ffh
ret
rlc4:
clr c
MOV a,r6
rlc a
MOV r6,a
MOV a,r7
rlc a
MOV r7,a
MOV a,r2
rlc a
MOV r2,a
MOV a,r3
rlc a
MOV r3,a
ret
add1:
MOV a,r6
add a,#1
MOV r6,a
MOV a,r7
addc a,#0
MOV r7,a
ret
tab:db 0c0h,0f9h,0a4h,0b0h,99h,92h,82h,0f8h,80h,90h
delay1ms:
MOV r7,#10
tta:
MOV r6,#50
djnz r6,$ ;2us
djnz r7,tta
ret
end
Previous article:TIMER0 counting working mode program in MODE2
Next article:Two 8051 serial multiplexed data transmission program
Recommended ReadingLatest update time:2024-11-15 17:33
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- 6657Statically configure serial port general interrupt in sys/bios
- Understanding Nginx Architecture in One Article
- Highly recommended! ADI's latest Chinese information is here
- Altera SoC Architecture Excerpt - What is a SoC FPGA
- How to use common mode chokes in signal lines to eliminate common mode noise
- EEWORLD University ---- Python 3 video tutorial
- [Rivet RVB2601 Creative Application Development Competition] Participation Award Prizes
- CCS5.5 compiler optimization issues
- Is there anyone who knows PGA460? My circuit diagram is based on PGA460PSM, but I can't get any measurement results.
- How does AD import the complete content of a DWG file, or how does AD apply copper in a ring-shaped strip area?