External crystal on 328p ...

I'm having a hard time using an Uno as an ArduinoISP to program another 328p on a breadboard. I've been able to do that with a bunch of Tiny ones (44s, 84s, 2313s, etc.) but having trouble with the 328p.

I can follow the bare breadboard setup and things work just fine, however I'm not too fond of having to remove the Uno's IC each time I do this. So I opted to use the setup where an external crystal is used, however this is where I run into problems.

I'm thinking it's because of the speed I'm using as the instructions say 16MHz crystal, but I'm using a 20MHz. Has anyone tried this and been successful? With a 20MHz crystal, it will let me burn the bootloader just fine (any of the following work: Arduino Nano w/ 328, Arduino BT w/ 328, Lilypad w/ 328, or even the Pro Minis w/ 328). But when I try to upload a sketch, it fails with a syncing error. Actually, all but the BT version will fail. The BT version will work, however it's too slow to start up, probably because it's expecting a Bluetooth module to be present so I won't be using that bootloader.

So I'm wondering if it's because of the 20MHz crystal that things are failing. As I said, going the bare bones breadboard method works just fine as it doesn't have a crystal anyway. But that causes things to clock at 8MHz and I want to bump that up.

Should I hook things up with a 16MHz crystal, program it then swap crystals afterwards? Will it work if i did that?

Suggestions?

So I'm wondering if it's because of the 20MHz crystal that things are failing. As I said, going the bare bones breadboard method works just fine as it doesn't have a crystal anyway. But that causes things to clock at 8MHz and I want to bump that up.

Should I hook things up with a 16MHz crystal, program it then swap crystals afterwards? Will it work if i did that?

Suggestions?

Yes, trying to run at 20Mhz is the root cause of your problems. While you can burn the bootloader code into the standalone chip fine via ISCP programming, once the bootloader tries to run it is 'hard-coded' to 'talk' to the ARduino IDE at a certain baudrate assuming it's running at 8 or 16Mhz. So to run at 20Mhz you have to get a recompiled bootloader hex file that is setup to run at 20Mhz. That is not avalible in the standard Arduino IDE distrubution, but there may be one out there somewhere in the wild. In the mean time you are probably better off just installing a 16Mhz crystal or ceramic resonator and run the standard bootloader.

Lefty

So I'm wondering if it's because of the 20MHz crystal that things are failing.

Yes

Should I hook things up with a 16MHz crystal, program it then swap crystals afterwards? Will it work if i did that?

No it will not work. This is because the boot loader has to know it has a 20MHz crystal so it can get the right baud rate to match the computer when uploading code.

I have built a 20MHz 644 system for my Reprap and programmed in the bootloader with a Uno running ArduinoISP without any problems. I did put a switch on it to disable the auto reset. However, I did have to get a "special" 20MHz 644 bootloader from the Sanguino site.

Awesome guys! Thanks for the replies. At least I know now I'm not (completely) insane yet. :slight_smile: I'll order some 16MHz resonators and call it a day ... Thanks again.

Another question ... Again, using the bare breadboard setup, I can burn a bootloader just fine (the one that came with the breadboard tutorial) and get sketches downloaded and running, no problem there. It sets the IC at 8MHz and all is peachy.

Now, why wouldn't I be able to burn an Arduino Pro or Mini 3.3V, 8MHz w/328 bootloader by using the ArduinoISP setup? It's the same clock speed. Is it because it's expecting an external 8MHz crystal and it's not there?

Now, why wouldn't I be able to burn an Arduino Pro or Mini 3.3V, 8MHz w/328 bootloader by using the ArduinoISP setup?

You can but the arduino application must have a boot loader designed for the speed your target system is running at, selectable in the boards menu.

Grumpy_Mike:

Now, why wouldn't I be able to burn an Arduino Pro or Mini 3.3V, 8MHz w/328 bootloader by using the ArduinoISP setup?

You can but the arduino application must have a boot loader designed for the speed your target system is running at, selectable in the boards menu.

Well, you lost me there. With the bare breadboard setup, no crystal, I can burn the bootloader (that comes with the bare breadboard tutorial) just fine. If I pick the Pro or Mini 8MHz w/328 as board and try to burn that, it fails with an 'Invalid device signature.' message. If I connect an oscillator (I only have a 20MHz on hand), it burns just fine. Which is why I'm thinking, it's failing because it's expecting an external one. I just need someone to verify that.