MCP7940 - scrambling a preset clock time - Resolved

Moderator: Benj

Post Reply
DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

MCP7940 - scrambling a preset clock time - Resolved

Post by DCW »

Hello folks... good early morning to you all...
Okay so I spent some time constructing a typical MCP7940 clock circuit on a small PCB... along with a 3V cell... for battery backup... with plainly 5 pins which simply plug into a white breadboard.. The pins are - 5V ... and GND (0V).. then SDA... SCL.. and the MFP pin. So when the lil PCB plugs into the breadboard.. all you do is to... connect up the processor selected pins.. of SDA / SCL... and then the %V and 0V lines.. write the software... and test the circuit..
ALL RIGHT... so after everything is done... the FLOWCODE software is attached... It is really very simple.. for testing...

So I set the DATE and TIME into the chip.. and then watched it display on my serial monitor... ALL OKAY..
I left it a for an hour or so... then I switched off the power supply which kills everything.. BUT the clock chip has the battery backup.. on pin 3 of the chip.. which measured.. 2.99 - 3.00 V... OKAY...

I then came back after a while... turned on the power again... re-initialized the serial monitor... and then connected up - and started the software..
WOW... BUT it ain't working correctly... Instead of getting what I was expecting... on the display... like maybe
270120 005234 .....
I got instead....
010101 000000 .....

It seems that the software ... had like gone astray... and reset the clock chip... somehow...!!!

I did this a few times.... like setting the date and time... and then running it - OKAY... restarting... everything... and the software.. or whatever... had just reset the clock chip...
I examined the flowcode... could not find anything wrong...

I presume - that.. somehow... the software on starting up - with a plain basic read... is somehow - resetting the MCP7940 registers... so that I only get...
010101 000000 .... figures... from a previously setup chip....

Does this happen normally... ??? surely not..???

Thanks... to anyone... to tell me what is wrong... please..!!!??

regards
...
Attachments
PIC1824-test-MCP7940.fcfx
(14.6 KiB) Downloaded 199 times

DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by DCW »

Hello folks.... !!! hmmm... good day... to ALL..!!

Okay so I have spent a further period of time... trying to debug the fault in the MCP7940 circuit etc etc etc...

It appears that... somehow - when the circuit is powered down... the damage to the registers in the MCP7940... occurs...!!!

Exhaustive testing... shows me -that ALL IS WELL after you leave it to run... for a while - after having gotten real figures into the chip..!!!

Then when ...WHILST THE CIRCUIT IS STILL POWERED UP.... you unplug the clock PCB... from the breadboard... OKAY... so the backup battery keeps the clock going... FINE..!!

Then when you plug it back into the board - WHILST THE POWER IS APPLIED.... the program generally picks up where it left off - and the DATE and TIME is carried on okay... (HOWEVER... here is a problem... one has to assert the +ve line first... then the SCL then SDA then 0V..)...
I found when it done like that it recovers - every time... 100%....

So now... there is ... just this problem... when powering down the SDA / SCL / power lines... cause mayhem... and the chip loses it's time...!!!

I have no idea... how to "FIX" this... problem... !!!!

Maybe... what has to happen.. is to TRI_STATE the SDA / SCL lines to the chip.. like in an intialization component... AND KEEP THEM TRI_STATED ...all the time... except when a WRITE / READ to the SDA / SCL lines of the MCP7940 is instructed...!!!!
After the READ... then the lines are TRI_STATED... and kept like that... so that in the event of a power down - (which is invetible and allowed)... the pins on the MCP7940 are not driven AT ALL..!!!

Hopefully - this will... help or SORT OUT THE PROBLEM....?????

HOW does everyone else handle this... problem..??? please...??? I am sure I not the only one ...????

Thanks... folks... and ALL...!!!
Regards
...

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by LeighM »

