The control logic of 8253 consists of 5 control signals and A0. The corresponding operations are shown in Table 1. ?
RL1, RL0——Read/write operation bit. 00 means latched data, and the count value in the counter can be read at any time; 01 means read/write only the lower 8 bits, and the upper 8 bits are automatically set to 0; 10 means read/write only the upper 8 bits, and the lower 8 bits are automatically set to 0; 11 means read/write 16-bit data, first the lower 8 bits, then the upper 8 bits.
M2, M1, M0——Working mode selection bit. 0~5 means modes 0~5. Mode 0, interrupt after counting; Mode 1, programmable single trigger operation; Mode 2, frequency division pulse generation; Mode 3, frequency division square wave generation; Mode 4, software trigger strobe; Mode 5, hardware trigger strobe. The working process of mode 0 is as follows: when the program sends a control word to put the selected counter in the set mode, the output of the counter is low; when the initial value of the counter is loaded into the selected counter, under the control of the external input gate high level, it can count down through the respective count pulses. At this time, its output is still "low". When the counter is reduced from the initial value to all "0", a high level output is generated, and this output signal is used to send a count-complete interrupt to the CPU; this interrupt request is maintained until the program loads the initial value into the counter again.
BCD - counting mode selection bit. 1 means counting in decimal, and 0 means counting in binary. The circuit using the 8253 counting function is shown in Figure 1.
When there is no workpiece passing between the LED light-emitting tube and the phototube, the light emitted by the LED can shine on the phototube, making the phototube conductive and the collector low. This signal is driven and shaped by 74LS14 and sent to CLK1 of 8253, making CLK1 of 8253 also low. When a workpiece passes between the LED light-emitting tube and the phototube, the light emitted by the LED is blocked by the workpiece, the phototube is cut off, the collector becomes high, and CLK1 of 8253 is also high. After the workpiece passes, CLK1 returns to low level. In this way, every time a workpiece passes, a positive pulse is input from CLK1. By counting this pulse by 8253, the number of workpieces can be counted.
A1 and A0 of 8253 are connected to A2 and A1 of CPU address bus respectively. GATE1 is connected to +5V, and OUT1 is connected to an interrupt request input terminal IR2 of 8259A or an external interrupt input of 51 single-chip microcomputer as interrupt signal INT. The port addresses of 8253 designed in this system are 0350H, 0352H, 0354H, and 0356H respectively.
When programming, you can choose counter 1 to work in mode 0. In the mode 0 working mode of 8253, there is a clock pulse delay from writing the initial count value into the counter to starting to count down by 1. If the initial count value is n=999, then after n+1, that is, 1000 pulses, the count value is reduced to 0, and a positive jump is output at the OUT1 terminal, which can be used as an interrupt request. In the interrupt service subroutine, the CPU can do other processing, such as sending the next package box.
The initial value of the design number is 1999 (a package box is required to contain 2000 workpieces). Count in decimal, send the lower 8 bits first, then the upper 8 bits, and the control word is 01110001B.
The initialization program is:
MOV AL, 01110001B
If we want to know how many workpieces are in the box before it is full in the automatic counting system, we can use the data latch function of 8253; since 8253 is a minus 1 counter, we can read the current value of the counter, and then subtract the current value from the full value to get the number of workpieces in the current box.
At this time, the mode control word is 01000000B, and the program to achieve the above function is:
Previous article:Measures for Cutting Off Interference Propagation Paths in Single-Chip Microcomputer Circuit Design
Next article:Intelligent sulfur determination instrument based on single chip microcomputer design
- Popular Resources
- Popular amplifiers
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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- [Xianji HPM6750 Review 5] LittlevGL transplantation using SPI display
- TI Embedded Live Month - Registration starts now to support efficient, intelligent and low-power system design~
- Four input modes of MCU
- How to replace TMS320C6416TGLZ7 chip
- I would like to ask how to connect the ground on the PCB board of the monitoring equipment and the board ground?
- Overvoltage, overcurrent and overtemperature detection circuit
- Recruitment: Assistant Optical Engineer, Assistant Electronic Engineer, Assistant CAE Engineer, Assistant Structural Engineer
- PCB checklist summary
- Multi-core DSP products in the SoC era
- Detailed explanation of Altera series FPGA chip IP core