-
The 2l solution is very good.
However, if the program is too long and time-consuming, it is also very laborious to observe. My approach is to set the instruction, when the program starts to execute, output a state on the single-chip microcomputer port, output another state when the program is executed, and then use the oscilloscope to monitor the time required for the state change of this port, you can calculate the program execution time more accurately, this method is suitable for observing I2C bus, SPI bus, USART and other time-consuming and unknown programs are very effective.
-
Enter the debug state, step into the window, and in the window on the left side of the screen, you can find the time and number of cycles that the program takes to run.
-
The program execution time can be measured by setting breakpoints.
-
1. Enter the debugging mode first.
2. You can see that there is a running time area on the left sidebar.
3. You can carry out single-step debugging, the time will change, pay attention to set your crystal oscillator, this will affect your running time.
-
Put the program into Keil In the debugging environment, set the breakpoint of that part of the program, and then click to execute at full speed, and in the left sidebar there is a time clock in microseconds.
-
Yes, the part of the program you want to know has a breakpoint at the beginning and end, running at full speed. In the left column, you can see the running time.
-
This time has something to do with your crystal oscillator!
-
It's hard to calculate the time directly, and different microcontrollers have different command times. And depending on the specifics, there are several directives that need to be seen in the compilation. It is best to test the time with an oscilloscope.
In addition, this delay can be affected by interrupting the program.
To want a precise time, it's best to use a timer.
-
110 It's not calculated, it's tried.
-
Look at it with an oscilloscope, or disassemble it to look up the instruction cycle.
-
First, whether the crystal oscillator is set up as you expected.
Second, you should be a program in C language, not assembly, and third, it depends on the actual running time, so you can see it clearly if you want to disassemble.
-
You can look at the crystal oscillator of the single-chip microcomputer, such as 12MHz, then the time of running once depends on the instruction, some single cycles, some two cycles, such as the addition instruction is two cycles, and it takes two cycles of time to do an addition 1 12000000 * 2 (seconds), and so on for other times.
-
c Language programs, whose working time, do not have a formula for calculating.
I can only experiment by myself and slowly explore the rules.
-
with a timer; #include
clock_t begin;
Start recording the time.
begin=time();
You want to test the program of the time.
begin=time()-begin;Get the time when the test program runs.
printf("%ld",begin/clocks_per_sec);The output time is in seconds, s.
-
#include
clock_t begin;
Start recording the time.
begin=time();
You want to test the program of the time.
begin=time()-begin;Get the time when the test program runs.
printf("%ld",begin/clocks_per_sec);The output time is in seconds, s.
-
Single-task "OS" is not easy to achieve, and it is best to monitor it through an external timer, such as the level change of a certain IO.
。If you have to do it internally, it's hard to do it in microseconds... Reaching milliseconds, it's still easier.
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
Hello: I wrote the program:
#include >>>More
Landlord, org 0030h.
How do you understand what I mean? >>>More
Summary. Please tell me about the specific question, dear. >>>More
void key0()
if(p1_0!=1) *If the key 0 is pressed. >>>More