Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Strange WDT behavior

johnny78

Full Member level 4
Joined
Jun 28, 2017
Messages
216
Helped
1
Reputation
2
Reaction score
4
Trophy points
18
Activity points
1,787
hi Guys

im using Atmega328P (coded with arduino IDE) for a device but i've faced strange behavior of the MCU
it is powered on solar system batteries ,it includes 16x2 i2c lcd & Ds1307 RTC

after more than 6 months one of the devices got Frozen.
i have already using WDT resets on ds1307 seconds change & i have tested it before by removing the ds1307 when the device is working & yes it resets the MCU & keeps restarting until i get clock source again.
another device got frozen after few months of installing

what kind of issues may cause the MCU to freeze after this long time of working ?
why the WDT did not reset the MCU when it must do OR is not enough for resetting like removing power & re connect it ?
the same device is working at my house for more than 1 year without any issue

any suggestion will be great & thanks in advance
Johnny
 
Hi,

one needs to investigate the "freeze" behaviour.

We don´t know what you exect the microcontroller to do .... while you call it frozen. What does it "not do"?
Example: you say you are using a LCD. So maybe your microcontoller is working perfectly, just your LCD is not updated ...

Then you need to tell what is necessary to "wake up" your microcontroller again.
Example:
If you can wake it up by an external RESET .. then the WDT maybe was (by accident) switched OFF.
If only a POWER DOWN can wake it up, then the WDT probably is working .. but mabe the WDT_RESET was performed regurarily.

Your code surely could give useful informations.

Klaus
 
Hi,

one needs to investigate the "freeze" behaviour.

We don´t know what you exect the microcontroller to do .... while you call it frozen. What does it "not do"?
Example: you say you are using a LCD. So maybe your microcontoller is working perfectly, just your LCD is not updated ...

Then you need to tell what is necessary to "wake up" your microcontroller again.
Example:
If you can wake it up by an external RESET .. then the WDT maybe was (by accident) switched OFF.
If only a POWER DOWN can wake it up, then the WDT probably is working .. but mabe the WDT_RESET was performed regurarily.

Your code surely could give useful informations.

Klaus
thanks for reply Klaus
as i said i have tested the WDT by removing the clock source & it reset the MCU until i connect back the clock source
when i've said freeze i mean the MCU not only the LCD because when it freezes no output or input or the LCD will update
& when i reset it by disconnecting power it works again
is there any reason can freeze the WDT itself inside the MCU ?
this code is working on my house since a year without any issue & it happened after 6 months only
& after 9 months for other device

the code is a long story & you will hate me if i posted it here

here is how i get clock source & how to reset the WDT

Code:
  tmElements_t tm;
  strZero = ("0");
  if (RTC.read(tm)) {
    strHours = tm.Hour;
    strMinutes = tm.Minute;
    if ((tm.Minute) < 10) {
      strMinutes = strZero + tm.Minute;
    }
    if ((tm.Hour) < 10) {
      strHours = strZero + tm.Hour;/////////// new to fix the time display after 00:59
    }
    strSeperator = (":");
    strTime = strHours + strSeperator + strMinutes;
  }

at the end of the main loop i update timerCurrentSeconds

Code:
 timerCurrentSeconds = tm.Second;

here i reset the WDT with every second change

Code:
  if ((timerCurrentSeconds) != tm.Second) {
    wdt_reset();

here is the setup of the WDT

Code:
void watchdogSetup(void)
{
  cli(); // disable all interrupts
  wdt_reset(); // reset the WDT timer
  /*
    WDTCSR configuration:
    WDIE = 1: Interrupt Enable
    WDE = 1 :Reset Enable
    WDP3 = 0 :For 2000ms Time-out
    WDP2 = 1 :For 2000ms Time-out
    WDP1 = 1 :For 2000ms Time-out
    WDP0 = 1 :For 2000ms Time-out
  */
  // Enter Watchdog Configuration mode:
  WDTCSR |= (1 << WDCE) | (1 << WDE);
  // Set Watchdog settings:
  WDTCSR = (1 << WDIE) | (1 << WDE) | (1 << WDP3) | (0 << WDP2) | (0 << WDP1) | (0 << WDP0);
  sei();
}
 
Hi,
as i said i have tested the WDT by removing the clock source & it reset the MCU until i connect back the clock source
Correct me if I´m wrong .. but as far as I understood you did the "remove clock" with a different software.

****
& when i reset it by disconnecting power it works again
I did not mean a pwower cycle. I meant to use the RESET input (pin)

***
If you do it in the order you showed us, the WDT_RESET never would happen.
Without the important pieces of code (or maybe all) all we can do is guess.
Guessing is not my way .. thus you need to rely on others.

****
I mean there could by many sources
Maybe it´s continously resetting but you don´t see this.
Maybe there is something during start up to prevent (maybe a loop) to prevent proper WDT initialisation.

.. thus my way is to investigate.

But still it´s your choice how to go on.

Klaus

added:
Now you come up with a new idea (before going through the first idea): EMC
For sure EMC is possible. But I never encountered an EMC problem with my circuits. Maybe because I do the PCB layout the correct way, clean power supplies, keeping noise low, keeping traces short ... we don´t know how you did it.
It´s on you whether you show or hide your informations.
 
Hi,

Correct me if I´m wrong .. but as far as I understood you did the "remove clock" with a different software.

****

I did not mean a pwower cycle. I meant to use the RESET input (pin)

***
If you do it in the order you showed us, the WDT_RESET never would happen.
Without the important pieces of code (or maybe all) all we can do is guess.
Guessing is not my way .. thus you need to rely on others.

****
I mean there could by many sources
Maybe it´s continously resetting but you don´t see this.
Maybe there is something during start up to prevent (maybe a loop) to prevent proper WDT initialisation.

.. thus my way is to investigate.

But still it´s your choice how to go on.

Klaus

added:
Now you come up with a new idea (before going through the first idea): EMC
For sure EMC is possible. But I never encountered an EMC problem with my circuits. Maybe because I do the PCB layout the correct way, clean power supplies, keeping noise low, keeping traces short ... we don´t know how you did it.
It´s on you whether you show or hide your informations.
hi Klaus
as i said before my code is working since more than a year without problems
the problem happened only twice
1:eek:ne device got frozen after 6 months of continuoues working
2:another one after almost 3 months
3:at my place it didnt happen even its working for more than 1 year

so i cant know what happened or why it happened
that why im asking for possibilities to think of

my WDT is working as i said & it updates every second change as i explained in the code
i get clock source from the seconds change & this i use to reset the wdt

here is a video of the way to test the WDT


i couldnt compress it so here is another one showing the WDT reset workin

 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top