Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

burning fuse kills ATMEGA 328P

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
MilkyWay

Bascom Member



Joined: 27 Sep 2015
Posts: 4

PostPosted: Wed Apr 03, 2019 4:57 pm    Post subject: burning fuse kills ATMEGA 328P Reply with quote

burning fuse kills ATMEGA 328P

I have a circuitry running perfectly with a ATMEGA 328P using the internal oscillator at 1 MHz.
Because of timing problems with the UART I want to run it with an external quartz at 3.86 MHz.
Therefore, the fuse SUT_CKSel should be changed to "Ext.Crystal, 3-8Mhz 16KCK..".
In order to do this I used the following set-up: AVRStudio 4 with programmer AVRISP MKII at 125 kHz.
Before changing the fuse the device signature was verified: 1E 95 0f :which is OK
After programming the fuses (nothing but SUT_CKSel was changed) the device signature had changed to 1E 01 18,
Varios attempts to reload the program with BASCOM-AVR (2081) failed.
I found no way to get the device working again.

A quasi sinusoidal signal (ca 1 Vpp) of 3.86 MHz at pin XTAL1 (loaded with 22pF, alike pin XTAL2) was measured with an Oscilloscope.

Apparently, the 328P was put into irregular state by burning the fuses.
(an earlier attempt with an other brandnew device had the same bad result)

It should be mentioned that all the descibed procedures worked out perfectly with an ATMEGA 8 in exactly the same hardware configuration.
(I just want to replace the ATMEGA 8 by the 328P (they are believed to be pincompatible) because I need more flashmemory for a software improvenent)

Is there somewhere a big difference between ATMEGA 8 and 328P which reqires a different kind of programming?
What went wrong or was overlooked? Any help/suggestions are very welcome
Thanks
Milkyway

(BASCOM-AVR version : 2.0.8.1 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Apr 03, 2019 8:15 pm    Post subject: Re: burning fuse kills ATMEGA 328P Reply with quote

Lots of text and very little information.
MilkyWay wrote:
What went wrong or was overlooked?

You forgot to post the target value of SUT_CKSel.

Can be many things, hardware issue, wrong user, a.s.o. Very Happy
Because it is a standard practice to fuse an ATMega for an external crystal, it would result in an enormous outcry throughout the whole Internet, if such is not possible on ATMegas, or a certain type of it. We would surely have heard this outcry.
At least I did not notice any rumor, that's why it is very likely to be only a special problem with your setup.

Disconnect the 3.86MHz crystal and caps, feed XTAL1 via resistor of 470 to 1k Ohm from an external clock source of 1 MHz or so.
The clock signal can be derived from another AVR or an crystal oscillator.
Try to connect again.
Back to top
View user's profile
MilkyWay

Bascom Member



Joined: 27 Sep 2015
Posts: 4

PostPosted: Thu Apr 04, 2019 1:10 pm    Post subject: burning fuse kills ATMEGA 328P Reply with quote

Thanks, MWS, for your quick response!
I didn't want to blame ATMegas at all, they are great devices, indeed.
Sorry, when my wording in the Subject-line was exaggerated, it's just a result of my frustration.

"it is very likely to be only a special problem with your setup. "
I certainly can't exclude it. However, hardware and software, including fusing, worked well with an ATM 8. Then the ATM 8 was taken out of the socket
and a brandnew 328P was inserted which also worked well with its internal clock. Only fusing the 328P failed.

"You forgot to post the target value of SUT_CKSel. "
I just selected the line "Ext.Crystal, 3-8Mhz 16KCK.." from the Pull-down Menue for SUT_CKSel, provided by AVRStudio 4 for the 328P.
How can I find out which target values are hidden behind that?

Thanks
Milkyway
Back to top
View user's profile
laborratte

Bascom Expert



Joined: 27 Jul 2005
Posts: 299
Location: Berlin

germany.gif
PostPosted: Thu Apr 04, 2019 3:43 pm    Post subject: Reply with quote

"You forgot to post the target value of SUT_CKSel. " :
I did forget where in Studio4 the values are shown but I'm pretty shure they are. In Studio 7 it is directly shown in the bottom part of the dialog. Search for "Fuse Register", "Value" and "EXTENDED, HIGH, LOW"


The M328P has an additional clock mode: "Low Power Crystal" vs. "Full Swing Crystal" (this is used by M8 ). Maybe you've selected the "low power" system and your hardware does not want to oscillate with that. Try "full swing".

Edit: Denglish corrected.


Last edited by laborratte on Thu Apr 04, 2019 8:19 pm; edited 1 time in total
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Thu Apr 04, 2019 4:26 pm    Post subject: Re: burning fuse kills ATMEGA 328P Reply with quote

MilkyWay wrote:
How can I find out which target values are hidden behind that?

http://www.engbedded.com/fusecalc

I tend to think about a hardware problem, if you compare external crystal setting of both controllers, there are remarkable differences, for example CKOPT at ATM8 while this bit is missing at ATM328 because it's embedded within CKSel.
You've likely fused to a low power mode, a swing of 1Vpp gives that hint.

Some question you'd need to answer:
If a PCB, what sort of design, custom, prototype or evaluation board?
If breadboard, are all required blocking capacitors connected?
Every GND connected?
Power supply, what type, 5V or 3.3V?
Tried another crystal?
Tried lower (12pf) capacitors for XTAL? If a breadboard is used, stray capacities are considerable.
Tried higher clock for MKII? 3.68MHz / 4 = 920 kHz, a bit lower, 500-800kHz would be ok.
I'd suggest to show also a picture of the setup or a circuit scheme.

The earlier and maybe more robust ATM8 design may work better under circumstances, where the low power mode of ATM328 won't.
It may be that the internal clock derived from the oscillator is not as clean, as the oscilloscope suggests, thus the ATM328 stutters.
Which may result in certain side effects.

That's why I've suggested to feed an external clock to XTAL1, however you did not respond to my suggestion.
Back to top
View user's profile
MilkyWay

Bascom Member



Joined: 27 Sep 2015
Posts: 4

PostPosted: Fri Apr 05, 2019 2:06 pm    Post subject: burning fuse kills ATMEGA 328P Reply with quote

Thanks to the two responders for brainstorming and helpful suggestions.

Hidden in the files of AVR Studio 4 I found the line:
<TEXT>Ext. Crystal Osc.; Frequency 8.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 4.1 ms; [CKSEL=1111 SUT=10] </TEXT>
which according to the datasheet, indeed, means operation in low power mode. Next time I shall try "full swing".

I work with a self-made breadboard at 5V (foto and circuit drawing are in preparation). Grounding and blocking caps are crosschecked.
Several crystals (in basic and harmonic modes) were employed with no improvement.

What could it mean that the device signature was different after fusing (it was reported in the first post). Shouldn't it
stay fixed in the prom? Could it mean that something (eg a short power break-down during the burning process due to a
weak power supply) corrupted the contents of the prom? That could explain the observed complete non-response of the device after fusing,
Or is it likely just a false read-out of a correct signature due to eg. an improper clocking (or so) and the flaw is somewhere else?

Next, I shall try to fuse a new device to a full-swing oscillation after the blocking caps of the powerline have been enlarged.
I shall report on the results.

Thanks
Milkyway
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Fri Apr 05, 2019 7:36 pm    Post subject: Re: burning fuse kills ATMEGA 328P Reply with quote

MilkyWay wrote:
I work with a self-made breadboard at 5V

Regular, not self-made breadboard contact rows easily build up some capacitance in the range of several pF, thus I suggest to try without crystal capacitors.
Quote:
What could it mean that the device signature was different after fusing

What could it mean that the controller does not respond? What can we read out of the magic crystal ball?
It looks simple: the controller is clock delirious.
Quote:
Next, I shall try to fuse a new device to a full-swing oscillation

Next you shall try to feed that damn external clock into XTAL1, after I've mentioned it now the third time.
It is a secret trick in forum communication to react to the potential helpster, otherwise the helpster will cease to help.

Should you want in contrary to use the forum as a platform to commune with yourself about the errors which result from potential other errors, which result from unknown errors, which again show certain side effects, for example a glowing pin 1 - just let me know.
Back to top
View user's profile
JC

Bascom Member



Joined: 15 Dec 2007
Posts: 586
Location: Cleveland, OH

usa.gif
PostPosted: Sat Apr 06, 2019 2:25 am    Post subject: Reply with quote

As you were told, you likely set the Fuses for an External Osc, not an External Xtal.

An External Osc is a clock signal source, it looks like a chip, has its own V+ and Ground pins, and it outputs a square wave signal on one pin.
That square wave signal can be fed into the micro's Xtal pin, and drive the micro as the clock signal.

So,

Program another AVR to toggle an I/O pin as fast as you can.
Do
Set PortB.1
Reset PortB.1
Loop

That won't be quite a square wave, but it will work.

Now feed that almost square wave signal into the Xtal pin on the micro.
ALSO connect a common ground wire between the dead micro and the micro generating the clock signal.

Now, set the programming Speed to the absolute slowest speed the programming software can be set at.

Then try to read the micro's signature.

If you can read the signature, then try to read the Fuses, and then reset them as needed.

Report back.

JC
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sat Apr 06, 2019 7:21 am    Post subject: Reply with quote

JC wrote:
As you were told, you likely set the Fuses for an External Osc, not an External Xtal.

Have to disagree.

Clock speech 'ext. crystal osc.' for the 328 means low power crystal oscillator, not external clock.
You can find out by using above 'engbedded' link, select ext. crystal osc. 3-8 MHz 16k 4.1ms, this will result in CKSEL3..0 SUT1..0 = 1101 10
Looking that up from data sheet, you'll find reference to Low Power Crystal Oscillator, fast rising power.

My advise to feed external clock was because a) to revive the controller instead of flashing the next one to death, and b) if that won't work, to learn about a more serious problem, which imho will be the hardware setup.

