On 19.08.21 17:54, Royce Pereira wrote: > The problem is very often when I switch off my board and switch on again, I > find the DS1307 back to initialised state (seconds showing 80) and date is > 0-0-0. > > I tried many things, changing pull-up values, decoupling capacitors, > staggering the RTC and Lux functions etc. But nothing is working.
After checking that the backup battery voltage is at least 2v at pin 3, and has a bypass capacitor for good measure, I'd try holding the cpu in reset while powering off. Then I'd try powering down the OPT3001 prior to the power-down, so it can't do anything Finally, if the DS1307 corrupts with nothing else on the board active, then is it switch bounce cycling power on & off several times in ten ms or so? Also, be aware that the problem could be occurring at switch-on, not switch-off, even if that seems much less likely.¹ It's more a matter of bisecting the problem, than trying many things. ;-) Happy hunting - it sounds like fun. Erik ¹ I once had a car manufacturer claim our LED clock died the second time its display was turned on. In fact it died when they first turned off the car's accessories line on the ignition switch, as a relay coil on that line generated a back-emf of over -1000 volts. They had no intention of adding the cost of a bypass diode, and I had to modify to tolerate the transient, without adding anything to the cost of the clock.
