Atmega 328p dead after changing clock frequency to 128khz

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

From what I have learned about this is that the serial communications frequency needs to be reduced to 32khz to restore communications to chip. I am using a usbisp type of programmer. Typing in avrdude shows a list of command options but I don't know if I need the B option or the i option and what the syntax would look like and how to insert the frequency (or period) and where to insert it in the command line. I want to restore the lfuse back to 62 to recover the chip. 

 

Can some show me a sample of the command syntax to do this?

 

Thanks,

 

Roger

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

You can use the -B option to specify the ISP speed. By default the value is 10 which means 100KHz clock, this is good for target clock speeds > 500KHz. If you want the high speed clockrate (400KHz) for target frequencies > 4MHz you can use "-B 1" to speed up programming. To calculate the SPI frequency from the delay value, use this formula:

SPI clock frequency in KHz = 1000/(1.5+B) where B is the delay value.

 

In general, the clock frequency should be at least 4 times larger than the target clock frequency. Try "-B 32" if you're having clocking issues, that should handle even 128khz clocks.

 

 

 

 

 

 

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

Here is last command I have tried. avrdude -p m328p -c usbasp -U -B 32 lfuse:w:0x62:m. With this command I am trying to restore the chip back to it's default clock setting.

Is there anything wrong with this command. I get an error rc1 unable to establish communication.

 

Thanks,

Roger

 

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

Looking at my programmer I notice it has two jumpers on it. It says usbasp v 2.0 on it but I think is an ebay clone. JP1 selects 3.3 or 5 volts. There is a jp2 but no jumper is soldered in. I this the one that reduces the clock frequency?

 

Thanks,

Roger

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

Think about it.   125kHZ with CLKDIV8 means 15kHz.   SCK freq must be < 4kHz.   e.g. -B250

 

Chinese USBASP firmware sets the SCK frequency automatically.

Chinese authors do not expect punters to select foolish clock fuses.   It will not attempt < 32kHz (from memory)

 

If  -B250 is accepted by avrdude you have probably got German firmware.

If you get a Warning,  you have probably got Chinese firmware.

 

Can you remember how you set the fuses?

 

Do you own a Uno?

This can rescue your chip i.e. it will do 4kHz SCK.

 

David.

Last Edited: Tue. Oct 15, 2019 - 04:16 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

 

Do you own a Uno?

This can rescue your chip i.e. it will do 4kHz SCK.

 

David.

 

I do have an uno but I have never used it. My computer is a linux machine and I dont' have an arduino.

 

Is the uno usable with avrdude?

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

An Arduino Uno will run on Linux, MAC, Windoze, ...

It can program an ATmega328P with avrdude

 

But the first step is to paste the avrdude command and response.

 

David.

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

david.prentice wrote:

An Arduino Uno will run on Linux, MAC, Windoze, ...

It can program an ATmega328P with avrdude

 

But the first step is to paste the avrdude command and response.

 

David.

 

OK, here is the last command I tried.

 

roger@AsusB350-A:~/avr/m328$ avrdude -p m328p -c usbasp -U -B 1000 lfuse:w:0x62:m

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.

 

I have two of the uno devices but they are chinese clones. Is this still a workable situation?

 

And also before I executed this last command I put a new chip in my programmer and verified it was working correctly by loading program code into it.

 

Thanks,

Roger

Last Edited: Tue. Oct 15, 2019 - 07:39 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Whoa -- deja vu.  Same topic; same AVR8 family; same week.  Coincidence?

https://www.avrfreaks.net/commen...

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

HI, a long shot, from a kind of de ja vue as well:  do you power the chip from the programmer only or is there power on ?

 

I had similar, the "SCK warning" from avrdude; I was supplying from programmer only (which was an exception, which usually dont), put on "normal power" and the programming went fine.

(was a cheap usbasp dongle, guess i should try to reprogram it)

Last Edited: Tue. Oct 15, 2019 - 08:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mopar_512 wrote:

roger@AsusB350-A:~/avr/m328$ avrdude -p m328p -c usbasp -U -B 1000 lfuse:w:0x62:m

 

Your syntax is wrong.  You should have:

avrdude -p m328p -c usbasp -B 1000 -U lfuse:w:0x62:m

But better to just write an empty command e.g.

avrdude -p m328p -c usbasp -B 1000

Which will just check the connection and report the Signature.   If it is ok,  repeat with the LFUSE command

 

David.

 

Edit.    Oops.  Your avrdude response indicates Chinese firmware that does not recognise -B1000

The auto-SCK might connect with a F_CPU=125kHz chip.   It has no chance if you had CLKDIV8 fuse i.e F_CPU=15.62kHz

Last Edited: Tue. Oct 15, 2019 - 09:29 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

gechxx wrote:

HI, a long shot, from a kind of de ja vue as well:  do you power the chip from the programmer only or is there power on ?

 

I had similar, the "SCK warning" from avrdude; I was supplying from programmer only (which was an exception, which usually dont), put on "normal power" and the programming went fine.

(was a cheap usbasp dongle, guess i should try to reprogram it)

 

Regular USBASP can power the target.   They usually have a 3x1 header J1.   Place jumper for 3V or 5V.  Remove jumper for unpowered.

The SCK warning implies Chinese auto-SCK firmware or (unlikely) 10-year old obsolete German firmware

 

There is little point in replacing good Chinese firmware with current (inferior) German firmware.   But it is your choice.

If you try the "shoot your foot" trick,   you learn not to do it again.    Recover chip with a Uno.

 

David.

Last Edited: Tue. Oct 15, 2019 - 11:07 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Unless it's really hard, replace the darn $2 chip and save yourself hours