-
void timers() interrupt 0count++;
tr0=1;
void timer0() interrupt 1th0=(65536-50000)/256;
tl0=(65536-50000)%256;
t++;Each drop edge arrives when conut self-plus 1. Turn on a timer, calculate the count value within a certain time t, the main program is easy to write, and then write an h=count t statement, h is the frequency. The general idea is this, you can write the details yourself.
-
You sample the signal with an external interrupt and then use a timer to calculate the frequency.
-
Interrupt interrupt, which means to disconnect from the middle, hehe, for example, you now have a task to count from 1 to 1000, and when you count to 50 or other data, someone asks you to hand something, you stop counting and hand things to others, and after handing things you find that you only count to 50, then you continue to count until you count to 1000 and complete the task.
This is what the interrupt of the MCU means, your main function has been executing in a loop, and the interrupt is the corresponding interrupt function execution of the interrupt program due to the change of the level of the external interrupt pin during the running of your main program.
Hope it helps.
-
CPU, ** processing unit, data must be handed over to the CPU for calculation (now some peripherals also have a certain ability to calculate data), for example, the printer wants to print, to carry out relevant calculations, it is necessary to submit the data to the CPU, and at this time the CPU is processing other things, then the printer has to apply to the CPU for the right to use. The printer says, "Hey, CPU, I'm going to print something, calculate it for me", and when the CPU receives this request, it will decide whether to stop what it is doing and help the printer process the data. If the CPU responds to the request, the CPU will say, "Oh, it's the printer brother, okay, I'll stop what I'm doing and help you," and the CPU interrupts and processes the printer's data.
Some interrupts are maskable, some are unmaskable, non-maskable, which means that the CPU has to stop to process the interrupted transaction. Blockable, that is, the things that the CPU is dealing with are more important, regardless of the interrupt request of the peripherals first.
-
After looking for a few timing counter questions, external interrupts should be simple.
1. Use the timing counter t0 to flash the LED at 1Hz from the square wave with an output period of 1s, and set the crystal oscillator frequency to 12MHz.
2. Utilize the timing counter T1 to generate a timing clock, control 8 light-emitting diodes by P1 port, make the 8 indicator lights flash one by one in turn, and the flashing frequency is 10 times a second (8 lights are lit up once in turn for a cycle), and cycle.
3. Use two timers to control the sound of the buzzer at the same time, the timer 0 controls the frequency, the timer 1 controls the duration of the same frequency, and the square wave of 1, 10, 50, 100, 200, 400, 800, 1K (Hz) is output in turn at an interval of 300ms.
4. Use a timer to display sequentially on the 6-digit digital tube at an interval of 500ms....c, d, e, f, repeat.
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
First of all, it is recommended that you use a serial port. >>>More
time=th1*256+tl1;
This is to use the timer t1 to count, time=th1*256+tl1; This is to calculate the time according to the count value of the timer counter t1, th1 is the higher 8 bits of the counter, and the count result is of course multiplied by 256 times, plus the value of the lower 8 bits tl1. >>>More
For how to learn single-chip microcomputer, I think it is still necessary to master its hardware, storage structure, assembly must be proficient, because the introduction of assembly is very helpful and understand the hardware, if you learn single-chip microcomputer, and then learn other, such as arm, at this time you can only be familiar with the assembly, but the first time to learn single-chip microcomputer, assembly, must be proficient, I mean at first do not use c to write programs, write with sinks, write can 10 20 assemblers, your assembly will go to the next level, In the future, you'll be using C for development, and you'll see how comfortable it is to optimize C with a solid foundation for assembly. Regarding the study of microcontrollers, I think it is necessary to have: >>>More
Some of the character storylines in League of Legends are made up, and many are copied, such as Monkey King