Timing within the one-chip computer Counter and interrupt system
Description: This document will present an overview of two critical components within a one-chip computer: the timing/counter system and the interrupt system. Through this explanation, readers will gain insight into the operating principles of these systems. For illustration, consider an alarm clock that rings after one minute; this requires the second hand to complete 60 ticks. The number of ticks corresponds to the count, and each tick represents one second. The timing/counter system in the one-chip computer functions similarly to an alarm clock, allowing for programmed operations at specified intervals. The primary time count is derived from clock pulses generated by the one-chip computer's internal crystal oscillator, which undergoes a frequency division of 12. Consequently, the timer can be viewed as a periodic counter for the computer. Each machine cycle consists of 12 oscillation periods, resulting in the timer incrementing by 1 with each cycle. The clock pulse input serves as a periodic signal for the machine, with a frequency that is one-twelfth of the crystal frequency. For a crystal frequency of 12 MHz, the timer receives an input pulse every second. In this experiment, a crystal frequency of 11.0592 MHz is used, resulting in an input pulse approximately every 1.085 seconds. Accurate timing is crucial in practical applications, as tasks often need to be executed precisely when a specified time is reached. The one-chip computer STC89C52 features three timing/counter modules: T0, T1, and T2. The operating modes of T0 and T1 are identical and will be discussed together, while T2 has a slightly different operating mode, which is not detailed here. The utility programs for these timers can be found in the experiment kit's CD. The timer/counter in the one-chip computer can multiplex, recording external pulse counts, while the timer relies on the stable internal clock for its counting source. T0 and T1 will be used as examples to illustrate the timer's functionality. After understanding the internal timer resources, a detailed explanation of the timer registers follows. TMOD (Timer Mode) is utilized to set the timer's operating mode, while TCON (Timer Control) manages the timer's start, stop, overflow indication, and cutoff conditions. Once the timer's operating mode is configured and initiated, it operates independently of the CPU's processing time, allowing the CPU to pause its current operation when the counter overflows. An example experiment involves controlling an external LED to blink, illustrating the one-chip computer's operating principles through programming.
The timing/counter system in a one-chip computer is essential for various applications that require precise timing and event management. The STC89C52 microcontroller, which is commonly used in educational and experimental setups, incorporates three timers: T0, T1, and T2. Each timer can be configured to operate in different modes, such as 16-bit timer mode or 8-bit auto-reload mode, depending on the requirements of the application.
The TMOD register is critical for setting the operation mode of the timers. It allows the user to select between different modes for each timer, enabling flexibility in how the timers are utilized. For instance, in mode 0, the timer operates as a 13-bit timer, while in mode 1, it functions as a 16-bit timer. The TCON register is equally important, as it manages the control signals for starting, stopping, and monitoring the timers' status, including overflow conditions.
When the timer is started, it begins counting based on the clock pulses it receives. The internal clock of the STC89C52 is derived from the external crystal oscillator, which provides a stable frequency for accurate timing. The timer increments its count with each clock pulse, and once it reaches its maximum value, it can trigger an interrupt or reset, depending on the configuration set in the TCON register.
Using the timing/counter system effectively allows for the implementation of various time-based functions, such as generating delays, measuring time intervals, and managing periodic tasks. For example, the blinking LED experiment demonstrates how the timer can be used to create timed events, where the LED turns on and off at regular intervals based on the timer's count. This showcases the practical application of the timer in controlling external devices, enhancing the understanding of how the one-chip computer operates in real-world scenarios.This one will report about and introduce two very important resources within the one-chip computer -Timing / counter and interrupt system. Say through this, readers can know the operating principle of the timer and interrupt system of the one-chip computer.
Let us give an example of alarm clock at first, its vibrating bell after one minute regularly, this needs second hand to leave in the fake 60 times. Namely time turn number of times that second hand leave into one minute, that is number of times that count, count, come 60 then vibrating bell, and time that count each time 1 second. Timing / counter inside the one-chip computer similar with alarm clock, can set for, take timed time, regular time reach carry on corresponding operation by programming.
Count what is primary time, clock pulse that 51 one-chip computer input got after 12 frequency demultiplication by output of crystal oscillator inside one-chip computer then, so the timer can also regard as the periodic counter of the machine of the computer. Because each machine cycle includes 12 oscillating periods, so every machine cycle timer is added by 1, can regard the clock pulse input as machine periodic signal.
So the frequency is 1/12 of the Jingzhen frequency. If the Jingzhen frequency is 12MHz, then the timer receives one and inputs pulsing time each time is just 1 s. It was the Jingzhen of 11. 0592M that adopted in kit of this experiment, so it is about 1. 085 s to receive one and input pulsing time each time. Realize accurately it is very important in the actual project is employed regularly, because often need to use accurate timing for some time, then do the corresponding task at the moment reached regular time.
What regular time of realization of programming is that The simple introduction plays the one-chip computer STC89C52 on a breadboard first at first Inner timer resources. There are three timing / counter in STC89C52, it is T0, T1 and T2 respectively. Among them T0, T1 operating mode are the same, are introduced together. The operating mode of T2 has a difference slightly, does not describe here, there are real utility programs in the kit CD of the experiment.
Meanwhile, the timer sum counter in the one-chip computer multiplexes, record the external pulsing number with counter, but the timer is that one offered by one-chip computer internal clock is very stable to count the source. In originally saying, regard T0, T1 as the timer to introduce embodiment to use. After understanding one-chip computer inner timer resources, and then we come to make a detailed instruction to the register of the timer.
TMOD see Table 1, TCON see Table 3 Connect with the timer T0, timer T1 through internal bus and logical circuit, TMOD is used for setting up the operating mode of the timer, TCON is used for controlling the start of the timer, stopping, mark the overflow of the timer and cut off the situation. After setting up the operating mode of the timer and starting the timer to work, the timer works alone according to the operating mode presumed, does not take up the operating time of CPU again, may cut off CPU present operation when the counter is counted and overflow fully.
On if you can`t say by telling with the experiment of controlling an external LED to glimmer of the one piece in reader, recommend operating principle of one-chip computer and develop by procedure. This one will report about and introduce two very important resources within the one-chip computer -Timing / counter and interrupt system.
Say through this, readers can know the operating principle of the timer and interrupt system of the one-chip computer. Let us give an example of alarm clock at first, its vibrating bell after one minute regularly, this needs second hand to leave in the fake 60 times.
The figure illustrates a preset outage timer circuit designed for an electric cooker. The timing range of the circuit extends from 1 hour to 12 hours, adjustable via a potentiometer (PR). The timing mode operates on a counting basis, and...
The switch shut-off time delay circuit consists of a timer, optocouplers, a bridge SCR, and an SCR AC switch. When the control button is released, it allows the motor or other AC power to remain active for one hour. Upon...
This circuit employs an 87C57 microcontroller along with several peripherals to convert X-10 power-line carrier-code formats from a personal computer for use with an X-10 power-line interface in a home-control system. Software details can be found in the reference.
The circuit...
The portable counter is designed with low-power logic to minimize battery drain while maintaining good performance. Since most of the milliwatt power drain is consumed by the digital readout, the circuit blanks the LED display when there is no input...
The project originated from a request by Tony Bowler, a member of the Long Eaton Club, who sought assistance in converting a "Golden Oldie" model to electric free-flight. He selected Vic Smeed's "Debutante" to be powered by seven AE size...
The electronic switch ES1 connects the frequency-determining capacitor to the input of clock oscillator N1. The logic level present at the Dm terminal of the integrated circuit is shifted to output Q at a speed defined by P1, allowing for...
An off timer with an alarm is a straightforward project designed to indicate the end of a specified time period. The circuit utilizes four transistors. It includes a circuit diagram along with a parts list and a description of the...
This circuit is specifically designed for individuals who frequently need to wake up early in the morning. Standard alarms in electronic watches are often insufficiently loud and frequently fail to wake users. The switch circuit described here will be useful;...
This device enables remote control of various appliances (up to eight with suitable add-on expansion boards) such as lights, water heaters, air conditioning, plant watering systems, alarms, etc., via a relay. It allows users to perform actions such as watering...
We use cookies to enhance your experience, analyze traffic, and (if you allow) serve personalized ads.
By clicking Accept All, you agree to our use of cookies.
Learn more