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; Thu, 17 Sep 2020 20:39:06 -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 08I3Ribk010975; Thu, 17 Sep 2020 23:28:07 -0400 Received: from outgoing-exchange-1.mit.edu (OUTGOING-EXCHANGE-1.MIT.EDU [18.9.28.15]) by PCH.mit.edu (8.14.7/8.12.8) with ESMTP id 08I3RhEY010972 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 17 Sep 2020 23:27:43 -0400 Received: from w92exedge3.exchange.mit.edu (W92EXEDGE3.EXCHANGE.MIT.EDU [18.7.73.15]) by outgoing-exchange-1.mit.edu (8.14.7/8.12.4) with ESMTP id 08I3RdkP028179 for ; Thu, 17 Sep 2020 23:27:43 -0400 Received: from w92exhyb8.exchange.mit.edu (18.7.71.113) by w92exedge3.exchange.mit.edu (18.7.73.15) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Thu, 17 Sep 2020 23:27:27 -0400 Received: from oc11exhyb4.exchange.mit.edu (18.9.1.100) by w92exhyb8.exchange.mit.edu (18.7.71.113) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 17 Sep 2020 23:27:42 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.174) by oc11exhyb4.exchange.mit.edu (18.9.1.100) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Thu, 17 Sep 2020 23:27:42 -0400 Received: from MWHPR18CA0047.namprd18.prod.outlook.com (2603:10b6:320:31::33) by SN6PR01MB5182.prod.exchangelabs.com (2603:10b6:805:c1::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.14; Fri, 18 Sep 2020 03:27:41 +0000 Received: from CO1NAM03FT018.eop-NAM03.prod.protection.outlook.com (2603:10b6:320:31:cafe::85) by MWHPR18CA0047.outlook.office365.com (2603:10b6:320:31::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.11 via Frontend Transport; Fri, 18 Sep 2020 03:27:41 +0000 Received: from mailscanner.virtbiz.com (208.77.216.252) by CO1NAM03FT018.mail.protection.outlook.com (10.152.80.174) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3391.15 via Frontend Transport; Fri, 18 Sep 2020 03:27:40 +0000 Received: from s18855546.onlinehome-server.com (s18855546.onlinehome-server.com [74.208.193.200]) by mailscanner.virtbiz.com (8.14.7/8.14.7) with ESMTP id 08I3RZk7001351 for ; Thu, 17 Sep 2020 22:27:39 -0500 Received: from mai.hallikainen.org (localhost [127.0.0.1]) by s18855546.onlinehome-server.com (8.14.4/8.14.4) with ESMTP id 08I3RYPn001346 for ; Thu, 17 Sep 2020 20:27:34 -0700 Received: (from apache@localhost) by mai.hallikainen.org (8.14.4/8.14.4/Submit) id 08I3RY6B001343; Thu, 17 Sep 2020 20:27:34 -0700 Received: from 71.218.16.216 (SquirrelMail authenticated user harold) by mai.hallikainen.org with HTTP; Thu, 17 Sep 2020 20:27:34 -0700 From: Harold Hallikainen To: Microcontroller discussion list - Public. Sender: "piclist-bounces@mit.edu" Date: Thu, 17 Sep 2020 20:27:34 -0700 Subject: Re: [PIC] Compare Mode Thread-Topic: [PIC] Compare Mode Thread-Index: AdaNbUNvZE+HHwFpS+Ohr6LSuPOVEg== Message-ID: <90282454b138aea99cb14bcc64158ad8.squirrel@mai.hallikainen.org> References: <3004e008-5a49-3bb2-a654-f6e012844dc1@audiovisualdevices.com.au> List-Help: List-Subscribe: , List-Unsubscribe: , In-Reply-To: <3004e008-5a49-3bb2-a654-f6e012844dc1@audiovisualdevices.com.au> 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: TempError 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=4x3uOtHIzHaoNW/BZ0Xr6nRFKI4FzhiDgd6Gw9lJShI=; b=G6Du34XVeWj8HXOMjVT1XlOzR86WBJo3/gJ8oSymz/KxfHuW82YdJOiWhq/bFr8pSJMsT6yEwLx2VMu69QqdQDTdUMv9dmMl6rjdssIjbWWD1NziX+n6HETWHX0i2sXI7NXMmZGp+qZKvAPmzSgNzsO06OJoPpRfeQYcnn3x9K8= 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; 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-greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mailscanner.virtbiz.com [208.77.216.252]); Thu, 17 Sep 2020 22:27:39 -0500 (CDT) x-topics: [PIC] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 This sounds like a phase control light dimmer! I did a four channel one with a single CCP register, figuring out which triac I needed to turn on first, loading the CCP register with that value, then when I got the interrupt, turned on the triac and loaded the CCP register with the next value I needed. I have not looked at that in a long time (more than 10 years). I think I started with a 17C42 and ended up using an 18F452. If indeed you're doing a light dimmer, I'd load the CCP registers and clear the timer, and turn off the outputs on a zero cross. Then each CCP interrupt would turn on an output and clear the interrupt flag. This is probably not much help since it's been more than 10 years since I worked on it. Good luck! Harold > I have a PIC16F1828 running from the internal 4MHz oscillator. I use the > various timers regulatly, but don't recall using the CCP modules before. > I'm using MPLABX and XC8. > > There is a 100Hz interrupt (INT0) from an optocoupler for zero cross > sync. I've set timer 1 to Fosc/4 and no prescaler, so that should be > ticking over at 1us increments. I'm trying to use CCP1, CCP2 and CCP3 to > get an interrupt at three different points from the zero cross interrupt. > > CCP1CON is set to 0x0A (compare with interrupt) and CCPR1 is set to 5000 > (decimal) when the INT0 interrupt occurs. I'm clearing a pin when INT0 > occurs and setting it when the CCP1IF interrupt is serviced. > > I'm getting a much longer period (LED off time) than the 5ms I expected. > The timing is not even proportional to the values I enter. Am I missing > something fundamental about how CCP works? > > David... > -- > 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 .