Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Re: Using WatchDog messes up timings in my code (ATMega644P 20AU): Wrong Diagnosis.

Re: Using WatchDog messes up timings in my code (ATMega644P 20AU): Wrong Diagnosis.

2010-03-11 by ray.greyvenstein

Are you using any optimization?

I vaguely recall a problem similar to this.  It may have something to do with "volatile".

...Just a thought.

--- In AVR-Chat@yahoogroups.com, Cat C <catalin_cluj@...> wrote:
Show quoted textHide quoted text
>
> 
> I just discovered that using (or not) the watchdog only changes the values at which the problem happens, and it was undetected before because I wasn't using the Timer1 values where it happens without the watchdog.
> 
> I'd still like to know why the watchdog changes anything in a mainly interrupt-driven timing setup, but ...
> 
> Thanks,
> 
> Cat
> 
> From: catalin_cluj@...
> To: avr-chat@yahoogroups.com
> Subject: Using WatchDog messes up timings in my code (ATMega644P 20AU)
> Date: Thu, 11 Mar 2010 11:03:22 -0700
> 
> 
> 
> 
> 
> 
> 
> 
> Hi,
> Got this very strange problem(s).
> 1. For some reason, at power-up (4.5V from linear on-board regulator from PC 5V PSU) the microcontroller starts up temporarily but then stops (or goes to microcontroller heaven).  I know this because I'm sending some text on the serial port near the start of the program and I only get some of it.
> If I press the reset button all is fine, so maybe strange things happen because power might go up too slow.
> I decided to use the watchdog so if it doesn't get to the main loop (where it gets kicked) it will reset the board.
> 
> This seems to work, but:
> 2. Some timings that work fine when I don't use the watchdog now get messed up in the strangest way:
> Depending on a value I set in Timer 1, I get a big change in Timer 0 (a period supposed to be about 440us is now about 3ms).
> 
> There are still things to check, but... does anybody have an idea that might save me some time?
> 
> Any help appreciated, thank you,
> 
> Cat
> 
> PS - when I enable the watchdog I'm NOT setting the fuse, just in SW:
> 
> #include <avr/wdt.h>
> 
> main()
> {
> ...
>      wdt_enable(WDTO_1S);
> ...
>      while (1)
>      {
>      wdt_reset ();
>      .....
> .....}
> 
> The timing routines are quite complex, involving setting Timer0 inside interrupt handler of Timer1, etc.
>  		 	   		  
> 
> [Non-text portions of this message have been removed]
>

RE: Using WatchDog messes up timings in my code (ATMega644P 20AU): Wrong Diagnosis.

2010-03-11 by Cat C

I just discovered that using (or not) the watchdog only changes the values at which the problem happens, and it was undetected before because I wasn't using the Timer1 values where it happens without the watchdog.

I'd still like to know why the watchdog changes anything in a mainly interrupt-driven timing setup, but ...

Thanks,

Cat
Show quoted textHide quoted text
From: catalin_cluj@hotmail.com
To: avr-chat@yahoogroups.com
Subject: Using WatchDog messes up timings in my code (ATMega644P 20AU)
Date: Thu, 11 Mar 2010 11:03:22 -0700








Hi,
Got this very strange problem(s).
1. For some reason, at power-up (4.5V from linear on-board regulator from PC 5V PSU) the microcontroller starts up temporarily but then stops (or goes to microcontroller heaven).  I know this because I'm sending some text on the serial port near the start of the program and I only get some of it.
If I press the reset button all is fine, so maybe strange things happen because power might go up too slow.
I decided to use the watchdog so if it doesn't get to the main loop (where it gets kicked) it will reset the board.

This seems to work, but:
2. Some timings that work fine when I don't use the watchdog now get messed up in the strangest way:
Depending on a value I set in Timer 1, I get a big change in Timer 0 (a period supposed to be about 440us is now about 3ms).

There are still things to check, but... does anybody have an idea that might save me some time?

Any help appreciated, thank you,

Cat

PS - when I enable the watchdog I'm NOT setting the fuse, just in SW:

#include <avr/wdt.h>

main()
{
...
     wdt_enable(WDTO_1S);
...
     while (1)
     {
     wdt_reset ();
     .....
.....}

The timing routines are quite complex, involving setting Timer0 inside interrupt handler of Timer1, etc.
 		 	   		  

[Non-text portions of this message have been removed]

RE: [AVR-Chat] Re: Using WatchDog messes up timings in my code (ATMega644P 20AU): Wrong Diagnosis.

2010-03-14 by Cat C

That problem was caused by some code I "moved" from place to another but forgot to remove from the original, in effect copying instead of moving.
The effect was complicated by interrupts, timers, etc; and the watchdog was only involved as an extra instruction to reset it in the main loop changing how long the loop took therefore values at which the problem happened.

Thanks everybody for consideration.

Cat


> To: AVR-Chat@yahoogroups.com
> From: Ray.Greyvenstein@gmail.com
> Date: Thu, 11 Mar 2010 18:40:53 +0000
> Subject: [AVR-Chat] Re: Using WatchDog messes up timings in my code (ATMega644P 20AU): Wrong Diagnosis.
> 
> 
> 
> Are you using any optimization?
> 
> I vaguely recall a problem similar to this.  It may have something to do with "volatile".
> 
> ...Just a thought.
> 
> --- In AVR-Chat@yahoogroups.com, Cat C <catalin_cluj@...> wrote:
> >
> > 
> > I just discovered that using (or not) the watchdog only changes the values at which the problem happens, and it was undetected before because I wasn't using the Timer1 values where it happens without the watchdog.
> > 
> > I'd still like to know why the watchdog changes anything in a mainly interrupt-driven timing setup, but ...
> > 
> > Thanks,
> > 
> > Cat
> > 
> > From: catalin_cluj@...
> > To: avr-chat@yahoogroups.com
> > Subject: Using WatchDog messes up timings in my code (ATMega644P 20AU)
> > Date: Thu, 11 Mar 2010 11:03:22 -0700
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > Hi,
> > Got this very strange problem(s).
> > 1. For some reason, at power-up (4.5V from linear on-board regulator from PC 5V PSU) the microcontroller starts up temporarily but then stops (or goes to microcontroller heaven).  I know this because I'm sending some text on the serial port near the start of the program and I only get some of it.
> > If I press the reset button all is fine, so maybe strange things happen because power might go up too slow.
> > I decided to use the watchdog so if it doesn't get to the main loop (where it gets kicked) it will reset the board.
> > 
> > This seems to work, but:
> > 2. Some timings that work fine when I don't use the watchdog now get messed up in the strangest way:
> > Depending on a value I set in Timer 1, I get a big change in Timer 0 (a period supposed to be about 440us is now about 3ms).
> > 
> > There are still things to check, but... does anybody have an idea that might save me some time?
> > 
> > Any help appreciated, thank you,
> > 
> > Cat
> > 
> > PS - when I enable the watchdog I'm NOT setting the fuse, just in SW:
> > 
> > #include <avr/wdt.h>
> > 
> > main()
> > {
> > ...
> >      wdt_enable(WDTO_1S);
> > ...
> >      while (1)
> >      {
> >      wdt_reset ();
> >      .....
> > .....}
> > 
> > The timing routines are quite complex, involving setting Timer0 inside interrupt handler of Timer1, etc.
> >  		 	   		  
> > 
> > [Non-text portions of this message have been removed]
> >
> 
> 
> 
> ------------------------------------
> 
> Yahoo! Groups Links
> 
> 
> 
 		 	   		  

[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.