This is a commonly used program segment - a subroutine - a standard program, which obtains input data or controls output data through port scanning to achieve the purpose of saving bits or bytes - saving hardware resources.
Regarding scanning, we can understand it by starting with the bit and its inversion to realize the running light. The running light-scanning can be realized by shifting. The running light-scanning can be realized by sending the byte data (01H, 02H, 04H, 08H, 10H, 20H, 40H, 80H—anode tube) through the port. The running light-scanning can be realized through the data table (DB 01H, 02H, 04H, 08H, 10H, 20H, 40H, 80H—cathode tube). The running light-scanning can be realized by loop jump. When scanning, pay attention to the input comparison and output check—obtaining input requires comparing data, and sending output requires checking the output.
Scan to get port bytes
Scan output bit movement produces dynamic effects (01, 02, 04, 08, 10, 20, 40, 80), which can be done with byte tables
Scan and output character bytes, and change characters by delay to create a digital carry effect
ORG 0000H
START:
dbuf equ 30h ; set the first address of the storage area
temp equ 40h ; set buffer first address
dp00: mov a,@r0 ; get the data to be displayed
disp0: mov r0,#temp ;display subroutine
dp01: mov a,@r0
segtab: db 0C0H,0F9H,0A4H,0B0H,99H,92H ; common anode tube
delay: mov r4,#29h ;delay subroutine
aa1: mov r5,0ffh
aa: djnz r5,aa
???????????????????????
************************************************************************
Scanning can also be performed in other program forms, such as loops, incrementing or decrementing judgment programs, etc. Scanning technology can be used for dot matrix displays and liquid crystal display (LCD) displays. These require character encoding, display delay, and scanning ports to make full use of resources (save resources).
Example 1 - About dynamic display - LED flashing
ORG 0000H
RIGHT
GUAN :
Other methods (such as delay subroutines) can also achieve dynamic display. [page]
Example 2 - Simulation of a single LED light and a single button
ORG 0000H ; This is a pseudo instruction. The machine does not execute it. It is used for program communication. The starting address of instruction execution is represented by D in decimal, H in hexadecimal, and B in binary. One byte (8-bit machine, 16-bit machine, 32-bit machine, 64-bit machine) is executed at a time. It can also be executed bit by bit, that is, one bit.
ORG 00000000B has the same function as ORG 0000H. Note that 8 bits are one byte. A 16-bit processor needs to be represented by 0000 0000H. For 16 or 32 bits or above, it is more effective to use an operating system (Wince, Linux, etc.), which can utilize a large number of low-level, professional, and standardized control-oriented library functions (such as: API, etc.).
START: ; This is a pseudo instruction, the machine does not execute it. It is just for the sake of the comprehensibility of the assembly language story.
PC→MOV P1, A ; transfer the number in the accumulator (constant 0D) to port P1 (all 8 bits of port P1 are set to 0, low level, all bits of port P1 are in the off state, and the LED light is in the ready state for system response), and transfer data by byte. Special memory: PC→ indicates the address pointed by the pointer, and it will automatically increase by 1.
PC→MOV C, 0A0H ; Check the status of P2.0 port, and transfer the status of P2.0 port (determined by the key status) to the bit accumulator C. The address of bit accumulator C is the carry flag CY (D7H\PSW.7) of PSW (Program Status Word Register). P2.0 port can be on or off, that is, set to 1 or 0, high level or low level), and data is transferred by byte. Data is exchanged through bit accumulator C and other storage addresses. This statement can also be written as: MOV C, P2.0, compare byte data transfer MOV A, #00H or MOV A, P1.
PC→MOV P1.0, C; equivalent to MOV 90H, C; transfer the value in the bit accumulator C address to the P1.0 port (90H is its direct address), that is, transfer the state of the P2.0 port (determined by the direct address 0A0H state) to the direct address 90H, P1.0 port
PC→MOV P1.1, C ; equivalent to MOV 91H, C
PC→MOV P1.2, C ; equivalent to MOV 92H, C
PC→MOV P1.3, C ; equivalent to MOV 93H, C , etc.
END; pseudo instruction, program end mark
Example 3 - Scanning to achieve digital movement change simulation
Example 4 - Dual-digital tube dual-port digital carry simulation
Example 5 - Dual-port digital display of dual-quadruple digital tube group - Single-port scanning mobile simulation - Dot matrix
Dual quad digital tube set dual port digital display - single port scanning mobile simulation, can be decomposed into
a) Dual-port digital display of dual-quadruple digital tube group - single port no scanning no movement - > digital changes (depending on the digital meter and pointer),
b) Dual-port digital display of dual-quadruple digital tube group - single-port scanning movement - > the number does not change (depending on the number table and pointer),
c) Dual-port digital display of dual-quadruple digital tube group—single-port scanning movement—>digital changes (depending on the digital meter and pointer),
Previous article:The interrupt architecture of 51 single chip microcomputer
Next article:Intelligent single pendulum period measuring instrument
- Popular Resources
- Popular amplifiers
- RBF neural network control design, analysis and Matlab simulation (Liu Jinkun)
- Model Engineering in Mixed-Signal Circuit Design: A Guide to Generating...
- Cadence and SpectreRF Tutorial Detailed guide to simulating RF circuits
- Modeling Method and Design Optimization for a SoftSwitched DC-DC Converter
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- 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
Guess you like
- [2022 Digi-Key Innovation Design Competition] K210 transmits images to DWIN serial port display
- AWR1843BOOST mmw demo operation guide (Part 1)
- [NXP Rapid IoT Review] Offline Compilation and Testing Summary
- [GD32F350/GD32E103] Build VSF-based WebUSB DFU using open source toolchain
- How to determine whether the power supply needs a PFC circuit?
- RFMD and Qorvo prototype boards vs. honeycomb heat sinks
- Is there any big guy who does MEMS process research and development? Please guide me
- Question about LED flashing (newbie question)
- Learn about vehicle-to-everything (V2X) technology in one article
- Evaluation of the domestic FPGA Gaoyun GW1N-4 series development board - Software Part 1