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; Sun, 24 Jan 2021 09:56:18 -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 10OHivVK016997; Sun, 24 Jan 2021 12:48:13 -0500 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 10OHit7V016993 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Sun, 24 Jan 2021 12:44:55 -0500 Received: from w92exedge4.exchange.mit.edu (W92EXEDGE4.EXCHANGE.MIT.EDU [18.7.73.16]) by outgoing-exchange-7.mit.edu (8.14.7/8.12.4) with ESMTP id 10OHisRI015477 for ; Sun, 24 Jan 2021 12:44:54 -0500 Received: from OC11EXPO27.exchange.mit.edu (18.9.4.98) by w92exedge4.exchange.mit.edu (18.7.73.16) with Microsoft SMTP Server (TLS) id 15.0.1293.2; Sun, 24 Jan 2021 12:44:32 -0500 Received: from oc11exhyb6.exchange.mit.edu (18.9.1.111) by OC11EXPO27.exchange.mit.edu (18.9.4.98) with Microsoft SMTP Server (TLS) id 15.0.1365.1; Sun, 24 Jan 2021 12:44:54 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.40) by oc11exhyb6.exchange.mit.edu (18.9.1.111) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Sun, 24 Jan 2021 12:44:54 -0500 Received: from DM6PR07CA0055.namprd07.prod.outlook.com (2603:10b6:5:74::32) by MW4PR01MB6130.prod.exchangelabs.com (2603:10b6:303:75::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.13; Sun, 24 Jan 2021 17:44:53 +0000 Received: from DM6NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:5:74:cafe::d4) by DM6PR07CA0055.outlook.office365.com (2603:10b6:5:74::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Sun, 24 Jan 2021 17:44:53 +0000 Received: from premium47-2.web-hosting.com (68.65.123.242) by DM6NAM11FT061.mail.protection.outlook.com (10.13.173.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.12 via Frontend Transport; Sun, 24 Jan 2021 17:44:52 +0000 Received: from 107-145-246-199.res.spectrum.com ([107.145.246.199]:55990 helo=[192.168.10.106]) by premium47.web-hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1l3jRO-002xMc-Qh; Sun, 24 Jan 2021 12:44:51 -0500 From: Neil To: "piclist@mit.edu" Sender: "piclist-bounces@mit.edu" Date: Sun, 24 Jan 2021 09:44:44 -0800 Subject: Re: [PIC] PIC18F I2C Start/Stop condition detection Thread-Topic: [PIC] PIC18F I2C Start/Stop condition detection Thread-Index: AdbyejfxUrdqAqkqRLKQDw/m7n3YcQ== Message-ID: <600DB20C.1090901@narwani.org> References: <600D0BC7.20406@narwani.org> List-Help: List-Subscribe: , List-Unsubscribe: , In-Reply-To: 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: narwani.org does not designate permitted sender hosts) dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=narwani.org ; s=default; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:Reply-To:To:References:Subject:Sender:Cc: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=soFkL5LQus7hUHksFi6njwfOmTDJ5WhTQYKHPf3D8CY=; b=rkz9658mu00cbPq+XMygbhlqeC 6c4Vod6OWwsu9y5xAT5RtVsBBLhU5fwH5Byry1N2wvvIlGWs7TKtkyLtatGzdPOVe3v2mJPsCn/su 3oqFbsm890/LpAcktxWVjQc4AMvBspfzVWyXipp3V+fePz7k+wvDr+C29ij87+X4wwFrEy5aRkukB S0wdrC9vuhe9t+MLMaGINIDRHB9jDohfIp+i+n3ifcdVw5voYHh6YZXtQsIU+MrbQ68iefEWiBhZh jEDYO+BddLykF3nV+8Q6pfWHhT0u8zlvThHQutSeEFEGIIWnZy9yL625N9LxTDaKcrTuOQaH5Y14C QaZ5E95A==; authentication-results: spf=none (sender IP is 68.65.123.242) smtp.mailfrom=narwani.org; mit.edu; dkim=pass (signature was verified) header.d=narwani.org;mit.edu; dmarc=bestguesspass action=none header.from=narwani.org; user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 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-source-args: x-source-dir: x-antiabuse: Sender Address Domain - narwani.org x-source: x-authenticated-sender: premium47.web-hosting.com: ca4@narwani.org x-topics: [PIC] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Joep, I was looking at fig 26-15, because I was not using AHEN & DHEN. Even with the behaviour shown in fig 26-17, I was wondering why=20 clearing this flag would not work, but I just this minute realized (from=20 the SSPxSTAT register definition in fig 26.9.1) that the P and S bits=20 are read-only. So this explains why my code detects the S bit every=20 time I receive a byte in the ISR. I'm not sure now how they expect this feature to be used. My thought=20 was that I'd detect the S bit, initialize my receiving buffer, capture=20 bytes, then when I detect the P bit, verify the recipient (slave address=20 in first byte) is my device and send off the bytes for processing in=20 non-ISR code. I guess I could check for a change from P to S and S to P to get those=20 transition points, but it's really not an issue, oh well. Cheers, -Neil. On 1/24/2021 2:50 AM, Joep Suijs wrote: > Neil, > > When looking at fig 26-17, it seems S remains high until stop is received= .. > The description mentions 'detected last', which -although not very specif= ic > - might confirm that it remains high until a stop condition is detected. > > Joep > > Op zo 24 jan. 2021 om 06:59 schreef Neil : > >> Hi all, >> >> I'm using I2C in slave mode on a PIC18F24Q10. The incoming packets are >> like this... >> http://orlandorobotbuilders.com/stuff/WD-I2C-hold-packet-01.gif >> >> The PIC18F24Q10 datasheet is here... >> >> https://ww1.microchip.com/downloads/en/DeviceDoc/PIC18F24-25-Q10-Data-Sh= eet-40001945D.pdf >> >> The MSSP has a flag and interrupt for Start and Stop condition (S & P >> bits in SSPxSTAT) and I tried this code in the ISR to detect these... >> >> if (SSP1STATbits.S =3D=3D 1) >> { >> TX1REG =3D 'S'; >> SSP1STATbits.S =3D 0; >> } >> >> if (SSP1STATbits.P =3D=3D 1) >> { >> TX1REG =3D 'P'; >> SSP1STATbits.P =3D 0; >> } >> >> (I'm using EUSART1 for debugging to a serial terminal). >> >> But I'm getting the 'S' 6 times for each message, and It's repeating the >> 'P' several times, even after the message is over. (The package is >> being sent once only). Am I missing something obvious here? >> BTW, I've worked around this already, but just want to know now. >> >> Cheers, >> -Neil. >> >> >> >> -- >> 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 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .