Arduino Forum

Using Arduino => Microcontrollers => Topic started by: simplesi on Sep 06, 2011, 10:05 pm

Title: Standard Fuse Settings for 16Mhz ATMega328p
Post by: simplesi on Sep 06, 2011, 10:05 pm
I've finally got myself a virgin ATMega328p and without uploading a bootloader, I've uploaded a simple variation of Blink and thought it was broken until I realised that because I hadn't set the fuses, the MCU was just using internal clock and running at 1MHz intead of 16MHz (I've included a crystal on my board).

So I'm thinking that if I set my fuses to the same as my ATMega328p Uno then I should be OK.

But I can't find what the bytes should be - could someone tell me please (I've given up trying to read them out from my Uno :( )

And of course, if the fuses should be different for a non-bootloader 16Mhz crystal clocked ATMega328p than my Uno, could I have those instead :)

regards
Simon
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Sep 06, 2011, 10:08 pm
I had exactly the same issue when I programmed my first 328! You can work out the fuse settings you need at http://www.engbedded.com/fusecalc (http://www.engbedded.com/fusecalc).

PS - If you just want the same ones as used in a standard Arduino, you can find them in the boards.txt file:

uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: simplesi on Sep 06, 2011, 10:32 pm
Quote
boards.txt


Ta :)
I used the values in there and used my little USBasp programmer with
Code: [Select]
avrdude -c usbasp -p m328p -C ../etc/avrdude.conf -U lfuse:w:0xFF:m -U hfuse:w:0xDE:m -U efuse:w:0x05:m

and my project imeidiately started running at the correct speed :)

Simon
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: floresta on Sep 07, 2011, 05:08 am
How about these:

Fuse calculator:   http://www.engbedded.com/fusecalc/
Arduino Default Fuses:   http://www.codingwithcody.com/2011/04/arduino-default-fuse-settings/

Don
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: wlewis on Jun 24, 2012, 01:34 am
Hi,

These setting did it for me too... 16mhz atmega328p.

lfuse = 0xff
hfuse = 0xde
efuse = 0x05

Thanks.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: floresta on Jun 24, 2012, 04:47 am
Have you heard of the phrase "a day late and a dollar short" out there in zeroland?

What has this post (to a stale thread) added that wasn't already said in the very first reply?

Don
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Oct 29, 2012, 08:00 pm

I had exactly the same issue when I programmed my first 328! You can work out the fuse settings you need at http://www.engbedded.com/fusecalc (http://www.engbedded.com/fusecalc).

PS - If you just want the same ones as used in a standard Arduino, you can find them in the boards.txt file:

uno.bootloader.low_fuses=0xff
uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05



Hi dc42.

I am getting similar issues as this with a 328p-au..
I've tried alsorts but am a bit stuck:

http://arduino.cc/forum/index.php/topic,129740.0.html (http://arduino.cc/forum/index.php/topic,129740.0.html)

Any ideas?

Thanks in advance.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: floresta on Oct 29, 2012, 08:54 pm
Quote
I've tried alsorts but am a bit stuck:


Have you tried either the default values or the values recommended in this thread?

Don
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: udoklein on Oct 29, 2012, 10:39 pm
When I use the Arduino IDE to flash the bootloader it always sets the proper fuses without any interaction on my behalf.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: CrossRoads on Oct 30, 2012, 01:53 am
I've been doing the same - burn a Uno bootloader to set the fuses.Then upload my sketch via File :Upload Using programmer.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Oct 30, 2012, 09:27 am

Hi dc42.

I am getting similar issues as this with a 328p-au..
I've tried alsorts but am a bit stuck:

http://arduino.cc/forum/index.php/topic,129740.0.html (http://arduino.cc/forum/index.php/topic,129740.0.html)

Any ideas?

Thanks in advance.


Looking at your post #7 in that thread, you are setting the baud rate to 300 on the mcu but then you have to set the PC to 2400 to communicate with it. So the UART in the mcu is running 8x faster than it should be. This isn't a problem with the CLKSEL fuse bit, that would cause the mcu to run 8x slower instead.

Are you sure that you have F_CPU set correctly in the boards.txt file you are using? Do you also find that delay and delayMicroseconds calls also execute 8x faster than they should?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 05, 2012, 11:45 pm


Hi dc42.

I am getting similar issues as this with a 328p-au..
I've tried alsorts but am a bit stuck:

http://arduino.cc/forum/index.php/topic,129740.0.html (http://arduino.cc/forum/index.php/topic,129740.0.html)

Any ideas?

Thanks in advance.


Looking at your post #7 in that thread, you are setting the baud rate to 300 on the mcu but then you have to set the PC to 2400 to communicate with it. So the UART in the mcu is running 8x faster than it should be. This isn't a problem with the CLKSEL fuse bit, that would cause the mcu to run 8x slower instead.

Are you sure that you have F_CPU set correctly in the boards.txt file you are using? Do you also find that delay and delayMicroseconds calls also execute 8x faster than they should?



Thanks for getting back to me Don.


From using the calculator I managed to get the baud correct with:

lfuse:w:0x77:m
(I know this is probably incorrect).
..and from messing about trying to set the fuses again I am back to the same issue of the baud reading out incorrectly and chasing my tail..



The board.txt is set to:

--------------------------------------------------------------------------------------

##############################################################

uno.name=Arduino Uno

uno.upload.protocol=arduino

uno.upload.maximum_size=32256

uno.upload.speed=115200

uno.bootloader.low_fuses=0xff

uno.bootloader.high_fuses=0xde
uno.bootloader.extended_fuses=0x05
uno.bootloader.path=optiboot
uno.bootloader.file=optiboot_atmega328.hex
uno.bootloader.unlock_bits=0x3F
uno.bootloader.lock_bits=0x0F
uno.build.mcu=atmega328p
uno.build.f_cpu=16000000L
uno.build.core=arduino
uno.build.variant=standard

--------------------------------------------------------------------------------------


The following worked when I had the baud reading at the correct rate:

- IDE does not upload
- AVRDude upload via Arduino ISP works
- Upload in IDE via Arduino ISP works
- Serial feedback (TX-RX loop) works [328 bypassed]
- Serial feedback via 328P works
- Holding reset at various times before/during/on upload no dice
- f_cpu=16000000L


I've double checked all my schematics, including the pull down 1k, 100nf cap between the 8u2 and the reset on the 328P-AU.
I have also removed and resoldered these components.

Could this be an issue with the 8u2?
I have managed to run the DFU many times with the same code I uploaded on to my R3 and this still uploads and works.

Thanks in advance for any suggestions!
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Nov 06, 2012, 12:00 am
So do delay() calls in sketches you upload delay for the correct amount of time or not?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 06, 2012, 12:08 am

So do delay() calls in sketches you upload delay for the correct amount of time or not?



Sorry, got my last post incorrect..

A delay(1000) posts at roughly 1 second. However the baud is mismatched.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Nov 06, 2012, 12:10 am


So do delay() calls in sketches you upload delay for the correct amount of time or not?



If you mean in a main body of code, they are not, also my baud is mismatching again..


Do they take too long? or not enough time? By what factor are they wrong?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 06, 2012, 12:14 am



So do delay() calls in sketches you upload delay for the correct amount of time or not?



If you mean in a main body of code, they are not, also my baud is mismatching again..


Do they take too long? or not enough time? By what factor are they wrong?



Sorry, I tried that again.

A delay(1000) posts roughly every second. The baud is mismatched..
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Nov 06, 2012, 12:22 am
Is the baud rate mismatched only when you are uploading a program through the bootloader, or it is also mismatched when you do a Serial.begin followed by a Serial.print ?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 06, 2012, 12:30 am
My head is spinning a little so please excuse me if I have missunderstood you here, but..

This is the sketch I am using:

--------------------------------------------
void setup()                   
{
  Serial.begin(300);         

void loop()                       
{
  Serial.println("Hello world!"); 
  delay(1000);
}
--------------------------------------------

When I bring up the serial monitor it posts at baud 2400 every second.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Nov 06, 2012, 12:45 am
In summary:

1. Delay calls execute in the correct amount of time. So the clock is almost certainly running at the right speed.

2. To communicate with the serial port of the device, you have to set the PC to a baud rate 8x higher than the device is supposedly set to.

Therefore, either the PC software is at fault and is running at a baud rate 8x lower than you ask for, or the UART in your 328p-au is running at a baud rate 8x higher than you ask for. Can you connect to a standard Arduino at 2400 baud using the same board setting, to verify that the PC software is operating correctly?

Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Nov 06, 2012, 01:11 am
I've just tried to communicate with my Arduino Uno at 300 baud, and it doesn't work. It works at higher baud rates. Maybe a bug in the Arduino software? Try a higher baud rate.

You might also like to upload the following sketch to see what the UART baud rate divisor is set to:

Code: [Select]

void setup()
{
  Serial.begin(2400);
}

void loop()
{
  Serial.print((int)UBRR0H, HEX);
  Serial.write(',');
  Serial.print((int)UBRR0L, HEX);
  Serial.write(',');
  Serial.println((int)UCSR0A, HEX);
  delay(1000);
}
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 06, 2012, 01:28 pm
I tried changing my port settings, this seemed to make no difference regardless of what I set the baud to..

I uploaded the sketch you kindly put up.

I had to change the begin from (2400) to (14400) as there was no option for x8 baud in the serial monitor.

This is what I got back:

"0, 8A, 2
0, 8A, 42
0, 8A, 42
0, 8A, 42
0, 8A, 42..." (repeats)

Until I hit reset and then it repeats from "0, 8A, 2".


All possible serials that are readable by IDE (serial x8):

14400 / serial 115200:

"0, 8A, 2
0, 8A, 42
0, 8A, 42
0, 8A, 42.."


4800 / serial 38400:

"1, A0, 2
1, A0, 42
1, A0, 42
1, A0, 42.."


2400 / serial 19200:

"3, 40, 2
3, 40, 42
3, 40, 42
3, 40, 42.."


1200 / serial 9600:

"6, 82, 2
6, 82, 42
6, 82, 42
6, 82, 42.."


and finally
300 / serial 2400:

"D, 4, 0
D, 4, 40
D, 4, 40
D, 4, 40.."


Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Nov 06, 2012, 02:20 pm
Can you remind me what you have connected between the microcontroller TxData pin and the PC?

The bad rate divisors from your data look OK to me. I'm wondering whether the USART is operating in synchronous master mode instead of asynch mode - that could explain the x8 speed. Try this sketch, which reads back all the USTAT control registers:

Code: [Select]

void setup()
{
}

void loop()
{
  Serial.begin(2400);
  byte ubrr0h = UBRR0H;
  byte ubrr0l = UBRR0L;
  byte ucsr0a = UCSR0A;
  byte ucsr0b = UCSR0B;
  byte ucsr0c = UCSR0C;
 
  //Serial.begin(2400);
  Serial.print((unsigned int)ubrr0h, HEX);
  Serial.write(',');
  Serial.print((unsigned int)ubrr0l, HEX);
  Serial.write(',');
  Serial.print((unsigned int)ucsr0a, HEX);
  Serial.write(',');
  Serial.print((unsigned int)ucsr0b, HEX);
  Serial.write(',');
  Serial.println((unsigned int)ucsr0c, HEX);
  delay(1000);
}


At 2400 baud I get: 3,40,62,98,6.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 06, 2012, 02:25 pm
Running the low fuse CLKDIV8 (0x77) posts at the selected baud but 8x slower, as expected..

I get back:

Serial(S)/Result(R):

S:300
R:??" ?|? "
(All other bauds are similar garbage)

S:1200
R:"6, 82, 2
   6, 82, 42.."

S:2400
R:"3, 40, 2
   3, 40, 42.."

S:4800
R:"1, A0, 2
   1, A0, 42.."

S:9600
R:"0, CF, 2
   0, CF, 42.."

S:14400
R:",` @¢ü,` Pm ,` Pm "
(All other bauds are similar garbage)

S:19200
R:"0, 67, 2
   0, 67, 42.."

S:28800
R:"¸øó¸¸h¸¸h"
(All other bauds are similar garbage)

S:38400
R:"0, 33, 2
   0, 33, 42.."

S:57600
R:"0, 10, 0
   0, 10, 40.."

S:115200
R:"0, 10, 2
   0, 10, 42.."


The Delay(1000) is now running posts at roughly 8 seconds (which I gather is expected?).
I hope this helps in some way.

I was just reading up on these commands and from what I gather they are to do with the Usart.
In terms of design, could noise from the crystal or other sources cause this issue, or is my design safe in terms of the mechanics?
IE is this a definite IC issue..
Could this be caused by the IC overheating, or is it something software orientated?

I'm just wondering as if my design is stable, at least I can move on from the actual design of the PCB itself, and start to focus on changing over IC's etc instead of having to knock up board after board trying new things..
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 06, 2012, 02:33 pm

Can you remind me what you have connected between the microcontroller TxData pin and the PC?

The bad rate divisors from your data look OK to me. I'm wondering whether the USART is operating in synchronous master mode instead of asynch mode - that could explain the x8 speed. Try this sketch, which reads back all the USTAT control registers:

Code: [Select]

void setup()
{
}

void loop()
{
  Serial.begin(2400);
  byte ubrr0h = UBRR0H;
  byte ubrr0l = UBRR0L;
  byte ucsr0a = UCSR0A;
  byte ucsr0b = UCSR0B;
  byte ucsr0c = UCSR0C;
 
  //Serial.begin(2400);
  Serial.print((unsigned int)ubrr0h, HEX);
  Serial.write(',');
  Serial.print((unsigned int)ubrr0l, HEX);
  Serial.write(',');
  Serial.print((unsigned int)ucsr0a, HEX);
  Serial.write(',');
  Serial.print((unsigned int)ucsr0b, HEX);
  Serial.write(',');
  Serial.println((unsigned int)ucsr0c, HEX);
  delay(1000);
}


At 2400 baud I get: 3,40,62,98,6.




Upon changing the fuses back to default:

I get: 3,40,62,98,6.
So that checks out!

I am using an ATMEGA8u2-AU for Tx/Rx..
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Nov 06, 2012, 03:40 pm
The programming on the atmega328p looks OK, and if delay calls are taking the right amount of time then the clock speed is correct. So my best guess it that it's something to do with the 8u2 programming, or the PC device driver, or a mismatch between the two. I think the PC sends a code to the 8u2 to tell it what baud rate to use, but maybe the meanings assigned to the codes in the 8u2 software are not the same as the ones used in the PC driver.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 06, 2012, 07:33 pm
I had a feeling there might be a problem between the PC and 8U2..

At least I'm not going nuts..

Basically the firmware I use for my R3 16u2 works for DFU over USB.
As far as I understand there is no difference between the 8u2 and -au?

I had wondered before if I would need to burn the fuses on the 8u2 but believed it to be able to work straight 'out of the box'. (This is the first time I have got this far..)

Is there a way of buring the fuses via USB, or will I need to ISP?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: dc42 on Nov 07, 2012, 12:24 am
I've just looked at the default settings for the 8u2 fuses in http://www.engbedded.com/fusecalc (http://www.engbedded.com/fusecalc) and it appears that it defaults to dividing the clock frequency by 8, just like the atmega328p. This explains why you need to set the PC to 8x the actual baud rate. I suggest you read the 8u2 datasheet to confirm this.

Unless you have put any bootloading code on the 8u2, you will need to program it via ICSP. How did you program it in the first place?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: clivemist on Nov 07, 2012, 01:36 pm
Ah.. I didnt..

Also I havent included a header in this design, I had messed up another part anyway, so just as well!

For now I will get this sorted, and hopefully it wil all lock in.

Fantastic, thanks for the help!
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Jul 24, 2014, 05:57 am
I have an Arduino Uno. Using PROGISP I think I accidentally overwrote the fuse settings to 0xD9E1, this thread says it should be set to 0x5DEFF. My Arduino was running blink code and it still is, but with the new clock its really slow, probably 10x slower. Unfortunately I can't just reset the fuse back to 0x5DEFF, PROGISP says it "Chip Enable Program Error." Arduino IDE gives
Code: [Select]
avrdude: stk500_getsync(): not in sync: resp=0x00
whenever I try to upload anything. Any suggestions on how to fix this? Did I brick my Arduino?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: CrossRoads on Jul 24, 2014, 07:22 am
Reburn the bootloader from the IDE using an AVR ISP Programmer. That should reset the fuses.
If you can't, then it's time for a new chip.


Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: westfw on Jul 24, 2014, 09:21 am
If you've really set HFUSE to 0xE1, then you've disabled SPI programming, and indeed "bricked" your chip to the extent that you'll need a HV Parallel programmer to un-brick it.  (However, you're not supposed to be able to disable SPI *using* SPI, so this shouldn't be the case.)  Most likely, you've just programmed the crystal oscillator to a mode that doesn't work with the actual crystal you have installed, and you can fix it by injecting a clock "manually."

http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=106325
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Jul 24, 2014, 04:37 pm
Thanks, new chip it is. I've tried to burn the bootloader multiple times with no luck.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Jul 24, 2014, 04:45 pm
I should have a 555 timer laying around that I can try and use as a clock input, what is not clear to me is if I can simply use 1Mhz or if it needs to be some other multiple of what I might have set the chip to look for.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Jul 24, 2014, 06:51 pm
I managed a 7kHz wave with the parts I had laying around, does the frequency need to be higher? I have this signal going into pin 9 on my arduino but I still can't re-program it through PROGISP.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: westfw on Jul 25, 2014, 01:07 am
You have to feed in ISP commands clocked (SCLK signal) at a fraction of the rate that the cpu is running at (1/16?)
I don't know offhand which programmers allow you to set the clock to arbitrary rates, or which programming tool SW permit you to set it...

Adafruit has a version of ArduinoISP that provides a relatively fast clock on one of the extra pins, which can be fed into the target CPU...
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Jul 26, 2014, 07:27 pm
Thanks for the replies. For ~$5 I can get a new Arduino pro mini, or for $4 I can get a new 328P chip, I'll just do one of those, its much easier  : )
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: CrossRoads on Jul 26, 2014, 07:36 pm
Get one with a bootloader on it, can use that one to bootload cheaper blank parts in the future.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Jul 27, 2014, 08:33 am
If I just get a standard 328P replacement can't I just burn the bootloader on using the Arduino IDE?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: CrossRoads on Jul 27, 2014, 08:38 am
No, you need a programmer - the programmer connects to the SPI pins for programmer the bootloader in. The IDE can do that, but you need a programmer.
An Arduino can be used as  a programmer:
http://www.gammon.com.au/forum/?id=11635
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Jul 27, 2014, 09:58 am
Will this programmer do?  https://www.sparkfun.com/products/9825

If not I have a $5 Arduino pro mini coming early next week.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: CrossRoads on Jul 27, 2014, 06:48 pm
Yes, that one will do.
In the IDE, select Tools:Programmer:USBasp
I have one but never set things up to use it, might be some driver setup needed as well.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 01, 2014, 07:17 pm
I have my Arduino Pro Mini and I thought it would be easy to program it, but I haven't had any luck yet  :(. Using my Sparkfun AVR pocket programmer ( https://www.sparkfun.com/products/9825 (https://www.sparkfun.com/products/9825) ) I'm trying to load the blink program. I have tried all the programmer types, none have worked. Most return;
Code: [Select]
avrdude: stk500_getsync(): not in sync: resp=0x00
The Pro Mini is powered and it looks like it came pre-programmed with blink. I'm trying to make it blink faster (really I'm just trying to verify my board & programmer all work) before I try and fix my other Arduino, or before I turn this Pro Mini into a quadcopter controller (the real reason I bought it).
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 01, 2014, 07:23 pm
I forgot to post images so here they are. I'm trying to program the Pro Mini using ICSP.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 01, 2014, 08:53 pm
I am able to burn the bootloader to the device, but none of the programs I've tried. I'm confused :S. I'm using Arduino IDE (forgot to mention this).
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 02, 2014, 09:26 pm
Got it. I need to use "upload using programmer" instead of the usual verify/upload buttons.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 13, 2014, 07:54 pm
Ok so I am thinking about fixing the fuse bits on my Arduino by using another of my Arduinos - I now have 2 Arduino Pro Minis. I've seen some links for using the Arduino as an AVR ISP but I dont think this is what I need, or at least its not totally complete as is; am I right? In this thread people have mentioned I need to send in a clock at a fraction of the incorrect clock the Arduino is currently set at, or the data comes in on a clock signal which is again a fraction of the incorrect clock, or something like this... I could use some help. I'm thinking this is the method I need to modify?
Code: [Select]
void start_pmode() {
  spi_init();
  // following delays may not work on all targets...
  pinMode(RESET, OUTPUT);
  digitalWrite(RESET, HIGH);
  pinMode(SCK, OUTPUT);
  digitalWrite(SCK, LOW);
  delay(50);
  digitalWrite(RESET, LOW);
  delay(50);
  pinMode(MISO, INPUT);
  pinMode(MOSI, OUTPUT);
  spi_transaction(0xAC, 0x53, 0x00, 0x00);
  pmode = 1;
}
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 13, 2014, 08:01 pm
I believe the Fuse that I wrote to my Atmega328P is 0xD9E1
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 13, 2014, 09:18 pm
I'm thinking this is the method I need to modify?


