I wrote this code:

#ifndef F_CPU
#define F_CPU 1105920UL

#include <avr/io.h>
#include <util/delay.h>

int main(void){

I programed it in atmega8:

sudo avrdude -c usbasp -p m8 -U flash:w:my.hex

micro programed ,OK, not problem:

i wanted use external crystal; then i connected crystal 11.0592 to pin 10 and 9, and rewrite fuse bit:

sudo avrdude -c usbasp -p m8 -U lfuse:w:0xE0:m

fuse bit rewrite and OK.not problem

now i realized this value 1105920UL is mistake, i edit code and change 1105920UL to 11059200UL ,

but when i programed micro, avrdude get me error:

$sudo avrdude  -c usbasp -p m8 -U flash:w:my.hex 

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: error: program 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.

My micro is lock? or i must rewire sck? how to i resolve this problem?!?

Thank you

  • \$\begingroup\$ Abstracting the crystal problem - the avrdude message about the SCK means that you have old usbasm firmware. Update it and you will be able to change the sck frequency \$\endgroup\$ May 27, 2018 at 0:18

2 Answers 2


Your problem is lfuse:0xE0 means "external clock". You have to use an integrated 8 to 16MHz crystal oscillator and connect it to XTAL1. Your device should be reprogrammable again, at least.

To use a bare crystal, you need an lfuse setting of 0xEE. But you cannot change this now, you had to connect the external oscillator you had selected before first.

  • \$\begingroup\$ yes, i use external crystal 11.0592 and connect it to pin 9(XTAL1) and 10(XTAL2) ,,but i can't re program my micro! \$\endgroup\$
    – Baba
    May 24, 2018 at 22:43
  • \$\begingroup\$ External clock != External crystal. Please read and understand pages 27, 32, and 217 of the ATmega8 datasheet. google.com/… \$\endgroup\$
    – Janka
    May 24, 2018 at 22:45
  • \$\begingroup\$ you could use an Arduino to generate the clock signal \$\endgroup\$
    – jsotola
    May 24, 2018 at 23:59
  • \$\begingroup\$ @jsotola how to do it? \$\endgroup\$
    – Baba
    May 25, 2018 at 1:38

I programed another micro (atmega16) and use it from external clock,

$regfile = "m16def.dat"
$crystal = 8000000
Config Portd = Output


Toggle Portd.1


Or in codevision (with internal rc 8Mhz) :

    PORTD.0 = ! PORTD.0

and connect D0 pin (atmega16) to xtal1 of locked micro (atmega8),

and now we can program locked micro and change fuse bit or set to default value.

U1 is atmega16 for use external clock

U2 is atmega8, locked micro, and we want change it fuse bit


thank from @Janka


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.