One more hint: if the controller is fused for fast rising power as in above sample, the controller expects exactly that, means a hard voltage rise from the power supply.
If the power supply's voltage in contrary is raising slow, problems with this setting are guaranteed.
Back to top
View user's profile
MilkyWay

Bascom Member



Joined: 27 Sep 2015
Posts: 4

PostPosted: Mon Apr 08, 2019 12:17 pm    Post subject: burning fuse kills ATMEGA 328P Reply with quote

Hi all,

The original problem was that an attempt failed to simply replace an ATM 8 by a pincompatible and functionally identical ATM 328P

The solution is easy!

In contrast to an ATM 8 (and others) the ATM 328P employs a prime clock of 8 MHz. It is followed by an 1/8 prescaler in order to provide the standard internal clock of 1 MHz.
This prescaler can be selected/deselected by the CKDIV8-fuse and is by default (factory setting) activated (tickmark in the box). What was not known or anticipated
was that the prescaler remains active when an external frequncy device (crystal, resonator or so) is employed by setting appropriate values of SUT_CKSEL-fuse.
So in our particular case, with an 3.6 MHz quartz attached and the prescaler still active, the ATM 328 operated internally at about 450 kHz.-
The clock of the ISP-interface for the programmer, however, was still set to 125 kHz (default setting of the AVR Studio 4). So the requirement, that ISP-clock must
be less than 1/4 of the system clock, was violated. There was no communication between the programmer and the ATM 328 any more (e.g the read out of the device
signature failed). The device appeared to be dead.
After having understood all this, the solution is very simple: Reduce the ISP-clock (to e.g. 6 kHz) which enables communication again and deactivate
the prescaler (remove the tickmark of the CKDIV8-fuse). After that everything was working perfectly. All previously "killed" ATM 328Ps could be rescued this way.

The lesson learned:
When you change from the internal 1 Mhz clock to a crystal (or so) by setting the SUT_CKSEL-fuse deselect AT THE SAME TIME the prescaler (CKDIV8) or at least consider to do so.

Thanks to all who have contributed to the brainstorming and for your suggestions. All were recognized and considered even though it probably doesn't look like this.
I've learned a lot from you!
Thanks again and all the best

Milkyway
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Mon Apr 08, 2019 5:04 pm    Post subject: Reply with quote

Good to hear it's solved.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum