> -----Original Message----- > From: =D6mer Yalhi [SMTP:oyalhi@TEKSAN.COM.TR] > Sent: Wednesday, January 15, 2003 11:18 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Saving contents of a mcu to eeprom >=20 > Is there a way to save couple of bytes (8 or 10 bytes) to eeprom just > before power outage? >=20 > * I am using MPLAB C18 (the software is in C) > * The unit is working with 220V AC converted to 12V DC then 5V DC. > * Configuration bit is set so power on reset on, brown out detection on, > brown out voltage 4.2, oscillator H4 (10MHz xtal working at 40MHz). >=20 > I looked up the datasheet, according to page 27, I checked the RCON > registers POR bit (that is the only one affected with brown out for some > reason) and saved 8 bytes to eeprom if the POR bit was 1. I did this at > the very first thing in the main() procedure. However, it did not work. > Any ideas? >=20 > If anyone is interested the product can be seen at: > http://www.teksan.com.tr/vana.asp?L=3DE&Id=3D0401 > or goto http://www.teksan.com.tr, select product then bathcing solutions. >=20 > Thanks, >=20 > =D6mer YALHI >=20 Check out the Low Voltage Detect (LVD) function. This is effectively a comparator with an adjustable reference set using the LVDCON register. If the supply falls below the reference voltage, and interrupt will be generated which you can capture and use to store you data. Ensure you have enough time remaing to store your 10bytes after the interrupt, the EEPROM memory typicaly takes 4ms per byte to write. Regards Mike =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Any questions about Bookham's E-Mail service should be directed to postmast= er@bookham.com. -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body