View previous topic :: View next topic |
Author |
Message |
jaikumar
Joined: 15 Dec 2006 Posts: 109
|
A question regarding RTC - MCP7940N |
Posted: Fri May 01, 2015 1:24 am |
|
|
Hi all,
I am using the MCP7940N RTC.
http://www.farnell.com/datasheets/1754398.pdf
I was wondering if there is any way of finding out if the
battery was removed and put back during power off.
Can i set a internal RAM location to some value say 0xAA and then check later on when power is re applied.
OSCON bit does not seem to help here.
Thanks,
Jay. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Fri May 01, 2015 3:19 am |
|
|
You don't need to fiddle.
Just read the Power Fail Time Stamp registers (18 to 1B).
If these contain a time, then the battery was OK all the time the chip was off. If they are empty. then the battery has been off, since the last main power failure.
These store the time when the main supply goes off, but their contents are lost if the battery goes off as well. |
|
|
jaikumar
Joined: 15 Dec 2006 Posts: 109
|
|
Posted: Fri May 01, 2015 3:33 am |
|
|
Thanks Ttelmah.
Regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Fri May 01, 2015 5:01 am |
|
|
I happened to want to ensure the chip always had a valid time, and 'force' a reinitialization when the battery had been off. Suddenly 'twigged' I could use these registers. |
|
|
jaikumar
Joined: 15 Dec 2006 Posts: 109
|
|
Posted: Sat May 02, 2015 12:38 am |
|
|
Want to know if i can apply power to RTC using the port pin of 16f887 instead of from regulator.
I know it sounds ridiculous but i have one reason
I read some where in the datasheet or application notes that the applied voltage should drop suddenly and should not droop for the RTC to work properly.
Since i am driving a motor i have a big cap. The controller is protected by a
supervisor. So i want to know if i can drive the RTC from a port pin.
Regards,
Jay. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Sat May 02, 2015 4:47 am |
|
|
Probably yes.
However where did you read this?.
If you look at the data sheet, there is a _minimum_ rise time specified, but no 'maximum'. The_PIC_ however has a maximum rise time, to reset properly, which with a large supply capacitor may well cause problems (you need an external MCLR circuit, if the supply takes significant time to rise...). |
|
|
jaikumar
Joined: 15 Dec 2006 Posts: 109
|
|
Posted: Sat May 02, 2015 6:30 am |
|
|
Ttelmah,
Please see below app note:
http://ww1.microchip.com/downloads/en/AppNotes/01365C.pdf
Although this app note is for the MCP794XX, as far as the RTC goes
they function the same.
Page-2 - Power-UP
it also specifies about using the MFC pin. But if i don't want to use it.
Can i just leave the pin open. Its not clear on that.
Regards,
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Sat May 02, 2015 1:09 pm |
|
|
The bit you are looking at there, is only if the supply droops below the minimum operating Vdd voltage, and then recovers. Seriously if your supply to the PIC does this, you have much bigger problems.....
If you are running the motor from the same supply as the PIC, 'think again'. Separate the rails. Have a PIC supply, with it's own capacitor. This can even be fed from the motor rail, but separated (perhaps an inductor, or resistor), from the actual motor rail. You have to understand that motors, can do some nasty things like acting as a generator, when switched off. This can result in the rail going above it's normal voltage. The energy both from this and the inductive nature of the drive coils, has to go _somewhere_, and you need to design your supply to handle this. |
|
|
|