The source program for the multi-channel data acquisition of the single-chip microcomputer is as follows
:
Single-channel acquisition program:
MOV DPTR, #0F8FFH
MOV R0, #00H ; store the first address of the memory in the two registers R0 and R1
MOV R1, #00H
MOV R2, #200D ; set up the loop
MOV R3, #4
MOV R4, #8D
MAIN:
CLR P1.1 ;Select ADC0809
PUSH DPL ;Push DPTR into the stack
PUSH DPH
MOVX @DPTR,A ;Start AD conversion
ACALL DELAY ;Delay 5ms to ensure the data acquisition frequency is 200HZ
MOVX A,@DPTR ;Read data
SETB P1.1 ;Select memory
MOV DPL,R0 ;Give the address of the memory to DPTR
MOV DPH,R1
MOVX @DPTR,A ;Store data
INC DPTR ;Point to the next storage unit
MOV R0,DPL ;Store the unit address back into the register
MOV R1,DPH
POP DPH ;Pop DPTR out of the stack
POP DPL
DJNZ R2,MAIN
DJNZ R3,MAIN
DJNZ R4,MAIN
SJMP $
DELAY: ;Delay program delay 5ms
MOV R5,#100D
MOV R6,#24D
LA:DJNZ R5,$
DJNZ R6,LA
RET
END
Loop acquisition program:
MOV 30H,#00H; Store the first addresses of the eight memories in 16 internal storage units from 30 to 3F respectively
MOV 31H,#00H
MOV 32H,#00H
MOV 33H,#20H
MOV 30H,#00H; Store the first addresses of the eight memories in 16 internal storage units from 30 to 3F respectively
MOV 31H,#00H
MOV 32H,#00H
MOV 33H,#20H
MOV 34H,#00H
MOV 35H,#40H
MOV 36H,#00H
MOV 37H,#60H
MOV 38H,#00H
MOV 39H,#80H
MOV 3AH,#00H
MOV 3BH,#0A0H
MOV 3CH,#00H
MOV 3DH,#0C0H
MOV 3EH,#00H
MOV 3FH,#0E0H
MOV R2,#200D ;Set the outer loop 200*40 for 8000 times in total
MOV R3,#40D
MAIN: MOV DPTR,#0F8FFH ;The address of channel 0
MOV R0,#30H ;R0,R1 are intermediate variables of the memory address
MOV R1,#31H
MOV R4,#8 ;Set the inner loop
LOOP: CLR P1.1 ;Select ADC0809
PUSH DPL ;DPTR is pushed into the stack
PUSH DPH
MOVX @DPTR,A ;Enter a number to start AD conversion
ACALL DELAY ;Wait for delay to collect 200 data per second
MOVX A,@DPTR ;Read data
SETB P1.1 ;Select the memory
MOV DPL,@R0 ;Give the address of the memory to DPTR
MOV DPH,@R1
MOVX @DPTR,A ; store data
INC DPTR ; point to the next storage unit
MOV @R0,DPL ; store the unit address back into the internal data storage unit
MOV @R1,DPH
INC R0 ; point to the address of the next memory
INC R0
INC R1
INC R1
POP DPH ; DPTR pops the stack
POP DPL
INC DPH ; point to the next channel address
DJNZ R4,LOOP ; inner loop
DJNZ R2,MAIN ; outer loop
DJNZ R3,MAIN
SJMP $
DELAY: ; delay program delay 600us
MOV R5,#100
MOV R6,#3
LA:DJNZ R5,$
DJNZ R6,LA
RET
END
Previous article:Hardware debugging steps in the MCU development process
Next article:Design of Single Chip Microcomputer in Cable Tester
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Award-winning live broadcast: Infineon MERUS Class D audio amplifier's multi-level technology and its advantages live broadcast material collection
- Who has used the LM26LV-Q1 temperature chip?
- Question about programmable frequency divider based on shift register
- AD20 Select PCB Components cannot be used?
- Newly purchased MicroPython development board
- STM32F 7508DK I2C BH1570 driver development and I2C usage
- C2000 MCU, Vienna Rectifier-Based Three-Phase Power Factor Correction Reference Design
- The 5G era has arrived. This is a rare opportunity. What ideas do you have to share?
- General method of displaying pictures and texts on TFT color screen
- Ultra-low standby power consumption DC-DC controller chip