First, the timing : the microcontroller timing refers to the time sequence of the control signal that should be sent when the microcontroller executes the instruction. The temporal correlation of these control signals is the timing of the CPU. It is a series of pulse signals with chronological order.

There are two types of timings issued by the CPU: one is used for the control of the various functional components on the chip, which are the concerns of the chip designer and have no meaning to the user. Another type of control for off-chip memory or I/O ports needs to be sent off-chip through the control pins of the device. This part of the timing is critical to the analysis of the principle of the hardware circuit. It is also the principle that software programming follows. grasp.

Second, the clock cycle, machine cycle and instruction cycle

1, clock cycle: also known as the oscillation cycle. Refers to the oscillation source period of the timing signal provided to the microcontroller. Is the smallest unit of timing.

The higher the frequency of the oscillation source, the faster the operation of the microcontroller.

The clock cycle is divided into two beats P1 and P2. The P1 signal is valid for the first half of each clock cycle, at which point the CPU typically completes the arithmetic logic operation; the P2 signal is asserted during the second half of each clock, and the data between the internal registers and registers typically occurs in this state.

2. Machine cycle: Defined as the time required to implement a particular function. The machine cycle is named according to its function, such as taking the machine cycle.

The machine cycle time of the MCS-51 is constant and is 12 crystal cycles or 6 state cycles. Divided into S1P1, SIP2; S2P1, S2P2; etc.

3. Instruction cycle: The time at which an instruction is executed.

The time to execute according to the instruction can be divided into: single cycle, double cycle and four cycle (only two instructions of multiplication and division).

The clock cycle, machine cycle, and instruction cycle are all sequential units of the microcontroller. The machine cycle is the basic timing unit for the MCU to calculate other time values ​​(such as baud rate, timer timing, etc.).

If the MCS-51 external crystal oscillator is 12MHz, then:

Clock cycle = = =0.167us;

Machine cycle = = =1us;

Instruction cycle = (1 ~ 4) = (1 ~ 4) =1 ~ 4us.

Example: If the clock frequency of the MCU is 12MHz, calculate the initial value of the timer required for the 2ms timing. (Set the timer to work in mode 1, ie the mode is 2.jpg )

Analysis: The MCS-51 has two 8-bit counters, and the counter is incremented by one for each machine cycle. When the counter is from 0FFFFH to 0000H, the timer automatically generates an overflow request. Therefore, the maximum timing of mode 1 is Tmax= 2.jpg &TImes;T0, where T0 is the time of a machine cycle. Since the frequency of the clock cycle is 12MHz, here 1.jpg .

Tmax= 2.jpg &TImes;T0=65536&TImes;1us=65.536ms.

Now to generate a 2ms timing, it is necessary to pre-position a certain initial value x in the counter to make:

(216-x) T0 = 2ms.

solution: 1.jpg

( 2.jpg -x)T0=2ms=2&TImes;10-3s

X= 2.jpg - = 216 - 2 × 103 = 63536 = F830H.

Note:

Decimal conversion method for decimal numbers and binary numbers and hexadecimal numbers

1. If the decimal number is less than 256, divide this number by 16 to get the quotient and remainder. If you write this decimal quotient in binary form, it is the upper 4 bits of the binary. Writing this decimal remainder in binary form is the lower 4 bits of the binary. Together they are the converted 8-bit binary numbers. Similarly, if the decimal quotient is written in hexadecimal form, it is the hexadecimal representation of the upper 4 bits of the binary. Writing the remainder of the decimal as a hexadecimal form is the lower 4 bits of the binary. The hexadecimal representation, together, is the hexadecimal representation converted into.

2. If the decimal number is greater than 256 and less than 65536, divide this number by 256 to get the quotient and remainder, and then divide the quotient and remainder by 16. After the quotient is divided by 16, the quotient and remainder are obtained. The quotient and remainder are in decimal form. The hexadecimal form is the hexadecimal form of the upper 4 bits of the upper 8 bits and the lower 4 bits of the upper 8 bits. The remainder and the remainder of 16 are also obtained. The quotient and remainder are also decimal, written in hexadecimal, which is the hexadecimal form of the lower 4 bits of the lower 4 bits and the lower 4 bits of the lower 8 bits.

Example: Find the binary and hexadecimal numbers of the following decimal numbers.

(1) 212; (2) 65365

Solution: (1)

212/16=13...4

If 13 is written as hexadecimal, D, 4 is written as hexadecimal, and 4 is converted to hexadecimal as:

212=D4(H)

If 13 is written as binary, 1101, 4 is written as binary, 0100, then converted to binary:

212=11010100 (B).

(2)

65365/256=255...85

(This quotient is 16 except the upper 8 and the remainder is 16 except the lower 8)

255/16=15...15

(This quotient is the upper 4 digits of the upper 8 digits, and the remainder is the lower 4 digits of the upper 8 digits)

Write quotient 15 as F in hexadecimal and F in hexadecimal as F, so the hexadecimal of the upper 8 bits is: FFH;

85/16=5...5

(This quotient is the upper 4 bits of the lower 8 bits, and the remainder is the lower 4 bits of the lower 8 bits)

Write quotient 5 as hexadecimal to 5 and remainder 5 as hexadecimal to 5, so the lower 8 hexadecimal is: 55F.

The combination of the upper 8 bits and the lower 8 bits is the hexadecimal form of this decimal number:

65365 = FF55 (H).

The binary is: 65365=FF55(H)=11111111010101010(B).

Accessories Service

We provide quick-turn injection molding by many types of materials, like ABS, PA66, PBT, TPU, TPE, PVC, PE, NYLON 6, PC, silicone, TPE, EPDM, PUR, etc. Special for some plastic parts. Our advantages in internal prototyping, bridge tooling and short-run manufacturing, which can eliminate the costly and time-consuming for customers a lot.


ETOP experienced to support one-stop cable assembly solution service, including wire harness, palstic enclosure, silicone, metal, PCBA, etc.


After customer approved 3D drawing, we can test it by 3D printer first, then move on for formal tooling once confirmed ok. And all related materials, logo, color or finishes can be chosed as customers' requirement.

Injection Molding Parts,Plastic Injection Molding,Low Cost Plastic Injection Molding,Plastic Mold Injection Molding

ETOP WIREHARNESS LIMITED , https://www.wireharness-assembling.com