[PIC] Using MPLAB X simulator Stopwatch with XC8 assembler code

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PIC] Using MPLAB X simulator Stopwatch with XC8 assembler code

TPCpiclist
I am attempting to time some loop code using the simulator's Stopwatch. My
target is the PIC16F1459.

I am able to use the stopwatch in another project with the same target but
in C rather than assembler.  This small standalone project's assembler
code (shown below) actually contains loops generated by the XC8 C compiler
from calls to __delay_ms() which I have copied from the compiler's .lst
file and made into a separate (Assembler) project.  I am doing this
largely out of curiosity about the code and its timing.

In the simulator I can build and debug the assembler project, set a couple
of breakpoints, at the top and bottom of a loop, run to the first
breakpoint, clear the stopwatch and run to the second breakpoint.  The
stopwatch however always reports 'Stopwatch cycle count = undefined'.

I believe I have set the relevant CONFIG parameters correctly, which are
derived from those generated by MCC for the C project.

Any ideas?

Thanks
Tom Crane

I am using MPLAB X IDE v.5.45.
-----------------------------------------------------------------------

processor       16F1459

  #include <xc.inc>
; Configuration word 1
CONFIG FOSC=INTOSC
CONFIG WDTE=OFF
CONFIG PWRTE=OFF
CONFIG MCLRE=OFF
CONFIG CP=OFF
CONFIG BOREN=ON
CONFIG CLKOUTEN=OFF
CONFIG IESO=OFF
CONFIG FCMEN=OFF
; Configuration word 2
CONFIG WRT=OFF
CONFIG CPUDIV=NOCLKDIV
CONFIG USBLSCLK=1 ; 1 = USB Clock divide-by 8 (48 MHz system input clock expected)
CONFIG PLLMULT=1  ; 1 = 3x PLL Output Frequency is selected
CONFIG PLLEN=ENABLED
CONFIG STVREN=ON
CONFIG BORV=LO
CONFIG LPBOR=OFF
CONFIG LVP=OFF


PSECT resetVec, class=CODE, delta=2
resetVec:
PAGESEL main
goto main

PSECT code
inner_loop_cnt     equ     0x70
outer_loop_cnt     equ     0x71

;main.c: 380:         _delay((unsigned long)((64)*(48000000/4000.0)));
main:
        movlw   4
        movlb   4       ; select bank4
        movwf   outer_loop_cnt
        movlw   230
        movwf   inner_loop_cnt           ; 3-deep nested loop count no. = 1*1*98 + 4*(230-1)*256 = 234594
        movlw   98
u4197:
        decfsz  9,f                      ; NB: Register at address 09 is the W register
        goto    u4197
        decfsz  inner_loop_cnt,f
        goto    u4197
        decfsz  outer_loop_cnt,f
        goto    u4197
        nop
l5195:




;main.c: 382:         _delay((unsigned long)((1000)*(48000000/4000.0)));
        movlw   61
        movlb   4       ; select bank4
        movwf   outer_loop_cnt
        movlw   225
        movwf   inner_loop_cnt           ; 3-deep nested loop count no. = 1*1*63 + 61*(225-1)*256 = 3498047
        movlw   63
u4207:
        decfsz  9,f                      ; NB: Register at address 09 is the W register
        goto    u4207
        decfsz  inner_loop_cnt,f
        goto    u4207
        decfsz  outer_loop_cnt,f
        goto    u4207
        nop2

END resetVec
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist