ATMEGA8A : How to attach interrupt to watchdog timer ?

Hi, I am doing a project with atmega8a, that requires the mc to stay on sleep for 5 minutes and then wake up, do it's job & go back to the 5 minute sleep again in the infinite loop.

I followed this guide (please check sketch H), it sets WDT to 8s, and uses WDIE register to enable watchdog interrupt.

Now, read the watchdog section of atmega8a, the timers and register names are different here in 8a, than 328p, and i did the changes accordingly. The problem is, I don't see anything that whats the same way as WDIE for 328p.

As the result, my mc going sleep properly, but I am unable to wake it up.

Please help ! :confused:
(My microcontroller programming knowledge is pretty much at novice level, so please elaborate what you suggest.)

8a datasheet is here.
328p datasheet is here.

I have done this for the tiny85 seriess:
Example Code

Most of the logic is from examples by Nick Gammon and others as noted in the source.

Ray

mrburnette:
I have done this for the tiny85 seriess:
Example Code

Most of the logic is from examples by Nick Gammon and others as noted in the source.

Ray

Thanks for sharing the project, but you are using WDIE also, with that attiny85 chip. Unfortunately atmega8 doesn't have this, and I am starting to suspect if its possible at all to to raise an interrupt internally when WDT expires. Not to mention, in atmega8 WDT maximum supports 2.1 seconds only, unlike 8 seconds in attiny or 328p.

I am not sure, may be putting a minute long clock pulse to raise external interrupt is the best I can do to call atmega8 from sleep ?

Ideas ? :cry:

Datasheet sounds like that chip doesn't have the ability to raise an interrupt. There's no mention of raising an interrupt, and no watchdog interrupt vector.

atmega8a

Ah. No 8s timeout, either (~2s max.)

The Atmega8/8A is an older chip design, and lacks some of the features of the newer 168 or 328 chips. There IS the ATmega88, which should have the same features as the 168/328 (only less memory.)

Um, so it seems wrong choice of mc, I will still try to awake it with some low frequency low power pulse generator, if I can.

Anyways, I would like to ask if all the attiny chips are fully compatible with arduino coding ? May be I will try some of those in future.

You can try waking the mega8 via WDT reset. In your code you will just need to read the MCU status register to find the reset condition and act accordingly. Hopefully you are not using a bootloader as they some times clear the reset condition.

hiduino:
You can try waking the mega8 via WDT reset. In your code you will just need to read the MCU status register to find the reset condition and act accordingly. Hopefully you are not using a bootloader as they some times clear the reset condition.

Don't think reset in every 2 seconds would be a good battery saving option, but thanks for suggesting.