From PICLIST@MITVMA.MIT.EDU Fri Nov 15 00:51:50 2002 Received: from cherry.ease.lsoft.com [209.119.0.109] by dpmail10.doteasy.com with ESMTP (SMTPD32-7.13) id A5A6176F0072; Fri, 15 Nov 2002 00:51:50 -0800 Received: from PEAR.EASE.LSOFT.COM (209.119.0.19) by cherry.ease.lsoft.com (LSMTP for Digital Unix v1.1b) with SMTP id <23.007DB3E0@cherry.ease.lsoft.com>; Fri, 15 Nov 2002 3:37:48 -0500 Received: from MITVMA.MIT.EDU by MITVMA.MIT.EDU (LISTSERV-TCP/IP release 1.8d) with spool id 0055 for PICLIST@MITVMA.MIT.EDU; Fri, 15 Nov 2002 03:37:37 -0500 Received: from MITVMA (NJE origin SMTP@MITVMA) by MITVMA.MIT.EDU (LMail V1.2d/1.8d) with BSMTP id 5047; Fri, 15 Nov 2002 03:33:46 -0500 Received: from *unknown [47.211.129.137] by mitvma.mit.edu (IBM VM SMTP Level 320) via TCP with ESMTP ; Fri, 15 Nov 2002 03:33:45 EST X-Warning: mitvma.mit.edu: Host *unknown claimed to be znsgs01r.nortelnetworks.com Received: from zwcwc012.europe.nortel.com (zwcwc012.europe.nortel.com [47.160.46.124]) by znsgs01r.nortelnetworks.com (Switch-2.2.0/Switch-2.2.0) with ESMTP id gAF8XhV15264 for ; Fri, 15 Nov 2002 08:33:43 GMT Received: by zwcwc012.europe.nortel.com with Internet Mail Service (5.5.2653.19) id ; Fri, 15 Nov 2002 08:33:43 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Message-ID: Date: Fri, 15 Nov 2002 08:33:41 -0000 Reply-To: pic microcontroller discussion list Sender: pic microcontroller discussion list From: Michael Rigby-Jones Subject: Re: [PIC]: Now, exactly what use is the BOR bit? To: PICLIST@MITVMA.MIT.EDU X-RCPT-TO: Status: R X-UIDL: 277600606 X-Evolution-Source: pop://mailinglist%40farcite.net@mail.farcite.net/ X-Evolution: 00000736-0000 > -----Original Message----- > From: llile@SALTONUSA.COM [SMTP:llile@SALTONUSA.COM] > Sent: Thursday, November 14, 2002 9:54 PM > To: PICLIST@mitvma.mit.edu > Subject: [PIC]: Now, exactly what use is the BOR bit? > > The book says that BOR must be set by the user and checked on subsequent > resets. Now, how does one tell if it is a subsequent reset, or the first > one? If you start up, how do you know if it is a subsequent reset, or > just the first time your code has ever seen the light of day? This seems > to be one of those catch-22 situations: "we can tell if it is a brownout > reset only if you already know it is a brownout reset." Hmmm.. > > The POR bit seems a little more straightforward: If it is 0 on startup, > there was a power-on-reset. You then set it to 1 and it will remain 1 > after the next watchdog reset or MCLR reset, but will go back to zero on a > cold boot. > Seems to me you answered your own question there. On reset, you check the state of the POR bit. If it is clear, then you set both the POR and the BOR bits. If it is not clear, then you test the state of the BOR bit to see if a brownout occured. Mike -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.