mega8 reset.

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm wondering if one could reset the mcu with the Watchdog. Is there a register I could effectively zero and force the mcu to reset? I had to use my PC6 pin so I no longer have a reset switch. I'm trying to find a way to do it in software.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Turn on the watchdog and then wait in an infinite loop.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Real question is, if you don't have a reset anymore how are you going to fix the problem in software? Do you already have a bootloader installed?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you read the datasheet for your micro? Specifically the section on watchdog? Yes, you can use watchdog to reset the micro, that's really what it's there for. You just need to fool it into timing out and firing the watchdog.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hugoboss wrote:
Real question is, if you don't have a reset anymore how are you going to fix the problem in software? Do you already have a bootloader installed?
yes Of course. This is how I program it.

Quote:
Did you read the datasheet for your micro? Specifically the section on watchdog? Yes, you can use watchdog to reset the micro, that's really what it's there for. You just need to fool it into timing out and firing the watchdog.
This is where I gathered it would work. I also heard that timing it out is the best means but can not figure that out.

Koshchi, that gave me an idea. It just so happens this is a ubs device. I could easily put the code in a while(1) loop and force the USB to fail, not as elegant but could work.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

but can not figure that out.

Eh?

enable_watchdog()
while(1) {
}

What could be simpler?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well dont have a built in function that I could fine. But I think I got it,

Quote:
WDTCSR = ((1<<WDCE) | (1<<WDE));

this should be enough time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which C compiler? I had half a memory that you used avr-gcc in which case you have:

http://www.nongnu.org/avr-libc/u...

EDIT: yup, I searched your previous posts - you are using avr-gcc

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

beats me, the compiler says its not defined? If winavr is avr-gcc that I guess I do.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

If winavr is avr-gcc

You have seen that manual I linked to before now haven't you?!?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I was not sure at the time that winavr was the same. I do see the wdt_enable(value), thx.