Yahoo Groups archive

AVR-Chat

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

Message

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

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]

Attachments

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.