Arduino UNO @ 20MHz

Hi Nick,

No it doesn't get hot at all. I test it now for 4 hours in a row and i found out that serial, adc conversion and eeprom read/write works well.
No trouble so far. I've change one other board and put it to the test.

I will see in the morning if it goes well.

I ordered 100 x 20 MHz crystals for $5.69 as well.

We'll see what happens with that one. :slight_smile:

Nick,
I get crystals from Tayda:
http://www.taydaelectronics.com/crystals-resonators-oscilliators/crystals.html
They have pretty low prices on everything they sell and their shipping is pretty
low as well.

--- bill

Thanks Bill.

If the worst comes to the worst, they can become stocking-fillers next year.

"What, this, Dad?"

"It's a crystal, darling"

"Cool!"

Today I tried getting an ATmega328P-PU to work at 20MHz. I downloaded the optiboot.zip file and copied the contents to my optiboot folder (I'm using Arduino-1.0.3 on linux). I made the necessary changes to boards.txt. I then started the Arduino ide and selected the "GVI High Speed (5V-20MHz-250k Baud)" board. Burned the bootloader with an USBasp, uploaded without errors. I then hooked up my ftdi usb/serial converter to the board and tried uploading the blink sketch. But no luck, it can't get serial communication. I tried another ftdi usb/serial converter but I got the same error:
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

Just to be sure I plugged the chip in another board with a 16MHz crystal. Bootloaded the Uno bootloader and uploaded a couple of sketches, no problems there, so the chip is fine.

When I try uploading a sketch the led on pin 13 blinks a couple of times. So can I assume that the bootloader is working?

What is the entry for boards.txt for the board you selected? In particular, the upload baud rate?

Where did you get the bootloader which expects to run at 20 MHz?

From a previous post in this topic: Arduino UNO @ 20MHz - #15 by gvi70000 - Programming Questions - Arduino Forum

I copied the code from that post to my boards.txt file, baud rate is set to 250000.

Hmm. Well I was getting strange error messages if I had a non-standard baud rate:

avrdude: ser_setspeed(): tcsetattr() failed
avrdude: ser_open(): can't set attributes for device "/dev/cu.usbserial-A900gcHm": Invalid argument
ioctl("TIOCMGET"): Bad file descriptor
avrdude: ser_close(): can't reset attributes for device: Bad file descriptor

I get this:
Using Port : /dev/ttyUSB0
Using Programmer : arduino
Overriding Baud Rate : 250000
avrdude: serial_baud_lookup(): Using non-standard baud rate: 250000
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: Send: 0 [30] [20]
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

Uploading sketches with the USBasp works.

Did you change the xtal to a 20MHz one?

would you not just change the crystal to a faster one?
do you really need to change the code?

devobtch

gvi70000:
Did you change the xtal to a 20MHz one?

Yes, 20MHz crystal bought from Tayda Electronics. I tried 2 just to be sure. I also tried putting the chip on a breadboard with 20MHz crystal, caps, ... but got the same error. I can upload sketches through my USBasp but can not make a serial connection.

I would like to revisit this thread(yes I know it is old) as it seems to have encountered the most untimely death,

So, because it is still completely unclear to me(noob), perhaps someone will be kind enough to comment on these....

  1. whether or not you can actually operate the ATmega328p on a breadboard with a 20Mhz crystal, while all the things requiring timing remain correct,
    2)If so, what is the general step by step procedure to do this. To clarify....I would assume most people capable of using this forum would be able to cut and paste something like a boards.txt file. However, I would less likely assume the same people looking for help on this forum to be able to correctly modify the contents inside. Same goes for Makefile, Optiboot, etc. files.

Many Thanks!

  1. whether or not you can actually operate the ATmega328p on a breadboard with a 20Mhz crystal, while all the things requiring timing remain correct,

You can certainly operate on the faster crystal. As for the "things requiring timing" there are two parts:

  • The bootloading process
  • The running sketch

In the running sketch the simplest thing would be to compensate internally. For example, to wait one second you wait for:

delay (1000UL * 20 / 16);

That would increase the number of "wait ticks" because each one will come faster. Similarly for things like setting the baud rate.

To upload sketches what I would personally do is use the ICSP uploader (I use another Uno for that) in which case it doesn't particularly matter what the clock speed of the target chip is.

Hi,
Thank you Nick for the help.
I would not exactly be too keen on trying to remember to "adjust" for the timing in sketches, unless as an absolute last resort.
I remained confused enough as it is....just trying to do very simple sketches from the examples menu right now in order to learn how Arduino functions. I think this would only complicate matters. For example....the "UL" that you placed behind 1000 is new to me, what does it do? Otherwise, delay(1000 * 20/16) does actually make a little sense to me.

Same goes for the ICSP. I haven't a clue what that is.( in spite of many, many previous searches on the topic) My conclusion is that it is just "another" method to program Arduino that I need not concern myself with right now.

I am sorry if this is redundant, but allow me to ask my questions in another way:
Considering that I am using an UNO r2 to burn the bootloader to bare chips on the breadboard right now......and then using an FTDI usb adapter to connect the "new" breadboarded Arduino to a pc......and I have both 16 and 20Mhz crystals available to me.

  1. is there a proper bootloader that I can install onto a bare ATmega328p(on a breadboard with 20Mhz crystal) that will allow me to load sketches from the IDE without requiring to account for the timing differences within the sketches?
    2)is there a proper boards.txt file that I can replace the existing one with that will allow me to load sketches from the IDE to the same breadboard with 20Mhz crystal without requiring to account for the timing differences within the sketches?
    3)is there any other files, ie, Makefile, optiboot, etc. that would need to be changed as well to allow me to load sketches from the IDE to the same breadboard without accounting for the timing differences from within the sketches?

or put more simply....If I am dead set on using a 20Mhz crystal on a breadboarded Arduino, and not being required to account for this in any way every time I load a sketch...is this even possible?

thanks again for your patience,

billcat:
I think this would only complicate matters. For example....the "UL" that you placed behind 1000 is new to me, what does it do? Otherwise, delay(1000 * 20/16) does actually make a little sense to me.

Read this:


Same goes for the ICSP. I haven't a clue what that is.( in spite of many, many previous searches on the topic)

This summarizes programming methods: Gammon Forum : Electronics : Microprocessors : Solving problems with uploading programs to your Arduino

My conclusion is that it is just "another" method to program Arduino that I need not concern myself with right now.

Using ICSP programming the exact clock speed won't matter, so maybe you should. If you up the frequency then the bootloader won't work unless you compensate.


  1. is there a proper bootloader that I can install onto a bare ATmega328p(on a breadboard with 20Mhz crystal) that will allow me to load sketches from the IDE without requiring to account for the timing differences within the sketches?

There may be, I'm not sure where it is. Otherwise take the standard bootloader, and try compensating in the boards.txt file (make a copy of the relevant entries and increase the baud rate by a factor of 20/16.

fasteruno.name=Arduino Uno at 20 MHz
fasteruno.upload.protocol=arduino
fasteruno.upload.maximum_size=32256
fasteruno.upload.speed=144000
fasteruno.bootloader.low_fuses=0xff
fasteruno.bootloader.high_fuses=0xde
fasteruno.bootloader.extended_fuses=0x05
fasteruno.bootloader.path=optiboot
fasteruno.bootloader.file=optiboot_atmega328.hex
fasteruno.bootloader.unlock_bits=0x3F
fasteruno.bootloader.lock_bits=0x0F
fasteruno.build.mcu=atmega328p
fasteruno.build.f_cpu=20000000L
fasteruno.build.core=arduino
fasteruno.build.variant=standard

That might work, I haven't tested it. I increased the bootloader baud rate to 144000 which is 115200 * 20 / 16


3)is there any other files, ie, Makefile, optiboot, etc. that would need to be changed as well to allow me to load sketches from the IDE to the same breadboard without accounting for the timing differences from within the sketches?

By changing f_cpu above it might compensate. However some testing I did in the part meant that the simple change actually threw up a lot of compiler errors for non-obvious reasons.

Someone else may be able to offer better advice.

thank you Nick,
I have read every bit of the information you have included and linked, but comprehended maybe 10%, hehe.
I certainly have no idea what all is happening regarding makefiles, optiboot, boards.txt, etc, when I "burn bootloader". These are just terms I have come across while attempting to learn about this. I simply know that I have been able to successfully install the bootloader using the UNO to ATmega(16Mhz) on breadboard a couple of times. Not even enough times to have the process committed to memory yet.

But I am especially unclear of this. You mentioned issues with the bootloader. (with 20Mhz breadboard)
Is the issue with the ability to actually load a sketch, or does it simply affect how the sketch functions after it is loaded? Or both?

I have found the boards.txt file that came with the IDE, and could cut and paste the fasteruno code you posted into it, but I am not sure that is what you are suggesting that I try, especially regarding your following "compiling errors" comment.

cheers!

The bootloader is called (usually) when the chip resets. If it finds incoming suitable data it uses that to reprogram the lower part of the flash memory (not itself, of course). Once done, or if it finds nothing, it jumps to address 0 to start the "real" sketch. Thus the bootloader is only important for changing the existing sketch, and you don't even need it for that if you use ICSP programming instead (via the 6-pin SPI header).

I have found the boards.txt file that came with the IDE, and could cut and paste the fasteruno code you posted into it, but I am not sure that is what you are suggesting that I try, especially regarding your following "compiling errors" comment.

You could copy and pasting my suggestion to the end of that file, and restart the IDE. Then choose "Arduino Uno at 20 MHz" from the Boards menu. If that doesn't work, oh well, don't choose it again. It might.

I hope your end application is worth all this pain. You are going to quite a bit of effort for only a 25% speed increase. With most applications the chip is sitting around waiting for input, the raw chip speed isn't all that important.

I've been following this thread with some interest.
I have built several of my Arduinos and have never used a bootloader (only ICSP) so the higher clock speed won't be a factor, however I'm confused about timings relating to other functions.
Is it necessary to compensate in the code for example, delay(1000*20/16) for a 1 sec delay, or will a simple edit of the boards.txt file be sufficient?

WhatEver.upload.speed=144000
        :
        :
WhatEver.build.f_cpu=20000000L

Is the baudrate edit also required?

True, for most applications it wouldn't be of much use but when generating video (especially VGA it will be very handy.

Well I tried just that for my VGA output and got a bit frustrated with it.

However, re-testing with my suggested setup seems to work (however not on a Mac).

On the Mac, it didn't seem to like that baud rate for the sketch upload:

Binary sketch size: 2,594 bytes (of a 32,256 byte maximum)
avrdude: ser_setspeed(): tcsetattr() failed
avrdude: ser_open(): can't set attributes for device "/dev/cu.usbserial-FTFAYL28": Invalid argument
ioctl("TIOCMGET"): Bad file descriptor
avrdude: ser_close(): can't reset attributes for device: Bad file descriptor

On Windows however it did, and I got the ASCII table sketch to work, however not at 115200 baud. At 9600 baud it worked fine.

Here is my setup: