I upload it.But it only show once "Begin" then nothing happen.I want to reupload the program.But it won't reset even I put reset pin to ground.The chip seems die.Only use ASP to erase the chip then the chip can reprogram again.What's the matter?Is the wdt library broken?
I have test 3 chips but it happen the same thing...(ATMEGA328P)
Yes that is what happens because the time out is less than the time it takes for the boot loader to finish loading some new code. It will happen every time.
I think you can do it if you take the right steps.
Power off the chip
Hold down the reset button
Power the chip back on, still holding reset down
Start uploading the sketch
Release the reset button
Doing it this way stops the sketch from running on power-up, and thus whatever-it-does doesn't matter. You go straight to the bootloader.
If you are running out of enough hands to do this you might use a wire with an alligator clip to keep reset shorted to ground, while you do the other steps, and then release it at the right moment.
I can burn the program in right now.Bootloader makes watchdog fail.So right now I need a bootloader which is support 8mhz,also make watchdog usable and the MCUSR need to work
Thanks, I've been noticing my Arduino Leonardo "message generator" has been less reliable now I moved to Ubuntu. I'll have to add ... gasp! ... delay().
One problem with this code is that you need to clear the WDT reset flag before you can disable the watchdog timer. I ran into this exact same issue with an ATtiny84V. Add MCUSR = 0; before wdt_disable();.
And put the watchdog disabling code right at the beginning of the setup().
Jiggy-Ninja:
One problem with this code is that you need to clear the WDT reset flag before you can disable the watchdog timer. I ran into this exact same issue with an ATtiny84V. Add MCUSR = 0; before wdt_disable();.
And put the watchdog disabling code right at the beginning of the setup().
According to a page I found ( avr-libc: <avr/wdt.h>: Watchdog timer handling ) if the watchdog was enabled it still is on reset with a fast prescaler (15 mS). So if the bootloader doesn't turn it off you are in trouble. I tested with the Lilypad bootloader and it didn't work. With the Optiboot loader, it does work. So the problem is indeed in the bootloader. Personally I don't know where to find a fixed 8 MHz bootloader.
Yes,I am going to make a bootloader,but after I burning my bootloader,everytime I want to upload program.avrdude will give me "verification error",and program won't work.
I builded it with ATMELStudio.Here is the bootloader for test(no wdt modification,just want to test it.use -Os optimization,4K on disk,Fuse:0xFEDCE2,Lock:0xCF.)
Here you go: http://pastebin.com/j5a0nr1Y(the forum only allow 9500 words.So I put it to pastebin)
Thanks for your replies
I have to use 8Mhz bootloader.And I need MCUSR,too.I can't use optiboot because they use 115200bps which is too fast.
Take the default (16MHz) optiboot bootloader and put it on your 8MHz chips. Then configure your boards.txt so that the upload speed is 57600 instead of 115200 (half the clockrate means half the upload speed.)