Measure Time
In today's article i am going to show you how to take advantage of an excellent feature of mplab IDE. As the title suggests, we are going to measure time of some instructions, by following those simple steps:
1. Probably the most important part is to set the frequency of your pic. To do that go to : Debugger>Settings and change the Processor frequency (i am going to use 4 MHz)
2. Next, select that: Debugger>Select Tool> 5 MPLAB sim. When you select that, a new button bar will appear(see the picture below)
These new controls can be used to simulate your code.The first button "Run", will run the code without any stop. The second button "Pause" will pause the run, the third one "Animate", does the same job as the run but you can see a green arrow moving which indicated the PC (program counter). The forth button "Step into", will move the PC one step every time you click on it. The fifth button "Step Over" it can pass "over" a subroutine, the sixth is the "Step out" button and it can move out of a subroutine. The yellow button is the "Reset" and as the name suggests resets the PC and finally is the red button named "Breakpoints", which is a "flag" that says to the simulator please stop here.
3. In order to measure time we need another tool, the "StopWatch" tool, where it can be found here: Debugger>Stopwatch
4. To count the the instructions of a part of code you must move your PC (using the buttons from the second step) to the begging of that part and then click on the "Zero" button of the stop watch, and continue to move the PC. As the PC moves you can see on the Stop watch in the first column how many instructions, and time has pass by.
That's easy isn't it? :)
No comments:
Post a Comment