Title: Use AT89C51 microcontroller assembly language to write a program to control the forward and reverse rotation of the motor
The button of P3.0 is used to control the forward rotation.
The button of P3.1 is to control the inversion
The button of P3.2 is to stop
Write it in the shortest possible assembly language, and explain it sentence by sentence if possible. I won't use interrupts.
The circuit is as follows:
For such a simple problem, there is no need to use interrupts.
The program written by Dao is as follows:
;DC motor control
ORG 0000H
P30:JB P3.0, P31; Detection button
CALL DELAY ; Delay
JB P3.0, P31 ; Anti-shake
JNB P3.0, $ ; Waiting for release
MOV P2, #01H ;Forward
;------------------------
P31:JB P3.1, P32; take turns to test
CALL DELAY
JB P3.1, P32
JNB P3.1, $
MOV P2, #02H ; reverse
;------------------------
P32:JB P3.2, P30
CALL DELAY
JB P3.2, P30
JNB P3.2, $
MOV P2, #03H ;Stop
SJMP P30
;------------------------
DELAY: ; Delay about 10ms (fosc = 6MHz)
MOV R6, #10
DJNZ R7, $
DJNZ R6, $ - 2
RET
;------------------------
END
;------------------------
Comment from the questioner: I thank the great god, grateful
postscript:
This program is written as: short and powerful, fully functional, and works extremely fast, not inferior to the method of using interrupts.
Previous article:51 Assembly language programming: 8 buttons control 8 LEDs
Next article:51 MCU Assembly Programming: Recording Keystrokes
Recommended ReadingLatest update time:2024-11-17 06:45
- Popular Resources
- Popular amplifiers
- Siemens PLC Programming Technology and Application Cases (Edited by Liu Zhenquan, Wang Hanzhi, Yang Kun, etc.)
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- Implementing a Deep Learning Framework with Python (Zhang Juefei, Chen Zhen)
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!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- 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
- How to embed OS in MSP430 series MCU
- Repost - The other side of electronic components you have never seen!
- BKP backup register
- [A-Current Signal Detection Device] Shaanxi Province First Prize_Topic A
- There is a bug in the 28335IO port. Has anyone encountered the following situation?
- Log-Periodic Antenna
- [TI Recommended Course] #TI Robot System Learning Kit (TI-RSLK) Upgraded Version#
- IC industry: Demand for three types of talent on the "talent chain" is expected to rise
- Why does the bandpass filter output such a waveform?
- Understanding mobile phone fast charging technology in one article