Why bother?  Just fetch Lady Ada's version of ArduinoISP that already has the necessary modifications.

Or, I believe Nick Gammon has a version.

Or, use this one...
https://code.google.com/p/arduino-tiny/downloads/list?can=2&q=tinyisp
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 02:45 am
Is that the same/similar thing to ArduinoISP sketch?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 03:53 am

I mentioned three things.  Which "that" are you referring to?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 05:01 am
What I need is some help doing "high voltage parallel programming mode" (http://mightyohm.com/blog/2008/09/arduino-based-avr-high-voltage-programmer/ (http://mightyohm.com/blog/2008/09/arduino-based-avr-high-voltage-programmer/)) on an Arduino that has bad fuse bits set. The Arduino does function, its running the blink code, only really slowly. Its not the delay in the code, its the frequency the chip is running at from bad fuse bits. Also I can't reprogram the chip through SPI again because of the fuse bits.

Several people in this thread said I could fix it with another Arduino, I just dont know how.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: westfw on Aug 14, 2014, 05:36 am
I think that the closest you can get to HV parallel programming with an Arduino is this 5V "rescue" shield: http://mightyohm.com/blog/products/hv-rescue-shield-2-x/

The clock injection you can get with the adafruit-modified Arduino ISP is NOT parallel programming, and will not fix some "bricked" AVRs (although the clock injection with serial programming DOES fix the most common bricking scenarios.) (And ArduinoISP does not support HV parallel programming at all.)

Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 05:40 am
Thanks. I was going to try and fix the Arduino for the experience, but at that price tag I'll probably just get a replacement like I had originally planned. I was hoping all I needed was a 2nd Arduino and nothing more.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 05:58 am
What I need is some help doing "high voltage parallel programming mode" ... The Arduino does function, its running the blink code, only really slowly


Asserting RESET stops the blinking?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 06:52 am
Hitting reset seems to lock it up. Blink code is loaded and if I hit reset the LED either stays off or stays on.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 07:18 am

Try this...
http://forum.arduino.cc/index.php?topic=182138.msg1349664#msg1349664

Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 08:05 am
Cool thanks I'll try it out.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 09:16 am
Ok so I have a few questions about that thread you linked. How many Arduinos are involved in this method? Just the bad one right?

I've downloaded tiny-isp-2-0100-0001.zip and extracted it to it's own folder. _TinyISP_BuildOptions.h already had
Code: [Select]
#define PROGRAMMER_SPI_CLOCK  SLOW in it so I left the file alone. The sketch compiles (no missing dependencies and such).

Using my USBTiny/USBTinyISP programmer ( https://www.sparkfun.com/products/9825 (https://www.sparkfun.com/products/9825) ) I tried to upload the sketch, no dice;
Code: [Select]
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

I'm able to upload this sketch on a good Arduino using the same programmer so I'm fairly confident I'm doing the steps right. Maybe the bit rate isn't slow enough? Let me know if you have any other ideas, thanks for your help.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 09:21 am
How many Arduinos are involved in this method? Just the bad one right?


No.  Two.  One serves as a programmer.  You upload the TinyISP sketch to that one then disable auto-reset.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 09:49 am
Ok so after I've uploaded TinyISP to the good arduino, I connect the 2 arduino's together like whats shown here? http://arduino.cc/en/Tutorial/ArduinoISP (http://arduino.cc/en/Tutorial/ArduinoISP)

Once the 2 Arduinos are wired up, my connections go programmer -> TinyISP -> bad Arduino ?

My good Arduinos are Pro Minis, so no usb. I have a USB programmer to go along with them, but I'm not sure if that will work or not. Here is how they're currently connected (http://www.ebay.com/itm/NEW-Arduino-Pro-Mini-USB-Programmer-Newest-Design-USA-Seller-FAST-Shipping/231303057344?_trksid=p2047675.c100012.m1985&_trkparms=aid%3D444000%26algo%3DSOI.DEFAULT%26ao%3D1%26asc%3D24895%26meid%3Dc6181dd0811c4615a13198a0819fc114%26pid%3D100012%26prg%3D10500%26rk%3D3%26rkt%3D10%26sd%3D231296779901 (http://www.ebay.com/itm/NEW-Arduino-Pro-Mini-USB-Programmer-Newest-Design-USA-Seller-FAST-Shipping/231303057344?_trksid=p2047675.c100012.m1985&_trkparms=aid%3D444000%26algo%3DSOI.DEFAULT%26ao%3D1%26asc%3D24895%26meid%3Dc6181dd0811c4615a13198a0819fc114%26pid%3D100012%26prg%3D10500%26rk%3D3%26rkt%3D10%26sd%3D231296779901));

USB programmer -> UsbTiny -> Bad Arduino via ISP

If this is correct, what code do I try to push onto the bad arduino? Just do a bootloader fix?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 09:59 am
I tried it out and now both arduino's are running blink at the same wrong clock speed   :~

They both blink in sync, 16 seconds on, 16 off
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 10:03 am
Ok so after I've uploaded TinyISP to the good arduino, I connect the 2 arduino's together like whats shown here? http://arduino.cc/en/Tutorial/ArduinoISP (http://arduino.cc/en/Tutorial/ArduinoISP)


Yes.

Quote
Once the 2 Arduinos are wired up, my connections go programmer -> TinyISP -> bad Arduino ?


No.  As I stated earlier, the "good" Arduino acts as the programmer.  Your dedicated programmer is not involved.

Quote
I have a USB programmer to go along with them, but I'm not sure if that will work or not.


Does not matter.  It is not involved.

Quote
If this is correct, what code do I try to push onto the bad arduino? Just do a bootloader fix?


Select the correct board under the Tools / Board menu.  Execute Tools / Burn Bootloader.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 10:05 am
Quote
No.  As I stated earlier, the "good" Arduino acts as the programmer.  Your dedicated programmer is not involved.

Right but my Arduino Pro Mini which doesn't have onboard USB has no way to connect to my computer. Usually I connect it through ICSP but those pins are now going to be used to program the bad Arduino, right?
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: westfw on Aug 14, 2014, 10:11 am
Quote
I tried it out and now both arduino's are running blink at the same wrong clock speed

Even after you disconnect them from one another?  It turns out that the LED pin IS one of the signals used to connect the two arduinos, so both LEDs will flash when the non-broken one does the flashing...
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 10:16 am
My good Arduinos are Pro Minis, so no usb. I have a USB programmer to go along with them, but I'm not sure if that will work or not. Here is how they're currently connected (http://www.ebay.com/itm/NEW-Arduino-Pro-Mini-USB-Programmer-Newest-Design-USA-Seller-FAST-Shipping/231303057344?_trksid=p2047675.c100012.m1985&_trkparms=aid%3D444000%26algo%3DSOI.DEFAULT%26ao%3D1%26asc%3D24895%26meid%3Dc6181dd0811c4615a13198a0819fc114%26pid%3D100012%26prg%3D10500%26rk%3D3%26rkt%3D10%26sd%3D231296779901)


That is not a "programmer".  It is a USB-to-TTL-serial-converter.

Do you have that?

Or the Sparkfun programmer (which is actually a "programmer")?  (https://www.sparkfun.com/products/9825)
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 10:17 am
I have both.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 10:20 am
Quote
Even after you disconnect them from one another?  It turns out that the LED pin IS one of the signals used to connect the two arduinos, so both LEDs will flash when the non-broken one does the flashing...


Ok they only blink in sequence if SCK is connected between them.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 10:28 am
I have both.


You will be using the USB-to-TTL-serial-converter.

You will not be using the Sparkfun programmer.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 10:37 am
Is there a specific sketch I now try and put on the bad Arduino? Do I just try and burn a new bootloader?

I get the following message if I try to burn a new bootloader or if I try and upload blink using the programmer;
Code: [Select]
avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 07:25 pm
Is there a specific sketch I now try and put on the bad Arduino? Do I just try and burn a new bootloader?


Tools / Burn Bootloader.  After selecting the correct board (the "bad" board).

Quote
I get the following message if I try to burn a new bootloader or if I try and upload blink using the programmer;
Code: [Select]
avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)


Under the Tools menu, click Programmer then Arduino as ISP.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 14, 2014, 11:33 pm
Ok tried to burn a new bootloader to an Arduino Uno, Arduino ISP programmer, still no luck;

Code: [Select]
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 14, 2014, 11:46 pm

Post the verbose output.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 15, 2014, 12:23 am
Here is verbose output for from the upload;
Code: [Select]
         Using Port                    : \\.\COM9
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
         AVR Part                      : ATMEGA328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         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    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                                  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  4500  4500 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  4500  4500 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  4500  4500 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  4500  4500 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 : STK500
         Description     : Atmel STK500 Version 1.x firmware
avrdude: Send: A [41] . [80]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [01]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [98]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
         Hardware Version: 0
         Firmware Version: 1.0
         Topcard         : Unknown
avrdude: Send: A [41] . [84]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [85]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [86]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [87]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [89]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us

avrdude: Send: A [41] . [81]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [01]
avrdude: Recv: . [10]
avrdude: Send: A [41] . [82]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [00]
avrdude: Recv: . [10]
avrdude: Send: B [42] . [86] . [00] . [00] . [01] . [01] . [01] . [01] . [03] . [ff] . [ff] . [ff] . [ff] . [00] . [80] . [04] . [00] . [00] . [00] . [80] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: E [45] . [04] . [04] . [d7] . [c2]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: Send: P [50]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]
avrdude: AVR device initialized and ready to accept instructions

Reading | avrdude: Send: V [56] 0 [30] . [00] . [00] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff]
avrdude: Recv: . [10]
avrdude: Send: V [56] 0 [30] . [00] . [01] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff]
avrdude: Recv: . [10]
################avrdude: Send: V [56] 0 [30] . [00] . [02] . [00]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [ff]
avrdude: Recv: . [10]
################################## | 100% 0.02s

avrdude: Device signature = 0xffffff
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

avrdude: Send: Q [51]   [20]
avrdude: Recv: . [14]
avrdude: Recv: . [10]

avrdude done.  Thank you.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 15, 2014, 03:44 am
Code: [Select]
avrdude: AVR device initialized and ready to accept instructions

...indicates that your "good" Arduino is acting like a programmer.  Excellent.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 15, 2014, 03:53 am
Code: [Select]
avrdude: Device signature = 0xffffff

...indicates that the target (the processor on your "bad" Arduino) is not responding.

The first step is to very carefully check the wiring.  Ensure there are no loose connections and that all connections are correct.  Then try again.

If that does not work, try reducing the clock rate.  This is the section of interest (the spi_send function near line #148 in TinyISP_SPI.cpp)...
https://code.google.com/p/arduino-tiny/source/browse/TinyISP_SPI.cpp?repo=isp#148
Double the value for both of the calls to delayMicroseconds (new value is 48 microseconds).  Re-upload TinyISP to the programmer (your good Arduino).  Then try again.

If that does not work, continue doubling the delay until the delay exceeds 12000 (6/(128000/256)*1000000).

If none of that works (or the avrdude output changes) then there is something else wrong.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: JohnnyFyve on Aug 15, 2014, 05:08 am
My reset pin is a bit flaky cause I have a 10uF cap between reset and ground (per the instructions here http://arduino.cc/en/Tutorial/ArduinoISP (http://arduino.cc/en/Tutorial/ArduinoISP)). I re-ran the code with and without the cap, but with the reset pin securely held in place, and I got a different device signature;
Code: [Select]
avrdude: Device signature = 0x000000

I found a post about a signature of 0x000000 here: http://forum.arduino.cc/index.php/topic,25385.0.html (http://forum.arduino.cc/index.php/topic,25385.0.html) but I haven't tried the suggestion(s) yet.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Aug 15, 2014, 06:17 am
Code: [Select]
avrdude: Device signature = 0x000000

...also indicates that the target (the processor on your "bad" Arduino) is not responding.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: westfw on Aug 15, 2014, 06:30 am
Quote
..indicates that the target (the processor on your "bad" Arduino) is not responding.

Or a wiring error (ie the response it not getting to the "programmer")  The SPI communications protocol just shifts data bits from the input pin into the peripheral; if you have something wrong with THAT pin connection, you end up shifting in randomness.
Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Outtasight on Apr 29, 2015, 06:00 pm
Winding back a bit...

Why are the Arduino Uno default extended fuses 0x05?  That's what it is in the Boards.txt file.  According to the fuse calculators I've looked at, this is an invalid / undefined setting.

The valid BOD settings for the extended fuses (according to the calculator) are:
0xFF (BOD disabled)
0xFC (BOD = 4.3V)
0xFD (BOD = 2.7V)
0xFE (BOD = 1.8V)

It also defaults the lock bits in the Boards.txt file to 0x0F which the calculator also says is invalid / undefined.

The valid Lock Bits settings (according to the calculator) are 0xFF for no lock downs on reprogramming.

http://eleccelerator.com/fusecalc/fusecalc.php?chip=atmega328p&LOW=FF&HIGH=DE&EXTENDED=FD&LOCKBIT=FF

Title: Re: Standard Fuse Settings for 16Mhz ATMega328p
Post by: Coding Badly on Apr 29, 2015, 09:18 pm
According to the fuse calculators I've looked at, this is an invalid / undefined setting.
Just because bits are undefined does not make zero values invalid.

I cannot speak about the m328p processor but two of the ATtiny processors always return zero for undefined fuse bits.  If values like 0xFE are used verification fails when trying to change the fuses.