How to calculate microcontroller program execution time in Keil

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

    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.

  2. Anonymous users2024-02-10

    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.

  3. Anonymous users2024-02-09

    The program execution time can be measured by setting breakpoints.

  4. Anonymous users2024-02-08

    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.

  5. Anonymous users2024-02-07

    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.

  6. Anonymous users2024-02-06

    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.

  7. Anonymous users2024-02-05

    This time has something to do with your crystal oscillator!

  8. Anonymous users2024-02-04

    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.

  9. Anonymous users2024-02-03

    110 It's not calculated, it's tried.

  10. Anonymous users2024-02-02

    Look at it with an oscilloscope, or disassemble it to look up the instruction cycle.

  11. Anonymous users2024-02-01

    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.

  12. Anonymous users2024-01-31

    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.

  13. Anonymous users2024-01-30

    c Language programs, whose working time, do not have a formula for calculating.

    I can only experiment by myself and slowly explore the rules.

  14. Anonymous users2024-01-29

    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.

  15. Anonymous users2024-01-28

    #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.

  16. Anonymous users2024-01-27

    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.

Related questions
4 answers2024-06-03

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

5 answers2024-06-03

Hello: I wrote the program:

#include >>>More

18 answers2024-06-03

Landlord, org 0030h.

How do you understand what I mean? >>>More

2 answers2024-06-03

Summary. Please tell me about the specific question, dear. >>>More

8 answers2024-06-03

void key0()

if(p1_0!=1) *If the key 0 is pressed. >>>More