| ??? 01/27/00 17:50 Read: times |
#1322 - RE: Calculate time of the loop: |
Well I did a small time measuring routine that I used in my 8051 project before Keil PK51 professional developers package with a very powerful simulator.
The routine was written in C and used timer to get the time. You need an output device to display the result - can be your serial port that I have used. The routine is calibrated so that when running: start_timer() stop_timer() You get the result 0 cycles. You can easily modify the routine or write it in assembly language. Routine start_timer () sets timer T0 in 16 bit mode and starts it without effecting the operating mode of timer T1. Routine stop_timer () stops counting and displays the result. To use it is very simple: start_timer(); your_routine_to_measure_execution_time (); stop_timer (); void start_timer(); void stop_timer(); void start_timer() { TMOD = (TMOD & 0xf0) | 0x01; TH0 = 0; TL0 = 0; TF0 = 0; TR0 = 1; } void stop_timer() { TR0 = 0; if (TF0 == 1) printf("nTimer T0 overflow."); else printf("nTimer T0 = %u cycles.",TH0 * 256 + TL0 - 7); } |
| Topic | Author | Date |
| Calculate time of the loop: | 01/01/70 00:00 | |
| RE: Calculate time of the loop: | 01/01/70 00:00 | |
| RE: Calculate time of the loop: | 01/01/70 00:00 | |
| RE: Calculate time of the loop: | 01/01/70 00:00 | |
| RE: Calculate time of the loop: | 01/01/70 00:00 | |
RE: Calculate time of the loop: | 01/01/70 00:00 |



