The interrupt setting of C51 microcontroller, 51 microcontroller has several interrupts

Updated on technology 2024-03-05
16 answers
  1. Anonymous users2024-02-06

    Scheduled interrupts, external interrupts?

  2. Anonymous users2024-02-05

    There are a total of 5 types of interrupts, and the priority is as follows from top to bottom:

    1) The function name ()interrupt 0 {} corresponds to the external interrupt 0;

    2) Function name ()interrupt 1 {} corresponds to timer counter 0 interrupt;

    3) The function name ()interrupt 2 {} corresponds to external interrupt 1;

    4) Function name ()interrupt 3 {} corresponds to the timer counter 1 interrupt;

    5) The function name ()interrupt 4 {} corresponds to the serial port interrupt;

    51 MCU is a collective term for all MCUs compatible with the Intel 8031 command system. The ancestor of this series of single-chip microcomputer is Intel's 8004 single-chip microcomputer, and later with the development of flash ROM technology, 8004 single-chip microcomputer has made great progress, becoming one of the most widely used 8-bit single-chip microcomputer, its representative model is ATMEL's AT89 series, which is widely used in industrial measurement and control systems.

    Many companies have launched compatible models of the 51 series, which will have a large market for a long time to come. 51 single-chip microcomputer is a basic entry single-chip microcomputer, or the most widely used one. It should be noted that the 51 series microcontroller generally does not have self-programming capabilities.

  3. Anonymous users2024-02-04

    A timer is what program is executed after how many cycles have elapsed.

    An interrupt interrupts a running program when it is interrupted and does not affect it when there is no interrupt request.

    When there is an interrupt or the interrupt priority is higher than the running program, an interrupt is generated and enters the interrupted program.

  4. Anonymous users2024-02-03

    px0(, external interrupt 0 priority bit;

    pt0(, timing counter t0 priority setting bit;

    px1(, external interrupt 0 priority setting bit;

    pt1(, timing counter t1 priority setting bit;

    ps (, serial port priority setting bit;

    pt2 ( timing counter t2 priority setting bit.

    Priorities are divided in this way.

  5. Anonymous users2024-02-02

    A timer is a hardware operation that increases or decreases a fixed register at a fixed frequency, and interrupt is a kind of processing provided for unexpected events.

    When the timer increases or decreases to a certain critical value (usually overflow), an interrupt signal is generated, providing a trigger source for the interrupt responder.

    After the program receives the trigger signal of the interrupt source, the hardware automatically points the program pointer to the interrupt responder after the current instruction is completed, so as to execute the interrupt response program.

  6. Anonymous users2024-02-01

    Timers are only related to timing count interrupts. That is, when the timing count value reaches the maximum value, the timer overflows, resulting in an interrupt, that is, entering the interrupt program.

  7. Anonymous users2024-01-31

    Features fast and punctual.

    The advantages are the features.

    Disadvantages: If not handled properly, the program is easy to run away, and the variables are inexplicably modified.

  8. Anonymous users2024-01-30

    The traditional microcontroller interrupts 5. It includes two external interrupts (int0, int1), three timed interrupts (t2, t1, t0), and one serial interrupt (uart).

    Features: Simple, intuitive, easy to control.

    Advantages: Fast response, level and clock triggered interrupts, count interrupts, timing interrupts, interrupts from serial data, sleep interrupts, wake mode interrupts.

    Disadvantages: Only a single-task mechanism can be used, the program can only be executed sequentially, lack of flexibility, can only use interrupt functions to process some short tasks in real time, and it is extremely inconvenient to use in more complex applications.

  9. Anonymous users2024-01-29

    Pros, responsive and accurate.

    Downside, the program is error-prone.

  10. Anonymous users2024-01-28

    51 single-chip microcomputer 12m crystal oscillator, timing counter clock is 1us, so a single 16-bit timing counter can achieve the maximum timing time: 65536 * 1us=, so in the case of 12m crystal oscillator, with a single 16-bit timer can not get 100ms timing. In this case, you can replace the crystal oscillator with a lower frequency or use the following two software methods:

    1. Timer accumulation. A count value is used to record the number of interruptions in the timer. For example, if you set a timer to interrupt for 10ms, use a count value to record the number of interruptions of the timer, and add 1 to each interrupt count, so that when the count value is 10, the timer will be interrupted 10 times, that is, 100ms, and then the count value will be cleared to 0 and recounted.

    There will be a small error in this method, because it takes a little time to manipulate the counting value, which is relatively short.

    timer counters in series. One is used as a timer and one as a counter. When the timer is interrupted, a pulse is output as the counter's counting pulse, a counting value is set, and the count is interrupted when the count is full. The principle of the total timed time is the same as above.

    As for the operation of the timing counter, the two upstairs made it very clear.

  11. Anonymous users2024-01-27

    The timer needs to set an initial value, and then when the timer is started, the timer will increase this initial value by 1 in each cycle until it overflows, and a timing interrupt will be generated.

    If the single-chip microcomputer is a 12m crystal oscillator, the timer will add 1 to 1ms, if you don't know it, you can look at the relationship between the various cycles of the single-chip microcomputer.

    The following is an example of a certain timer t0 to introduce the setting of the initial value.

    th0=(65536-100)/256;

    tl0=(65536-100)%256;

    Th0 and TL0 together form a 16-bit timer, and its initial value is set to 100 before overflowing, so that after 100ms, the timer will overflow and produce an interrupt.

    I won't talk about how to set the timer working mode, how to start the timer and interrupt.

  12. Anonymous users2024-01-26

    The timer is interrupted when the total number reaches ffffh! Then you want it to count 10,000, do you use ffff (hexadecimal) minus 10,000 (decimal) as the initial value of the count? th0=-(10000/256);tl0=-(10000%256) is the same as ffff (hexadecimal) minus 10000 (decimal).

    from th0=-(10000 256); tl0=-(10000%256) starts counting until 10000 is just full. It's the same as subtracting 10,000 (decimal numbers) from ffff (hexadecimal!! It's easier to write, don't count !!

    Just look at the original code and the complement code. The complement of a positive number is the corresponding binary number, and the sign bit is zero, and the complement of a negative number is the binary number corresponding to its absolute value, and the binary number is inverse by bit and then add one, and the sign bit is one. If an unsigned number does not take into account the symbol, then the result is the same as subtracting its absolute value from FFFF.

  13. Anonymous users2024-01-25

    I can't find the include file, I can't use scanf and printf in 51 microcontrollers!

  14. Anonymous users2024-01-24

    OK. It depends on whether your object scans for a low level output.

    ex0=1;

    it0=1;

    ea=1;

  15. Anonymous users2024-01-23

    Yes, assign the timer disposal to ff, and start the timer, external counting.

  16. Anonymous users2024-01-22

    When any of the following conditions occur, the interrupt response is blocked, that is, the interrupt program will not be entered.

    1) a service interruption of the same level or level is in progress;

    2) The current machine cycle is not the last cycle of the current instruction, and no interrupt request will be responded to until the instruction is executed;

    3) RETI or read and write operations to IE and IP, at least one other instruction must be executed to respond;

    During the S5P2 of each machine cycle, the CPU samples the interrupt sources in turn, and in the above case, the interrupt requests are locked in their respective interrupt flags, and then queried in order for the next machine cycle. That is, the sibling interrupt will not be interrupted, where the ti has been cleared, and this interrupt will no longer respond after exiting.

    There is also a slight problem, the interrupter program should perform an if(ri) condition judgment at the beginning, otherwise it may read junk data.

Related questions
5 answers2024-03-05

void timers() interrupt 0count++;

tr0=1; >>>More

9 answers2024-03-05

16 and 7 are the number of bytes between the PC and the data ** at the time of the lookup command. >>>More

4 answers2024-03-05

You use a P1 port to control the dynamic scanning of 8 digital tubes, and the dynamic scanning display of digital tubes needs to be blanked. >>>More

19 answers2024-03-05

First of all, it is recommended that you use a serial port. >>>More

6 answers2024-03-05

Not at all contradictory. The purpose of each port of the single-chip microcomputer is different, the structure is also different, you say that the current of the LED MA level can make it brighter, which refers to the rated brightness, different power has different brightness, you can't compare the 1 mm patch with the 10 mm one, can you understand? If you want to use LEDs at the P2 port, there are two ways. >>>More