In software mode, the Flowcode component already does keep the pins tri-stated.
Perhaps you need to consider why you need to disconnect the RTC from the rest of the circuit?
If it is essential, try with the SCL/SDA resistor pull-ups on the board that has the RTC device.
Also ensure that you have capacitors on the Vcc and Vbat pins.

DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by DCW »

Hello Leigh... yeah thanks for reminding me of stuff I have already done, and taken care of... on the little board...I made up....

I then looked at the more expensive... DS1307... chip... and it is amazing.. the circuitry is basically the same... so I merely used a DS1307 chip instead of the MCP7940... chip... and used the DS1307 component...

IT ALL WORKS FANTASTICALLY WELL...!!!...

BUT - that does not FIX the MCP7940 software problem....

I'd be really glad Leigh - if you fellows could spend some time... and FIX UP the MCP7940 ... component..!!! PLEASE..???

I want to use the MCP7940 chip in my system...please.. as it is somewhat much cheaper.... here in South Africa...!!.. than the DS1307 chip...

Thanks very much Leigh....
Regards....

DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by DCW »

Hello Leigh... yeah - okay - I went back and checked everything again... and it's all in order..!!
I have had 2K resistors on the 5V to SDA / SCL .. .. like in the microchip diagram... (not to the 3V line...)...
I have caps on all the other points... including the 100 pf cap they discuss....

I then checked again... you program (Setup the MCP7940 - with numbers.. ) and it all works fine...

EXCEPTING when you power fail the main processor etc etc - like you should be ALLOWED TO DO.... I mean what's the use of having a 3V battery then..?? and when it starts up again... the internal clock registers are scrambled...!!

I even changed the 2K for 4K7 and slowed down the frequency to 100 K... BUT still same thing... power off scrambles the internal registers..!!

..................
Okay so I also checked the DS1307 chip again...
I cannot fault that chip - the DS1307 JUST WORKS... and carries on working when you power fail the main board / processor... when it comes back on... it is all perfect..!!!

So all I can say - is PLEASE... spend some time on the software of the MCP7940 - and I guess - fix it - so that it works correctly - even when you power fail the main board... and when you return the power - it does not scramble the internal registers......!!

It is a pre-requisite that one be able to fail the power off the main board... cause that is why one has a battery backed up chip... so that the RTC carries on working correctly...

Thanks Leigh...
regards
Spencer....

DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by DCW »

Hello Leigh... okay so.. we DO NOT STAND ALONE...!!!

There is something WRONG WITH THE MCP7940 CHIP ... made by microchip...!!!

It seems - that folks have found that... the VBAT... voltage must be held at say - 5V... on power failure...
When the power fails... 5V -> 0V ... the chip registers are scrambled inside... because the VBAT voltage must stay at say ....5V...HMMMM...

Okay Sir.. I found this link...

https://www.avrfreaks.net/forum/strange-issue-rtc

... and it's all there....!!!

SO ... SORRY...!!!!!!!!!!! - MY STUPID MISTAKE..!!!!!!!!!!!!. THE MatrixTsl SOFTWARE SEEMS very good....!!!!!!... BRILLIANT - THANK YOU VERY MUCH..!!!
(IT seems that the backup battery MUST BE LIKE 5V...!!!!!)...

IT IS A MICROCHIP FAULT..!!!!

Kindest Regards
Spencer....

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by Benj »

Hi Spencer,

Did you buy the MCP7940 from a reputable supplier? If not it could potentially be a cheap Chinese clone.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by Benj »

Another thing I spotted on page 4 & 5 of the datsheet details the minimum VCC fall time in microseconds. Look for the "Power supply transition timing" diagram. It needs the fall time to be at least 300uS. This sounds like it could be linked to the problems you're having. What value of capacitor do you have across the supply rails?

The 300uS must be between VTRIP MAX (1.7V) and VTRIP MIN (1.3V), sounds quite hard to achieve without a big cap. Do you have anything else drawing current from the power rails that could be causing the fall time to be reduced? Do you have access to a scope to view the fall time?

