Received: from PCH.mit.edu (18.7.21.50) by mail.efplus.com (192.168.0.8) with Microsoft SMTP Server (TLS) id 8.3.485.1; Wed, 17 Feb 2021 12:31:41 -0800 Received: from PCH.MIT.EDU (localhost.localdomain [127.0.0.1]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 11HKLdpb017343; Wed, 17 Feb 2021 15:22:38 -0500 Received: from outgoing-exchange-5.mit.edu (OUTGOING-EXCHANGE-5.MIT.EDU [18.9.28.59]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 11HKLbpp017339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 17 Feb 2021 15:21:38 -0500 Received: from w92exedge4.exchange.mit.edu (W92EXEDGE4.EXCHANGE.MIT.EDU [18.7.73.16]) by outgoing-exchange-5.mit.edu (8.14.7/8.12.4) with ESMTP id 11HKLVBc012239 for ; Wed, 17 Feb 2021 15:21:37 -0500 Received: from w92expo16.exchange.mit.edu (18.7.74.70) by w92exedge4.exchange.mit.edu (18.7.73.16) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Wed, 17 Feb 2021 15:20:59 -0500 Received: from oc11exhyb2.exchange.mit.edu (18.9.1.98) by w92expo16.exchange.mit.edu (18.7.74.70) with Microsoft SMTP Server (TLS) id 15.0.1365.1; Wed, 17 Feb 2021 15:21:14 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.105) by oc11exhyb2.exchange.mit.edu (18.9.1.98) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Wed, 17 Feb 2021 15:21:14 -0500 Received: from CO2PR07CA0056.namprd07.prod.outlook.com (2603:10b6:100::24) by DM5PR01MB2762.prod.exchangelabs.com (2603:10b6:3:f4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.38; Wed, 17 Feb 2021 20:21:13 +0000 Received: from CO1NAM11FT031.eop-nam11.prod.protection.outlook.com (2603:10b6:100:0:cafe::a0) by CO2PR07CA0056.outlook.office365.com (2603:10b6:100::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Wed, 17 Feb 2021 20:21:12 +0000 Received: from mklab.ph.rhul.ac.uk (134.219.128.55) by CO1NAM11FT031.mail.protection.outlook.com (10.13.174.118) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3868.27 via Frontend Transport; Wed, 17 Feb 2021 20:21:11 +0000 Received: from mklab.ph.rhul.ac.uk (IDENT:4200@localhost [127.0.0.1]) by mklab.ph.rhul.ac.uk (8.16.1/8.15.2) with ESMTP id 11HKL9k9020996; Wed, 17 Feb 2021 20:21:09 GMT Received: from localhost (tom@localhost) by mklab.ph.rhul.ac.uk (8.16.1/8.13.8/Submit) with ESMTP id 11HKL893020992; Wed, 17 Feb 2021 20:21:08 GMT From: Tom Crane To: "piclist@mit.edu" CC: Tom Crane Sender: "piclist-bounces@mit.edu" Date: Wed, 17 Feb 2021 12:21:08 -0800 Subject: [PIC] Using MPLAB X simulator Stopwatch with XC8 assembler code Thread-Topic: [PIC] Using MPLAB X simulator Stopwatch with XC8 assembler code Thread-Index: AdcFa+jJWOgQr30ITjCfUZSu0//p1A== Message-ID: <5cb2e9b4-2e8a-59c0-8ac7-6feb345f94b@mklab.ph.rhul.ac.uk> List-Help: List-Subscribe: , List-Unsubscribe: , Reply-To: Microcontroller discussion list - Public. Accept-Language: en-US X-MS-Exchange-Organization-AuthAs: Anonymous X-MS-Exchange-Organization-AuthSource: TS500.efplus4.local X-MS-Has-Attach: X-Auto-Response-Suppress: All X-MS-Exchange-Organization-SenderIdResult: Pass X-MS-Exchange-Organization-PRD: mit.edu X-MS-TNEF-Correlator: received-spf: None (protection.outlook.com: mklab.ph.rhul.ac.uk does not designate permitted sender hosts) dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mitprod.onmicrosoft.com; s=selector2-mitprod-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=W9shKF11mTRvrtVNTEeedngdPbiOUB9/EoOvqQXbSSo=; b=ABY6Q/mBGqnirHkDTN+z6USMHj0ndE1gt6D1q2e3sA2GT9syjbPS9iwrho/GO+A5xvNzbwYpOJOl+No0yq0kzOy2KnXtG8zg/3bURfi3gJmJmFAFDUFVknjoTpyVtcgUb6UvzndkkDZiF3sWycX9MLxu/EuqMxTHYYjjYmxtdOE= authentication-results: spf=none (sender IP is 134.219.128.55) smtp.mailfrom=mklab.ph.rhul.ac.uk; mit.edu; dkim=none (message not signed) header.d=none;mit.edu; dmarc=none action=none header.from=mklab.ph.rhul.ac.uk; errors-to: piclist-bounces@mit.edu list-id: "Microcontroller discussion list - Public." list-post: x-beenthere: piclist@mit.edu x-mailman-version: 2.1.6 x-authentication-warning: mklab.ph.rhul.ac.uk: tom owned process doing -bs x-topics: [PIC] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 I am attempting to time some loop code using the simulator's Stopwatch. My= =20 target is the PIC16F1459. I am able to use the stopwatch in another project with the same target but= =20 in C rather than assembler. This small standalone project's assembler=20 code (shown below) actually contains loops generated by the XC8 C compiler= =20 from calls to __delay_ms() which I have copied from the compiler's .lst=20 file and made into a separate (Assembler) project. I am doing this=20 largely out of curiosity about the code and its timing. In the simulator I can build and debug the assembler project, set a couple= =20 of breakpoints, at the top and bottom of a loop, run to the first=20 breakpoint, clear the stopwatch and run to the second breakpoint. The=20 stopwatch however always reports 'Stopwatch cycle count =3D undefined'. I believe I have set the relevant CONFIG parameters correctly, which are=20 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 ; Configuration word 1 CONFIG FOSC=3DINTOSC CONFIG WDTE=3DOFF CONFIG PWRTE=3DOFF CONFIG MCLRE=3DOFF CONFIG CP=3DOFF CONFIG BOREN=3DON CONFIG CLKOUTEN=3DOFF CONFIG IESO=3DOFF CONFIG FCMEN=3DOFF ; Configuration word 2 CONFIG WRT=3DOFF CONFIG CPUDIV=3DNOCLKDIV CONFIG USBLSCLK=3D1 ; 1 =3D USB Clock divide-by 8 (48 MHz system input cloc= k expected) CONFIG PLLMULT=3D1 ; 1 =3D 3x PLL Output Frequency is selected CONFIG PLLEN=3DENABLED CONFIG STVREN=3DON CONFIG BORV=3DLO CONFIG LPBOR=3DOFF CONFIG LVP=3DOFF PSECT resetVec, class=3DCODE, delta=3D2 resetVec: PAGESEL main goto main PSECT code=20 inner_loop_cnt equ 0x70=20 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. =3D= 1*1*98 + 4*(230-1)*256 =3D 234594 movlw 98=20 u4197: decfsz 9,f ; NB: Register at address 09 is th= e 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. =3D= 1*1*63 + 61*(225-1)*256 =3D 3498047 movlw 63 u4207: decfsz 9,f ; NB: Register at address 09 is th= e W register goto u4207 decfsz inner_loop_cnt,f goto u4207 decfsz outer_loop_cnt,f goto u4207 nop2 END resetVec --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .