## Eleven running slow

The "Eleven" is our Uno-equivalent Arduino-compatible board, but with a number of improvements including prototyping area, a mini-USB connector, LEDs mounted near the edge, and the D13 LED isolated using a FET. [Product page]
platypus
Posts:14
Joined:Mon Aug 13, 2012 11:01 am
Eleven running slow
I have two V1.0 Elevens - one works fine, the other has a problem with running very slowly, about 1/10 normal speed.

The 328P was swapped for a brand new chip, today.

It accepts sketches and programming using a AVRISPMKii.

A test sketch from Examples, Liquidcrystal , needed delay set from 1000 to 100 to bring character update to about normal speed ie one per second - thats how I found the timing problem.

Could it be a damaged crystal/or crystal timing capacitor/s? Don't think much else could cause this, or could it?

angusgr
Freetronics Staff
Posts:853
Joined:Tue Apr 09, 2013 11:19 pm
Location:Melbourne, Australia
Contact:

### Re: Eleven running slow

Hi platypus,

Interesting problem, must have been annoying to figure out though!

A faulty crystal is one very likely culprit.

The other possible culprit would be fuses. On a brand new 328p chip, it defaults to using the internal 8MHz internal RC oscillator with the /8 divider set, meaning you get a 1MHz clock frequency. 1/16 of normal is somewhat close to what you're measuring.

That only applies if you haven't set the fuse values on the new chip either, though. If you used the Arduino IDE's "Flash Bootloader" option then the fuse values should be set correctly as part of that process.

To be 100% sure, you can dump the fuses (and a bunch of other interesting data) with:

Code: Select all

avrdude -c avrispmkII  -p m328p -v

