;******************************************************************
;* Description: *
;* ADC0832 digital voltmeter digital tube display *
;* *
;* Adjust the potentiometer next to ADC0832
, and the digital tube will display the size of the ADC0832 conversion value * ;* *
;* *
;**********************************************************************
AD_CLK EQU P1.0
AD_DAT EQU P1.1
AD_CS EQU P3.4
DISSTART EQU 30H ;Display unit first address
LED_DATA EQU P0 ;Digital tube data definition
ORG 0000H
JMP START
;--------------------------------------------------------
START: MOV SP,#60H
MOV A,#00H
MOV 20H,A
MOV P0,#0FFH
MOV P2,#0FFH
START1: CALL AD_CONV
CALL AD_CHULI
CALL QUSHU
CALL ADPLAY
JMP START1
;---------------------------------------------------------
AD_CONV: ;ADC0832 initialization
SETB AD_CS ;A conversion cycle starts
CLR AD_CLK
CLR AD_CS ;CS is set to 0, chip select is valid
SETB AD_DAT ;DI is set to 1, start bit
SETB AD_CLK ;The first pulse
CLR AD_DAT ;Add a DI inversion operation before the negative jump
CLR AD_CLK
SETB AD_DAT ;DI is set to 1, set to single channel
SETB AD_CLK ;The second pulse
CLR AD_DAT ;***
CLR AD_CLK ;
CLR AD_DAT ;DI is set to 0, select channel 0
SETB AD_CLK ;The third pulse
SETB AD_DAT ;***
CLR AD_CLK
NOP
SETB AD_CLK ;The fourth pulse
MOV R1,#08H ;Counter initial value, read 8-bit data,
AD_READ: CLR AD_CLK ;Falling edge
MOV C,AD_DAT ;Read DO terminal data
RLC A ;C moves into A, high bit first
SETB AD_CLK ;The next pulse
DJNZ R1,AD_READ ;Continue
SETB AD_CS
MOV 20H,A ;Conversion result is sent to 20H
RET
;------------------------------------------------------
AD_CHULI:
CLR C
MOV R5,#00H ;Decimal conversion low register
MOV R4,#00H ;Decimal conversion high register
MOV R3,#08H ;Number of decimal adjustment
MOV A,20H
AD_CHULI1:
RLC A
MOV R2,A
MOV A,R5
ADDC A,R5
DA A
MOV R5,A
MOV A,R4
ADDC A,R4
MOV R4,A
MOV A,R2
DJNZ R3,AD_CHULI1
MOV A,R5
ADD A,R5
DA A
MOV R5,A
MOV A,R4
ADDC A,R4
DA A
MOV R4,A
RET
;-------------------------------------------------
QUSHU: MOV A,R5
ANL A,#0FH
MOV DISSTART,A
MOV A,R5
ANL A,#0F0H
SWAP A
MOV DISSTART+1,A
MOV A,R4
ANL A,#0FH
MOV DISSTART+2,A
MOV A,R4
ANL A,#0F0H
MOV DISSTART+3,A
RET
;--------------------------------------------------
ADPLAY: PUSH PSW
CLR PSW.3
SETB PSW.4
MOV R0,#DISSTART ;Start filling display unit
MOV R2,#03H ;Fill 3 bits in total
DISP1: MOV A,@R0 ;Get current bit address
MOV DPTR,#TAB_NU ;Get table header
MOVC A,@A+DPTR ;Get coded data
MOV @R0,A ;Save coded data
INC R0 ;point to the next conversion data
DJNZ R2,DISP1 ;continue conversion until completed
MOV R0,#DISSTART ;get the display unit first address
MOV R1,#07FH ;start from the first digital tube
MOV R2,#03H ;display 3 digital tubes in total
DISP2: MOV LED_DATA,@R0 ;read the display unit data
MOV P2,R1 ;start to display the current bit
MOV A,R1 ;prepare to display the next bit
RR A ;
MOV R1,A ;next bit
INC R0 ;get the next unit address
JNB ACC.5,DISP3 ;add decimal point to the third digital tube
JMP DISP4
DISP3: MOV A,@R0
ANL A,#7FH
MOV @R0,A
DISP4: LCALL DELAY5MS ;delay 2 MS
DJNZ R2,DISP2 ;repeat to display the next
POP PSW
RET ;display completed, return
;---------------------------------------------------
DELAY5MS:
MOV R6,#10
DEL1: MOV R7,#100
DJNZ R7,$
DJNZ R6,DEL1
RET
;-------------------------------------------------
TAB_NU:
DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H
DB 80H,90H,88H,83H,0C6H,0A1H,86H,8EH
Previous article:Knowledge of transformer detection methods
Next article:Tube voltmeter - for measuring pulse voltage
Recommended ReadingLatest update time:2024-11-15 13:38
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- MCU Principles and Interface Technology C51 Programming (Edited by Zhang Yigang)
- Seizing the Opportunities in the Chinese Application Market: NI's Challenges and Answers
- Tektronix Launches Breakthrough Power Measurement Tools to Accelerate Innovation as Global Electrification Accelerates
- Not all oscilloscopes are created equal: Why ADCs and low noise floor matter
- Enable TekHSI high-speed interface function to accelerate the remote transmission of waveform data
- How to measure the quality of soft start thyristor
- How to use a multimeter to judge whether a soft starter is good or bad
- What are the advantages and disadvantages of non-contact temperature sensors?
- In what situations are non-contact temperature sensors widely used?
- How non-contact temperature sensors measure internal temperature
- 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
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Three steps to govern hybrid multicloud environments
- Three steps to govern hybrid multicloud environments
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Microchip Accelerates Real-Time Edge AI Deployment with NVIDIA Holoscan Platform
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- [Automatic clock-in and walking timing system based on face recognition] Maixbit/MaixPy pitfall! The audio playback function blocks the call
- 1
- Wireless Earbud Battery Ultra-Low Standby Power Consumption Reference Design
- When MOS tubes are connected in parallel, do they have to be symmetrical?
- TA0CCR0 interrupt of msp430
- What are the 9 most important applications of the Internet of Things (IoT)?
- MOS tube burnt out
- About CS1256 Analog Chip
- At the same frequency, the impedance of a large capacitor is smaller than that of a small capacitor, and it has better filtering performance for high frequencies. Why do we need to connect a small capacitor in parallel?
- [GD32E503 Review] Part 5: FreeRTOS Project Creation