1. We will be in Read Only mode (no new threads, replies, registration) starting at 9:00 EDT for a number of hours as we migrate the forums to upgraded software.

MPLAB Stopwatch?

Discussion in 'Programmer's Corner' started by Ben_C, May 9, 2012.

  1. Ben_C

    Thread Starter Active Member

    Oct 19, 2010
    Anybody got any ideas how to get the total execution time of all iterations of the loop using MPLAB SIM and Stopwatch?
    Excluding the final NOP and the instructions that initialize the values of X & Y

    Info: 10MHz using PIC18F4520.

    The answer is:


    Just wondering how you would get this value.. I've tried a lot of ways in MPLAB but I'm getting different times from the Stopwatch :confused:

    Code ( (Unknown Language)):
    2. [B][SIZE=3]      radix decimal [/SIZE][/B]
    3. [B][SIZE=3]x     equ 10 [/SIZE][/B]
    4. [B][SIZE=3]y     equ 11 [/SIZE][/B]
    5. [B][SIZE=3]      CLRF x [/SIZE][/B]
    6. [B][SIZE=3]      CLRF y [/SIZE][/B]
    7. [B][SIZE=3]loop [/SIZE][/B]
    8. [B][SIZE=3]      INCF x [/SIZE][/B]
    9. [B][SIZE=3]      INCF x [/SIZE][/B]
    10. [B][SIZE=3]      MOVF x,w [/SIZE][/B]
    11. [B][SIZE=3]      ADDWF x [/SIZE][/B]
    12. [B][SIZE=3]      INCF y [/SIZE][/B]
    13. [B][SIZE=3]      BNC loop [/SIZE][/B]
    14. [B][SIZE=3]      NOP [/SIZE][/B]
    15.       [B]end[/B]
    Last edited: May 9, 2012
  2. Ben_C

    Thread Starter Active Member

    Oct 19, 2010
    I got it, set a breakpoint at NOP then step through the x & y to find the time then minus this to give the total loop time.. but surely theres an easier way than stepping through x & y ??
  3. Markd77

    Senior Member

    Sep 7, 2009
    If you press the run button, it should stop at the breakpoint. Assuming MPLAB 8, there is a button on the stopwatch to zero it.