You should see in the output something like this (if they're set correctly):

Code: Select all

avrdude: safemode: lfuse reads as FF
avrdude: safemode: hfuse reads as DE
avrdude: safemode: efuse reads as 5

Once you can rule out fuses, I'd say crystal is the only likely culprit. Has it been like this since you got it new, or is this a recent development?

- Angus

platypus
Posts:14
Joined:Mon Aug 13, 2012 11:01 am

### Re: Eleven running slow

Thanks Angus - the Avrdude cmd line did not work - it gave a verbose number of chip options.

However I did burn bootloader and ran a few sketches which showed the processor timing is back to normal.

Can you tell me where I might have made an error in that cmd line script?

I have also used Studio6 to check out fuses but instead of firing that up it is a much simpler option just to burn bootloader or run your script, when it works correctly.

To answer your question - the 328p was the unfortunate victim of many tests, one involving neutral using a mains volt divider. I knew ADC 2,3 were affected but it continued to work on all the other ADCs. Then I decided it was time for a new chip, when I ran into the fuse issue.
It might have been kinder just to hit it with a hammer to see if it would disintegrate!!

I haven't used bootloader for a year or so, I always use the AVRISPMKii programmer, so I suppose I was a bit rusty on checking fuse condition.

It's nice that it was just fuses and shows that we need to run bootloader at least the first time on a new chip to do initial settings.

angusgr
Freetronics Staff
Posts:853
Joined:Tue Apr 09, 2013 11:19 pm
Location:Melbourne, Australia
Contact:

### Re: Eleven running slow

platypus wrote:Thanks Angus - the Avrdude cmd line did not work - it gave a verbose number of chip options.
Hmm, OK. I probably have a newer avrdude version than you.

The critical option is just "-v" that tells avrdude to print verbose information about the chip. You should be able to reuse the "-c" (programmer type) and -p (MCU chip type) arguments that you've been using with avrdude already. My guess is maybe your version doesn't support the "m328p" abbreviation.
platypus wrote:However I did burn bootloader and ran a few sketches which showed the processor timing is back to normal.
Oh, excellent! Good to hear.

platypus wrote:To answer your question - the 328p was the unfortunate victim of many tests, one involving neutral using a mains volt divider. I knew ADC 2,3 were affected but it continued to work on all the other ADCs. Then I decided it was time for a new chip, when I ran into the fuse issue.
It might have been kinder just to hit it with a hammer to see if it would disintegrate!!
No problems, I've found avrs to be unreasonably tough in the face of some of the abuse I've inflicted on them, too.
platypus wrote:It's nice that it was just fuses and shows that we need to run bootloader at least the first time on a new chip to do initial settings.
Yes, or at least set the fuse bits.

You can do this with avrdude at the same time you flash your program, by adding the arguments "-U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m" at the end of the avrdude command line. Avrdude accepts multiple "-U" options, each to write to a different section of the chip.

Alternatively you can always pick up a preprogrammed atmega328p directly from us, it should have the bootloader and the fuses set already.

If you want to explore some of the other fuse options, there's a quite good online calculator here: http://www.engbedded.com/fusecalc

- Angus

platypus
Posts:14
Joined:Mon Aug 13, 2012 11:01 am

### Re: Eleven running slow

Thanks again Angus.

Do you have a link to your version of Avrdude please. Mine does not support the 328 at all.

angusgr
Freetronics Staff
Posts:853
Joined:Tue Apr 09, 2013 11:19 pm
Location:Melbourne, Australia
Contact:

### Re: Eleven running slow

I'm using avrdude 5.11.1, but I run Linux so it's probably not much use to you.

There's a version of avrdude bundled inside the Arduino IDE, you'll find it if you look under hardware\tools\avr\bin\ You can add that directory to your PATH if you want to be able to easily run it from the command line.

- Angus

platypus
Posts:14
Joined:Mon Aug 13, 2012 11:01 am

### Re: Eleven running slow

I can only see an Avrdude version of 5.10. I can now see the 328p

I haven't used Avrdude in cmd line to upload or even check a controller.

Is there a tutorial on using Avrdude - the cmd line options are no help!

angusgr
Freetronics Staff
Posts:853
Joined:Tue Apr 09, 2013 11:19 pm
Location:Melbourne, Australia
Contact:

### Re: Eleven running slow

Sorry platypus, I was labouring under the delusion that you were already using avrdude with your programmer somehow! (Although I should have worked out that you weren't several posts back.)

There are some good examples in the avrdude documentation:
http://www.nongnu.org/avrdude/user-manu ... nvocations

And the adafruit tutorial is pretty good:

Here are a few precanned recipes to get you started:

Flash "myprogram.hex" to the atmega328p:

Code: Select all

avrdude -c avrispmkII  -p m328p -U flash:w:myprogram.hex
Read fuses and other chip info (as mentioned in the previous post):

Code: Select all

avrdude -c avrispmkII  -p m328p -v
Set the fuses correctly for an Eleven or other Arduino-compatible atmega328p board:

Code: Select all

avrdude -c avrispmkII  -p m328p -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m

Flash your program and set the fuses in one pass (note that I'm just combining multiple -U options together on a single command line):

Code: Select all

avrdude -c avrispmkII  -p m328p -U lfuse:w:0xff:m -U hfuse:w:0xde:m -U efuse:w:0x05:m -U flash:w:myprogram.hex

Hope that helps,

Angus

angusgr
Freetronics Staff
Posts:853
Joined:Tue Apr 09, 2013 11:19 pm
Location:Melbourne, Australia
Contact:

### Re: Eleven running slow

Oops, one more thing: If you are using the avrdude version that came with Arduino then you may also need to add a "-C" argument that specifies the location of the avrdude.conf file, something like "-C C:\path\to\my\avrdude.conf". It'll be under your Arduino directory in "hardware\tools\avr\etc\avrdude.conf"

If you have a version of avrdude that you installed standalone then it will probably find the avrdude.conf file automatically, no need for the -C argument.

And a final tip, if these command lines get too long and unwieldy then it may be worth writing a batch file and putting your programming command in that.

platypus
Posts:14
Joined:Mon Aug 13, 2012 11:01 am

### Re: Eleven running slow

OK thanks Angus. I have always found Avrdude unwieldy and have not needed to use it. Likely won't go down that path now either.

I have found that Atmels studio 6/now 6.1, is good for checking and programming fuses, even uploads if you feel the need, using avrispmkii programmer. Using the avrispmkii, Studio6.1 will check any of Atmels controllers, not just the limited range that Arduino offers.

I can't figure out why anyone would want to play with a low level cmd line script when high level APIs are much easier to use and very likely will result in less pain with the whole procedure.

However, I prefer using The Arduino IDE (1.0.3 ERW) with the Avrispmkii and have always used this ICSP programming. Nick Gammon suggested some time ago to look into the Avripsmkii and I would never look at another programmer - its a total waste of time.

When you find out that it only takes about 8 seconds to upload just about any sketch (after it compiles (about 15 seconds), using this fantastic programmer (about \$45 including freight), then why stuff around with inferior hardware with the result of never knowing if your code even uploaded correctly and also it will likely take ages to upload using other programmers?

Sounds like an ad for Atmel - no affiliation here, its just the best hardware to use.

Thanks Angus.