Go Down

Topic: Set fuse to use internal clock - "target doesn't answer" (Read 4035 times) previous topic - next topic

bigal83

Hi, I have had some problems with my newest board based on the ATmega2560. Trying to fix a issue I've had for a week I turned my suspicions to the external crystal which seemed to worked fine locking through the oscilloscope but I had nothing else to try so I switched to use the internal 8MHz clock.

After this I lost the connection to the MCU, getting the classic error:

Code: [Select]
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1


I've had this before when I disabled the ISP interface; but should switching to the internal clock really cause an issue? Shouldn't it just keep running with the internal clock instead?

Any ideas of how to recover from it?

Cheers

Coding Badly

I've had this before when I disabled the ISP interface; but should switching to the internal clock really cause an issue?


No.

Quote
Shouldn't it just keep running with the internal clock instead?


Yes.

Quote
Any ideas of how to recover from it?


Post the verbose output from avrdude.

bigal83

Quote


Post the verbose output from avrdude.



Here is the full verbose message when trying to upload a sketch via a USBasp interface.
Code: [Select]
avrdude: Version 5.11, compiled on Sep  2 2011 at 19:38:36
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\arduino-1.0.4\hardware/tools/avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbasp
avrdude: seen device from vendor ->www.fischl.de<-
avrdude: seen product ->USBasp<-
         AVR Part                      : ATMEGA2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : usbasp
         Description     : USBasp, http://www.fischl.de/usbasp/

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: programm enable: target doesn't answer. 1
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.


Any other parameters I can rund avrdude with to get more info?

cheers

Coding Badly


It looks like the programmer is not responding.  What happens if the programmer is not connected to the target?  Do you get the same error message?

hiduino

Actually it looks like your programmer is responding, since avrdude is giving the warning to update your USBasp firmware.  I get similar messages when the AVR is set to a lower clock speed like internal 1MHz or 128KHz and your USBasp programmer can't slow down for this.

Do you remember what fuse settings you used last?

What kind of USBasp programmer do you have?
There may be a jumper option to use a slow sck clock or you may be able to upgrade the firmware so you can use an avrdude option -B to slow it down.


bigal83

I tried the -B parameter which needed a number after it, tried 0,1,2,3,4 with no success. The only fuse I set was the low one, which specifies the clock settings.

Would the external crystal give a signal if the internal one is used? Could I look at the crystal with a oscilloscope and if it is silent I know the internal one is used?

Cheers

Nick Gammon

If you have another board, try running the sketch below and seeing what response you get:

http://www.gammon.com.au/forum/?id=11633
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

hiduino

Quote

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.


This output indicates your USBasp does not support the -B option.  It may be possible to upgrade your programmer firmware to be able to support that option.  If you tell us what kind of USBasp you have then I may be able to help you upgrade it.

If you had set the CKOUT fuse option, then the system clock can be measured at the output CLKO on pin 9.

What low clock fuse setting did you use?


bigal83

Quote

If you tell us what kind of USBasp you have then I may be able to help you upgrade it.

I have one bought from eBay, hongkong style. It says "USBASP V2.0" and "Lcsoft Studio" on the programmer, hopefully you have an firmware update for it.

Quote
What low clock fuse setting did you use?

I remember that:
CKSEL0=0
CKSEL1=0
CKSEL2=0
CKSEL3=1

But when I use the AVR Fuse Calculator to get what it represents, it seems to be inverted, I have to "select" fuse CKSEL0,CKSEL1 and CKSEL2 to get 0x1000 (the above). Either way, when I mimic the settings above it says:
"Ext. Crystal Osc; Frequency 0.4-0.9MHZ; Startup....." which is totally wrong....does this mean I have to get a crystal within that range to recover it?

Can't even find the "Internal Osc 8MHz" in the Fuse calculator..

Cheers

Nick Gammon

Fuse settings are confusing. The default is 0xFF or all 1-bits. However that is called "not programmed". To "set" a fuse you write it to zero. Thus they appear inverted.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

hiduino

#10
Mar 25, 2013, 11:47 am Last Edit: Mar 25, 2013, 11:50 am by hiduino Reason: 1
Yes, the USBASP V2.0 LCsoft Studio usually supports sck auto-clock adjust for AVRs running down to 1MHz.  That USBasp firmware can be upgraded to support lower speeds for AVRs running at 128KHz.  In addition it does have the hardware jumper (J3) support for slow sck clock, but only if you update the firmware.  I have one of those USBasp programmers and have tried this, so I know it works.  But I think you have a bigger problem with your fuse selection.

Are you saying you programmed the low fuse byte with 0xF8?  If so then yes, you will need to connect an external ceramic resonator (not a crystal according to the datasheet) in the range from 400KHz - 900KHz.

The low byte fuse setting for the internal 8MHz clock should have been something like 0xE2.


bigal83

Problems solved, hooked up a 500KHz ceramic resonator and set the fuses back to 16Mhz ext. and everything is back to normal.


...USBasp firmware can be upgraded to support lower speeds for AVRs running at 128KHz.  In addition it does have the hardware jumper (J3) support for slow sck clock, but only if you update the firmware.  I have one of those USBasp programmers and have tried this, so I know it works.  But I think you have a bigger problem with your fuse selection.


Would be great with the updated firmware, I've been running with the 2011-05-28 all the time but people keeps saying that there is an update to it. I would be very happy if you could give me the newer one!

I've also read that the J3 jumper is obsolete for the newer updates like 2011-05-28, but you mean that it is first in the later updates it is used?

Cheers!

hiduino

#12
Mar 29, 2013, 07:34 am Last Edit: Mar 29, 2013, 07:52 am by hiduino Reason: 1
Glad to see you have figured it out.

About your USBasp programmer, do you still get this output from avrdude?
Code: [Select]

avrdude: auto set sck period (because given equals null)
avrdude: warning: cannot set sck period. please check for usbasp firmware update.

If so, then you are not running the USBasp 11-05-28 firmware.  This means the USBasp programmer does not support the -B option.  But it doesn't mean there is an actual problem and you don't need to update if it's working well for you.  It could be that your USBasp firmware supports a built in auto-clock instead of the -B option.  I have several of these types of programmers and they run fine.  You can just ignore that warning.

The J3 hardware jumper is not totally obsolete.  In some cases where you can't use the avrdude -B option, like from the IDE or some other software, then having a hardware jumper can be very helpful.  The caveat is that not all USBasp firmwares support the J3 option.  I do know that the 11-05=28 (and 2009-02-28) firmwares do support the J3 option, in addition to supporting the -B option.  Older firmwares (2006 and older) only support the J3 option.


bigal83

Thank you for increase my understanding about the USBasp and surroundings :)

Back to try to get my ATMega2560 board do accept the bootloader without giving a missmatch, cheers!

bperrybap


I've also read that the J3 jumper is obsolete for the newer updates like 2011-05-28, but you mean that it is first in the later updates it is used?

In the official USBasp releases, the jumper always overrides the ISP clock rate.
If the newer code is used you can set the rate through the commands over the USB
interface. But even if you do set it with a command, the jumper still overrides that setting.

So while you don't necessarily have to use the jumper to get a slower clock, it still
works with the newer firmware.

--- bill

Go Up