What Is a Cycle Count?
Counting is the counting of unknown pulses generated from outside.
- Counting is the counting of unknown pulses generated from outside.
- Each time the timer / counter receives a count pulse, the value of the addition counter is incremented by 1; when it is full, an overflow occurs, and the counter starts counting from 0 and sets the overflow flag (TF0 = 1 or TF1 = 1).
- 1. Timing mode In this mode, the input pulse of the counter is obtained by dividing the crystal by 12. For example, the value of the crystal frequency is 12MHz plus 1. This can be used to calculate the timing time based on the count value, and the initial value of the counter can also be calculated based on the timing time.
- 2. Counting mode In this mode, the input pulse of the counter is input from the external pin (T0 or T1). When a falling edge occurs on an external pin, the value of the corresponding counter is increased by 1. If the initial value of the counter is set, the number of pulses can be calculated by reading the counter at that time.
- 1. Clock period = Oscillation period. The name is different. It refers to the period of the oscillation source that provides the clock signal to the microcontroller, which is equal to the reciprocal of the crystal frequency of the microcontroller. .
- 2. Machine cycle. The machine cycle of 8051 series microcontrollers = 12 * clock cycles. The reason for this is that a single clock cycle can't do a complete thing at all (such as fetching instructions, writing registers, reading registers, etc.), and 12 clock cycles can basically complete a basic operation.
- 3. Instruction cycle. A machine cycle can complete a basic operation, but an instruction often requires a combination of multiple basic operations to complete. The time required to complete an instruction is the instruction cycle. Of course, different instructions have different instruction cycles. It's the same. In MCS-51 system, there are single-cycle instructions, two-cycle instructions and four-cycle instructions.
- 4. State cycle: Each state cycle is twice the clock cycle, which is obtained after the oscillation cycle is divided by two.
- Oscillation cycle * 12 = State cycle * 6 = Machine cycle.