If 5V is working then great but that might not be the end of the story. Just because it works well on one board don't assume that the problem is resolved. Have you checked the microchip website for an errata document that documents known silicone issues with their devices?

You blame us and you blame Microchip but you give no details of your circuit or your program so we just have to guess at things to try and help you. For example Leigh tries to help and gets this in return. :shock: :o
Hello Leigh... yeah thanks for reminding me of stuff I have already done, and taken care of... on the little board...I made up....
How are we suppost to know that!

No one is saying you are stupid, these things are easy to miss and it's all a learning process, especially when using new hardware but even with tried and tested solutions. I like to think there isn't a day that goes by where I don't learn something new. As soon as that happens it will be time for me to leave :wink:

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by LeighM »

Can you check you have MCP7940N, not MCP7940M?

DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by DCW »

Hello there guys....!!! and ALL...

Right - so.... OKAY... I AGAIN... A STUPID..!!!! Who knows that there are two types of MCP7940....??? I wonder why Microchip - would even waste time making the M version - with NO battery backup pin availability...

Okay - so thanks to BEN for his comments - MUCH APPRECIATED BEN - ... Thank you very much... I really needed them...to track me down - back to square one again..!!!.. Honestly BEN... thanks very much... (no hard feelings please...???)...

BUT ALL THE BEST TO LEIGH..!!!! You are are a REAL SOLDIER..!!..

LEIGH...???... Seriously...??? Who the hell - would even think that Microchip would waste time making a unit like the MCP7940 M .... version... ????... Really....???... AND MUGGINS HERE.... orders the stuff and it's the 7940...YES...!!! BUT it's a M variety ... and well ... er... hmmm... darn it all..!!


SO thank you BEN... and LEIGH.... I am very grateful that you guys are there..!!!... AND... in passing... when I put a DS1307 chip into the socket of the board I made for the 7940... it just worked...!!! (so that compounded the confusion even more... ha ha ha ha..). BUT... You guys are GOOD... Thanks very much... BEN and LEIGH..!!!.... I owe you guys one..!!!

I HOPE EVERYONE READING THIS STRING OF BANTER... realizes that there are two types of MCP7940... the M type... no battery backup....
and the MCP7940 ... the N type.... WITH battery backup...!!!

Kindest Regards to ALL...
Spencer...

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by LeighM »

OK, thanks Spencer.
For the M type, you need to have two additional diodes to supply the device from either the processor voltage (e.g. 5v) or the backup battery.
Something like this …
batt.jpg
batt.jpg (23.35 KiB) Viewed 6113 times

DCW
Posts: 64
Joined: Mon Sep 28, 2015 8:19 pm
Has thanked: 14 times
Been thanked: 10 times
Contact:

Re: MCP7940 - scrambling a preset clock time...

Post by DCW »

Hello there Ben ... yeah... I thought about it for a while... then I sat down and made up a new PCB... for the MCP7940 M chips....
The circuit is really - exactly like you have drawn it...
I have attached some PDF files for others who would like to make up boards... for JUST using it on a white bread board...

Actually - shortly - I will send up ... a few files... of PDF's which.. I have sat down and made up... for the simple use.. of folks wanting to make up simple stuff for hobbying... or attempting to teach...

So right now... two PDF's hopefully can be attached right here...

Thanks again... folks...

regards
Spencer...
Attachments
MCP7940M-RTC chip with backup CR2032 across VCC-PCB-LAYOUT.pdf
(13.08 KiB) Downloaded 196 times
MCP7940M-RTC chip with backup CR2032 across VCC-COMPONENT-OVERLAY.pdf
(17.01 KiB) Downloaded 172 times
MCP7940M-RTC chip with backup CR2032 across VCC-CIRCUIT.pdf
(20.2 KiB) Downloaded 176 times

Post Reply