Archives
-
Make sure you disable the watchdog at start up…
Hi Everyone,
From now on this is going to be the way I start a project – putting in code to disable the watchdog at start up.
Twice now during debugging/testing, I’ve had a project stop working properly only to put some debug code in that turns on a light to watch it blink quickly because the chip is resetting from the watch dog.
For some odd reason this did now work on a mega328p:
Code:
//disable watchdog if enabled
wdt_reset();
wdt_disable();but this did:
Code:
//disable watchdog if enabled
wdt_reset();
MCUSR=0;
WDTCSR|=_BV(WDCE) | _BV(WDE);
WDTCSR=0;Good luck,
Alan
Related Forum Messages
- Cant STOP Watchdog
- Watchdog timer reset ATMega2560
- Watchdog problem with AVR bootloader
- Watchdog question…
- Wdt_disable() is not working properly
- Watchdog, strange behavior
- 18F8277 WatchDog disable kills timer0?
- Atmega128rfa1 watchdog wouldn’t disable [resolved]
- Watchdog lockup
- SOLVED: Detecting a watchdog timer reset
- Using the watchdog to wake up from sleep
- Solved help with WatchDog
- at91sam7x256 watchdog issue
- Simple watchdog set-up query
- WatchDog and ADC conflict
- DFU upgrade via the boot loader and watchdog
- AT91SAM9263– watchdog enabling
- Atmega 328p slepp and WDT interrupt
- Sleep mode not working in simulator
- ATmega48: Watchdog reset
Im using a m1284. START Watchdog is working but once startet, the watchdog cant be stopped. I tried STOP Watchdog.... The sequence: Clear_Watchdog: 'this sub toggles the watchdog into and out of interrupt / reset mode 'this ensures that no matter what mode the watchdog might have been in previously... 'it will be turned off completely CLI 'disable global interrupts WDR 'reset watchdog timer IN R16, MCUSR 'get MCUSR ANDI R16, $F7 'clear the watchdog reset bit in the status reg !OUT MCUSR, R16 'store MCUSR LDS R16, WDTCSR 'get current watchdog setting LDI R17, $58 'load int/res mode value ...I have an application where it appears that I am unable to stop/ clear the watch dog timer properly. I have a process that I know could take longer than the normal watch dog timer timeout setting.(WDTO_4S) So before I go into my long process I disable the watchdog timer. After I finish my long process I enable the watchdog timer but as soon as I do I get a hardware reset. This is how I'm doing the disable Code: void System_Support_wdtoff(void) { SREG amp= ~(1ltlt7); //I have no idea why I'm ...i am working with some equipment from Libelium (waspmotes) which doesnt seem to allow me to use a watchdog in the reset mode but will work in interrupt mode. What I'd like to know is whether there is a better way to do a reset as soft reset isnt really whats needed - also does anyone know why a bootloader can stop a watchdog from doing a reset !!!???? Here is some code that works for a soft watchdog obviously I am trying to find out how this can be improved -e.g. what registers should I also reset and how ...On a 168P, this does not work, cpu reset after 1s: Code: void goto_sleep() { cli(); // disable interrupt timer0_ovf=0; wdt_enable(WDTO_1S); set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); sleep_bod_disable(); sei(); sleep_cpu(); sleep_disable(); wdt_disable(); } I managed to get this to work: Code: void goto_sleep() { cli(); // disable interrupt timer0_ovf=0; wdt_reset(); MCUSR=0; WDTCSR = (1ltltWDCE) | (1ltltWDE); WDTCSR = (1ltltWDIE) | (1ltltWDP2) | (1ltltWDP1) | (1ltltWDP0); set_sleep_mode(SLEEP_MODE_PWR_DOWN); ...Hello friends, To be clear from the beginning... WDE fuse bit is disabled. INTS are disabled and code is placed just after vectors: Code: void __attribute__((naked)) __attribute__ ((section (".init0"))) CriticInit(void) // { cli(); wdt_reset(); wdt_disable(); //MCUSR amp= ~(1ltltWDRF); //WDTCSR |= (1ltltWDCE) | (1ltltWDE); //WDTCSR = 0x00; } The function wdt_disable() doesn't disable always the WDT module !!! It's the 5 or 6'th time I suspect this and when replaced with recommended in datasheet: MCUSR amp= ~(1ltltWDRF); WDTCSR |= ...I am working on a program for an 18LF45K22 using the CCS compiler. There is one section of the code where I go into an infinite loop with a while(1) and I want the watchdog to time out and reset the CPU. Immedaitely before the code hits the while(1) I disable global interrupts. For some reason the watchdog will never time out and reset unless I take out the disable global interrupts. The watchdog works just as expected if the global interrupts are enabled when it hits the while(1). I could find nothing in the documentation to indicate why the ...New here, but not my first rodeo.. I am working on a rather complex program that uses the Watchdog timer for its obvious uses. Timer0 is also used to generate interrupts for the system clock. I need to be able to disable the Watchdog via a command from another system so that both systems can be reburned in the field. The watchdog is under software enable via the swdten bit (and this is working). When I disable the watchdog, the interrupts from timer0 also stop. I have even added code to enable timer0 immediately after resetting the swdten bit, to ...I suspect it is something very obvious, but I don't see it. My watchdog timer refuses to get disabled. I have trivial program: Code: wdt_disable(); asm volatile ("lds __tmp_reg__, 0x60" ::: "r0"); while (1); I step through it and see that r0 is 0x08 (watchdog timer enabled) after wdt_disable. wdt_disable is (unmodified from wdt.h file): Code: cli out 0x60, 0x18 out 0x60, 0 update Code above should have been: Code: cli sts 0x60, r24; // r24 = 0x18 (WDCE|WDE) sts 0x60, r25; // r25 = 0x00 WDTON fuse is unprogrammed (I ...Hi. Today I burned 5 hours on a strange problem. I have solved it now but I like to chare it and also I have a question. Set up: ATmega88 mkII debugger through debugWire Symptom: The hardware looses contact with the emulator in the beginning of the code. A LED on the hardware that is controlled by the MCU starts to blink rapidly. Usually but not always this happend at the first Delay. The Delay uses Sleep mode. Observations: The Watchdog is enabled. Why, I have had it enabled in this code in the past but not know. And this ...Hi, I've successfully flashed a new bootloader with the "quick boot" / "watchdog modifications" (using my USB Tiny of course!). All is good in watchdog land... However, I'd like to be able to detect when the WDT causes a reset rather than a normal event (reset button, power etc.). Looking at the bootloader code I see this: Code: Select all ch = MCUSR; MCUSR = 0; WDTCSR |= _BV(WDCE) | _BV(WDE); WDTCSR = 0; // Check if the WDT was used to reset, in ...Hey, I'm trying to make a timer thingie that basically just displays the elapsed time on an LCD. I want to put the CPU to sleep every second (or every 500ms) and just wake up from sleep to refresh the LCD with the current time (need to have timer0 running so I can't do a full power-down, just power-save afaik). The documentation on the watchdog and sleep seem surprisingly sparce and I'm having trouble setting it up. Currently I'm doing something like this (just showing the bits related to sleep and watchdog): Code: #include ltavr/wdt.hgt #include ltavr/sleep.hgt #include ltavr/interrupt.hgt void setup() { ...hi all. I need help with watch dog setting. I have DIP ATTiny2313 and in fuse bit set watch dog always On . and use this code : for setting prescaler Code: in r16,MCUSR andi r16, (0xff amp (0ltltWDRF)) out MCUSR, r16 in r16, WDTCSR ori r16, (1ltltWDCE) | (1ltltWDE) | (1ltltWDP2) | (1ltltWDP1) | (1ltltWDP0) out WDTCSR,r16 but if test my application don't start. if fuse bit always on clear then all work what happened??? what is correct setting if I have fuse bit for watch dog always on ??? I want set watch dog timeout about 2sec to 4sec ...Hi, i'm working on a AT91SAM7X-EK development board, and i'm trying to figure out if the normal at91 watchdog behavior can be changed or workarounded because: "The Watchdog Mode Register (WDT_MR) can be written only once. Only a processor reset resets it. Writing the WDT_MR register reloads the timer with the newly programmed mode parameters." due to this feature, if i disable watchdog on start up, i'm not able to turn in on anymore until the next reset. What i want to do is disable watchdog on startup, and then turn it on later (on a custom received can message). ...Hello all, I am using an ATMEGA 88pa controller at 8Mhz clock internal frequency. I am trying to use the watchdog in interrupt mode to toggle an LED. I was reading the datasheet where I came across this statement under the WDIE enable bit section in WDTCSR register: Quote: When this bit is written to one and the I-bit in the Status Register is set, the Watchdog Interrupt is enabled. If WDE is cleared in combination with this setting, the Watchdog Timer is in Interrupt Mode, and the corresponding interrupt is executed if time-out in the Watchdog Timer occurs. Now to ...Hello, 1)I have coded PIC16F676 for one system. Before using WatchDog, the ADC code in my program works appropriately. I am taking analog signal on Port A - 0 pin (AN0). But after enabling Watchdog through Configuration bits, ADC working is erratic. Code structure is below: This is with watchdog CONFIG bit enabled 1. Init registers,ports etc 2. Call ADC routine 3. ----- 2)If I disable the Watchdog CONFIG bit and then if I assign prescalar to Watchdog through the code given in datasheet(initially for 30 secs I am using prescalar for Timer), then Watchdog is not active at all. I ...Hi all. First of all, we are using a LM3S9B90 Rev. C3 and StellarisWare rev. 6852. Our application is using a watchdog, which is working fine. However, whenever I enter DFU mode (using the USB capable boot loader), this is done by calling USBDDFUUpdateBegin(), and the device enters DFU mode without being reset. This causes an issue, as the watchdog is not disabled, and will, when it counts down, reset the MCU. Once enabled, there is no possibility to disable the watchdog, and issuing WatchdogResetDisable(WATCHDOG0_BASE) causes an error. How can we prevent the watchdog from resetting the MCU while in ...Hi, Iam using at91sam9263 with bootstrap and uboot in dataflash and linux kernel and rootfs in nand flash. whenever i load the driver at91sam9_wdt.ko it says that watchdog is already initialised. I came to know that in bootstrap is disabled by default. at91sam9263ek.c file hw_init /* Disable watchdog */ writel(AT91C_WDTC_WDRSTT,AT91C_BASE_WDTC + WDTC_WDCR); i commented this line so that i can enable the watchdog at the later time. but by default watchdog is enabled and resets the processor every 16 seconds. also we can write to the watchdog mode register only once. how to disable the watchdog until kernel boots up ...I am wanting to put the CPU to sleep for 8 seconds, wake up using WDT interrupt flash an led then go back to sleep 8 seconds and keep looping thru that. I adapted some code from an arduino tutorial and basically the C code only flashes the lED - no sleep for 8 secs. Also i get warning on compile AVR studio 4: "../main.c:20:1: warning: return type defaults to 'int' ../main.c: In function 'ISR': ../main.c:20:1: warning: type of '__vector_6' defaults to 'int' ../main.c:24:1: warning: control reaches end of non-void function" I think the problem may be with the ISR ...Not sure what's wrong here, probably something obvious as usual.... When I step through this code in the simulator the Sleep Mode Select register never changes from 0x00 and the Sleep Enable box never checks (bit never sets). If I manually set the SE bit (by clicking on the check box with my mouse during debug) then the simulator goes into sleep mode after the sleep_cpu command as it should. What's going on? Code: // put device to sleep until interrupt wakes it up for (;;) { // set ...Hi. I would like to reset my ATmega48 via software/watchdog, so I decide to use the wdt.h library from the avr-gcc toolchain. You can access a simple code example by downloading the "main.c" attachment. My problem is, that the processor goes into an endless loop of Watchdog resets and I have no idea how to solve this state. I tried to use wdt_disable() and wdt_reset() but it did not work. Info about the project: ATmega48 RS232/USB devel board
