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, 29 Apr 2020 22:45:33 -0700 Received: from PCH.MIT.EDU (localhost.localdomain [127.0.0.1]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 03U5ZRKo002977; Thu, 30 Apr 2020 01:36:02 -0400 Received: from outgoing-exchange-7.mit.edu (OUTGOING-EXCHANGE-7.MIT.EDU [18.9.28.58]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 03U5ZPVH002974 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 30 Apr 2020 01:35:25 -0400 Received: from oc11exedge2.exchange.mit.edu (OC11EXEDGE2.EXCHANGE.MIT.EDU [18.9.3.18]) by outgoing-exchange-7.mit.edu (8.14.7/8.12.4) with ESMTP id 03U5Ytcx016478 for ; Thu, 30 Apr 2020 01:34:56 -0400 Received: from oc11expo9.exchange.mit.edu (18.9.4.14) by oc11exedge2.exchange.mit.edu (18.9.3.18) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Thu, 30 Apr 2020 01:34:38 -0400 Received: from oc11exhyb4.exchange.mit.edu (18.9.1.100) by oc11expo9.exchange.mit.edu (18.9.4.14) with Microsoft SMTP Server (TLS) id 15.0.1365.1; Thu, 30 Apr 2020 01:35:24 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (104.47.58.169) by oc11exhyb4.exchange.mit.edu (18.9.1.100) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 30 Apr 2020 01:35:24 -0400 Received: from CO2PR04CA0166.namprd04.prod.outlook.com (2603:10b6:104:4::20) by CY4PR0101MB3175.prod.exchangelabs.com (2603:10b6:910:47::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2937.22; Thu, 30 Apr 2020 05:35:23 +0000 Received: from CO1NAM03FT012.eop-NAM03.prod.protection.outlook.com (2603:10b6:104:4:cafe::bb) by CO2PR04CA0166.outlook.office365.com (2603:10b6:104:4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2958.20 via Frontend Transport; Thu, 30 Apr 2020 05:35:23 +0000 Received: from mailscanner.virtbiz.com (208.77.216.252) by CO1NAM03FT012.mail.protection.outlook.com (10.152.80.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2921.25 via Frontend Transport; Thu, 30 Apr 2020 05:35:22 +0000 Received: from mai.hallikainen.org (s18855546.onlinehome-server.com [74.208.193.200]) by mailscanner.virtbiz.com (8.14.7/8.14.7) with ESMTP id 03U5ZIwe007313 for ; Thu, 30 Apr 2020 00:35:20 -0500 Received: from mai.hallikainen.org (localhost [127.0.0.1]) by mai.hallikainen.org (8.14.4/8.14.4) with ESMTP id 03U5ZIwi003937 for ; Wed, 29 Apr 2020 22:35:18 -0700 Received: (from apache@localhost) by mai.hallikainen.org (8.14.4/8.14.4/Submit) id 03U5ZI1b003931; Wed, 29 Apr 2020 22:35:18 -0700 Received: from 97.118.102.230 (SquirrelMail authenticated user harold) by mai.hallikainen.org with HTTP; Wed, 29 Apr 2020 22:35:18 -0700 From: Harold Hallikainen To: Microcontroller discussion list - Public. Sender: "piclist-bounces@mit.edu" Date: Wed, 29 Apr 2020 22:35:18 -0700 Subject: Re: [PIC] Jump Tables and Memory Access on PIC18F47K40 Thread-Topic: [PIC] Jump Tables and Memory Access on PIC18F47K40 Thread-Index: AdYespERl1/Rj9F7RsGJcvCUFwNOaQ== Message-ID: <757182be63fa5868013baf730fe3f133.squirrel@mai.hallikainen.org> References: <64ef7b2e-bbff-cf49-d09c-f543a7a4eb93.ref@drumon.com> <64ef7b2e-bbff-cf49-d09c-f543a7a4eb93@drumon.com> <3e970b80-16ac-bed9-4ae6-a12e8a1c7213@nicolaperotto.it> <43b41230-26f2-b5d8-5817-8af6fe045196@drumon.com> List-Help: List-Subscribe: , List-Unsubscribe: , In-Reply-To: <43b41230-26f2-b5d8-5817-8af6fe045196@drumon.com> 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: Pass (protection.outlook.com: domain of mai.hallikainen.org designates 208.77.216.252 as permitted sender) receiver=protection.outlook.com; client-ip=208.77.216.252; helo=mailscanner.virtbiz.com; 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=9OSasyPdt/JHJqRJ7Ntlp010yegm1GQnNWnCeDcI8I0=; b=umF51T3RMLFlOIJWod0EPuGrS5pTzdE5mfpIEp6YFn/KlHFvUczZSdnjlfy8FeG5Wb9i9ii+sfnAikSk+NGppoUFjM3+A/YuPXa0YAoZLbyNYf9nHBU8O28vemYmvesWgzOhxdv/QhLNOQR1sfaru2zbvUq8gGCD4Z74LvrHm38= authentication-results: spf=pass (sender IP is 208.77.216.252) smtp.mailfrom=mai.hallikainen.org; mit.edu; dkim=none (message not signed) header.d=none;mit.edu; dmarc=permerror action=none header.from=mai.hallikainen.org;compauth=pass reason=111 user-agent: SquirrelMail/1.4.22-5.el6 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: mai.hallikainen.org: apache set sender to harold@mai.hallikainen.org using -f x-spam-status: No x-greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.6.2 (mailscanner.virtbiz.com [208.77.216.252]); Thu, 30 Apr 2020 00:35:20 -0500 (CDT) x-topics: [PIC] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 You only need to mess with PCLAT, PCLATH, and PCLATU if you are directly manipulating PCL. The PC can deal with all of memory fine on its own. But when you write to it (typically for a table read), you can only write the lowe 8 bits, so the higher bits are pulled from the PCLAT. So, previously, your table was in low enough memory that PCLATU was not needed (0x00 loaded at reset was fine). Harold > Hi Nicola, > > =C2=A0 That was the piece I was missing, you nailed it! I was pretty sur= e it > had something to do with PCLAT, and even looked at it in the data sheet > but somehow missed the "upper" option. What confuses me now is how was > my program able to run correctly all this time without it? Until now, my > program was living in flash below the 64K boundary, but I would think > that crossing over that point would only require the Most Significant > Bit of the address. So I do not know how it managed to jump correctly > without that part of the address being set all this time. > =C2=A0 Anyway, I have fixed it everywhere I use it and the program is > working as expected. Wish I would have asked for help days ago! > > Thanks! > Rob > > > On 4/28/2020 4:29 PM, Nicola Perotto wrote: >> Hi Rob, >> >> >> On 29/04/2020 00:53, Rob wrote: >>> Hello Group, >>> >>> =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2= =A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ;values = are in the >>> range of 0 to xx for >>> jump table offsets >>> =C2=A0=C2=A0=C2=A0 movlw=C2=A0=C2=A0=C2=A0 high(KeyModeJumpTable)=C2= =A0=C2=A0=C2=A0 ;load high address >>> byte in PCLATH >>> =C2=A0=C2=A0=C2=A0 movwf=C2=A0=C2=A0=C2=A0 PCLATH >>> =C2=A0=C2=A0=C2=A0 rlncf=C2=A0=C2=A0=C2=A0 vKeycode,W=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ;multiply >>> by 2 >>> =C2=A0=C2=A0=C2=A0 movwf=C2=A0=C2=A0=C2=A0 vTempX=C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0= ;temp >>> storage >>> =C2=A0=C2=A0=C2=A0 movlw=C2=A0=C2=A0=C2=A0 KeyModeJumpTable >>> =C2=A0=C2=A0=C2=A0 addwf=C2=A0=C2=A0=C2=A0 vTempX,w=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ;TableIndex >>> from 0 to number of >>> items -1 >>> =C2=A0=C2=A0=C2=A0 btfsc=C2=A0=C2=A0=C2=A0 STATUS,C=C2=A0=C2=A0=C2= =A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ;check Carry >>> flag >>> =C2=A0=C2=A0=C2=A0 incf=C2=A0=C2=A0=C2=A0 PCLATH,F=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 ;gotcha!, >>> compensate for carry >>> =C2=A0=C2=A0=C2=A0 movwf=C2=A0=C2=A0=C2=A0 PCL=C2=A0=C2=A0=C2=A0 =C2= =A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 = =C2=A0=C2=A0=C2=A0 ;now >>> jump safely >> you need to use also PCLATU >> =C2=A0=C2=A0=C2=A0 movlw=C2=A0 Upper(KeyModeJumpTable) >> =C2=A0=C2=A0=C2=A0 movwf=C2=A0=C2=A0=C2=A0 PCLATU >> >> =C2=A0=C2=A0=C2=A0 Nic >> > > -- > http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 FCC Rules Updated Daily at http://www.hallikainen.com Not sent from an iPhone. --=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 .