It is required to use timer/counter 1 for timing, with a timing of 1 second; timer/counter 0 for counter, and the external pulse to be counted is connected from P3.4 (T0).
The microcontroller will count the pulses within 1 second and send them to the four-digit digital tube for display. The maximum count display value is 0FFFFH.
Request a program.
;==============================================
Best answer: This is a simple frequency meter. The program is as follows:
;---------------------------------
ORG 0000H
JMP START
ORG 000BH
JMP T0_INT
;---------------------------------
START:
MOV TMOD, #51H ;/*01010001 T1 counting, T0 timing*/
MOV TH0, #HIGH(65536 - 50000) ;50ms@12MHz
MOV TL0, #LOW (65536 - 50000)
MOV TH1, #0
MOV TL1, #0
SETB TR0
SETB TR1
SETB ET0
SETB EA
MOV R7, #20
SJMP $
;---------------------------------
T0_INT: ;Execute once every 50ms
MOV TL0, #LOW (65536 - 50000) ;Rewrite the initial value
MOV TH0, #HIGH(65536 - 50000) ;50ms@12MHz
DJNZ R7, T0_END
MOV R7, #20
MOV P1, TL1
MOV P2, TH1
MOV TL1, #0
MOV TH1, #0
T0_END:
RETI
;---------------------------------
END
The simulation with PROTEUS is as shown below.
Previous article:Stopwatch Programming
Next article:Use T1 timing to output square waves with periods of 2ms and 500 microseconds at the P1.0 and P1.1 pins respectively.
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- 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
- Melexis launches ultra-low power automotive contactless micro-power switch chip
- Molex leverages SAP solutions to drive smart supply chain collaboration
- Pickering Launches New Future-Proof PXIe Single-Slot Controller for High-Performance Test and Measurement Applications
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- Apple faces class action lawsuit from 40 million UK iCloud users, faces $27.6 billion in claims
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The US asked TSMC to restrict the export of high-end chips, and the Ministry of Commerce responded
- The weekly review information is here~ The fresh delivery is here
- STM32F030 AD signal acquisition
- Does anyone have a working stm32F7 or H7 fmc interface lcd driver? I've been having a lot of trouble with it recently.
- The output data of the ADC chip is incorrect no matter how I process it. Please help.
- Some knowledge about optical splitters
- [NXP Rapid IoT Review] Unboxing Test
- Practical Tips | Four Myths About Ultra-Wideband (UWB) Technology
- 3 days left: Free application, Allwinner quad-core A40i low power and high performance evaluation board
- "Playing with the board" + Zhou Hangci's book Chapter 11, Example 1
- Pads color setting problem