hi can i use timer2 (with external 32.768hz crystal) instead of watchdog timer on arduino uno? So when the program gets stuck somewhere, can the timer2 (with external 32.768hz crystal) produce a solution without resetting the processor?
Possibly, but using Timer2 would not be as convenient as the watchdog. The method would not work if the interrupts were shut off. Only a reset can fix that.
With a 32 kHz crystal on the crystal oscillator, the CPU clock options are very limited.
Why would you not use the watchdog?
thank you for your answer, As far as I can tell, the two are not the same thing. What I am wondering is if a stuck timer2 (with external crystal) can solve the problem? Or are the stuck s various? some cannot be solved without a reset. is not it
Timer2 does not solve the problem. Use the watchdog.
Exactly what is "the problem" which wdt overcomes.??? infinite loop or the problem between CPU and clock source. Thanks al ot
Please explain, why do you not want to use watchdog? It specially created for this
i want to overcome "the problem" which is solved by wdt without resetting mcu. Since i want to save datas in the registers. i thougt a rtc could be build with external 32.768 without wdt. And on the other hand a i plan to build a circuit with external RTC and Tpl5111 ( 35 nA) using int0 and saving registers without reading Eeprom. Thanks you for your interest.
Why do you think that your "problem" can be solved without reset?
Usually wdt is needed when the program is frozen. Most often, freezing occurs due to incorrect register content. To get out of this situation, you need to restart the controller with clearing these registers, otherwise the program will most likely freeze again right there
Ok now i got it. So Mass production based on a mcu without wdt is very risky. isn't it?
The WDT has nothing to do with mass production. It makes MCU operation more reliable when actually in service, by allowing the MCU to recover from unexpected errors.
It depends.
It is also risky to release into mass production a program that needs WDT to work...
What kind of programs need wdt? My program includes a rtc, an external interrupt, serial comunication via ble ( 9600 bps powered via upside switch using PNP bjt )and a full bridge driver with only on-off between at least one minute cycle. internal or external xtal is optional. Power source is 18650 battery with Ldo regulator. Using wdt causes increasing power budget. Mcu sleeps forever until an external interrupt occured.
Any program, where an automatic restart is desired if the processor hangs up, can take advantage of the WDT.
You decide whether you need it.