![]() |
How to measure execution time? And code size?
Can someone describe a simple way to measure how much of the 26 ms time budget is being used? As I add code I would like to know how close I am coming to the limit.
Also, how do I know how close I am to the memory limits for code and data? Thanks all, Norm |
Re: How to measure execution time? And code size?
Add a breakpoint at the top of process_data_from_master_uP and at the bottom. Then use the simulator and the stopwatch to calculate the time different between the 2 breakpoints.
For the memory thing, use the simulator and just look at the memory map of program and data memory. |
Re: How to measure execution time? And code size?
What simulator? I tried one in mplab, and it got stuck in one of the transmission loops!
|
Re: How to measure execution time? And code size?
Quote:
Some example code (place this at the very beginning of your code): static char TimingFlag; if (TimingFlag) TimingFlag = 0; else TimingFlag = 1; Then immediately set the digital I/O pin equal to TimingFlag. This code will produce a square wave on the scope. The time that the wave is high (or low) is your cycle time. I hope this helps. -Chris |
Re: How to measure execution time? And code size?
Quote:
For the default code you get 112,840 to 112,892 loops per second or ~42 (THE_ANSWER) ticks per loop for the basic default program (results may vary). There are a couple of ways to check memory utilization. 1) When you open the .hex file in the IFI_Loader there is a text string at the bottom of the IFI_Loader window that tells you how much space the .hex file uses. For instance, the FRC default code will show: "Total Bytes 2C90, Erase Size B5, Flash 800-3510, MemSize 2D10" 2)A memory map can be generated by MPLAB whenever you compile your code. You have to turn it on by going to Project -> Build Options... -> Project then click on the "MPLINK Linker" tab, then click on "Generater map file". After you build your project look in the project directory for a text file ending in ".map" just a little way down the file it will have a section that looks like: Code:
Code:
e.g., |
Re: How to measure execution time? And code size?
Quote:
|
Re: How to measure execution time? And code size?
Quote:
|
Re: How to measure execution time? And code size?
measureing timeing on the simulator wont tell you what you want to know, because the SW will be running on your PC, not on the target system (the RC) which is what really matters.
|
Re: How to measure execution time? And code size?
Quote:
realExecutionTime = simulatedClockCycles * realClockPeriod I'll have to have a closer look at the simulator. At this point I feel like I don't have time to go up another learning curve. But I should probably do it anyway... |
Re: How to measure execution time? And code size?
Quote:
My first post only works if you're running the loop time as fast as possible. It doesn't work if you're setting your loop time with an interrupt. To measure this way do the following: 1) At the VERY BEGINNING of your loop, set a digital I/O pin high. 2) At the VERY END of your loop, set the same digital I/O pin low. 3) Measure the pin voltage on a scope. The amount of the the pin stays high is the amount of time that your code takes to run. (By the way, this is how code time is usually measured in industry.) |
Re: How to measure execution time? And code size?
Quote:
Ooo, I like the idea of using a scope. Technology that I understand! But I think the code you suggest may not give me what I want. I think the code you suggest would toggle a pin with every 26 ms cycle of the code, so the high and low portions of each square wave cycle would each be 26 ms, regardless of how long my code was taking. Your code was: Code:
static char TimingFlag;How about this instead, in main.c. Note the two lines with ***: Code:
while (1) /* This loop will repeat indefinitely. */ |
Re: How to measure execution time? And code size?
Quote:
|
Re: How to measure execution time? And code size?
Yeah I didn't mean an actual stopwatch, there is a function in the simulator that keeps track of time based on chip speed. It's called the "stopwatch".
But the oscilloscope idea sounds easier (assuming you have an oscilloscope you can use). [EDIT]Oops... |
Re: How to measure execution time? And code size?
Quote:
|
Re: How to measure execution time? And code size?
engineers have to learn to listen to what people mean, not what they say :)
|
| All times are GMT -5. The time now is 16:01. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi