Mega 2560: converting to 14.745 MHz

Hello All,

I'm attempting to convert a Mega 2560 to 14.745MHz in order to run the serial at 921.6k baud. I've found a couple of references, but they're not quite the same scenario as I'm in and so I've found myself going in circles trying to figure it out. Most of them seem to be a few years old and are dead ended or missing info:

http://forum.arduino.cc/index.php?topic=62631.0

http://forum.arduino.cc/index.php?topic=61384.0

With this one being the closest but a bit over my head:

http://forum.arduino.cc/index.php?topic=262976.15

So far, I've socketed my board to be able to change crystals:

and made a new entry in boards.txt:

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

mega2560.name=Arduino Mega 2560 14.7MHz

mega2560.upload.protocol=wiring
mega2560.upload.maximum_size=258048
mega2560.upload.speed=115200

mega2560.bootloader.low_fuses=0xFF
mega2560.bootloader.high_fuses=0xD8
mega2560.bootloader.extended_fuses=0xFD
mega2560.bootloader.path=stk500v2
mega2560.bootloader.file=stk500boot_v2_mega2560_14_7MHz.hex
mega2560.bootloader.unlock_bits=0x3F
mega2560.bootloader.lock_bits=0x0F

mega2560.build.mcu=atmega2560
mega2560.build.f_cpu=14745000L
mega2560.build.core=arduino
mega2560.build.variant=mega

The next step looks to be to modify the stk500boot.c file, but this is where I get stuck... not sure what to do here. The only example I could find was for an ATmega 168. This is all I've been able to spot in that file, at line 228:

/*
 * define CPU frequency in Mhz here if not defined in Makefile
 */
#ifndef F_CPU
	#define F_CPU 14745000UL
#endif

Then after that I believe I need to go after the makefile, but I haven't gotten that far yet.

I have, at my disposal, an UNO and a Sparkgun FTDI Basic to use for burning the new bootloader when I get that far.

Also, I'm wondering, since I can readily switch the crystals...

Is there any chance I can simply define the clock speed within the sketch, use the 16MHz crystal to upload as normal, swap to 14.7MHz, and go? Seems too simple to be true, but a guy can dream :slight_smile:

Any guidance is appreciated. Thanks!

You do realise that the crystal you are replacing is not the clock for the ATmega2560 but for the small ATmega that does the USB-serial conversion. The clock for the ATmega2560 is a tiny resonator. Take a look at the Eagle design files on the Mega2560 page: http://arduino.cc/en/Main/arduinoBoardMega2560

Nope, I didn't realize that. Shame on me.

So that means that the crystal for the main processor is going to be the little surface mount guy to the back and left of my socket in the pics above, over near the power bank of pins. Same goes for the Uno.

Well, that stinks. Is there any other option for me, or am I looking at building something standalone now? I keep going further down the rabbit hole with this project, lol.

I was trying to use the Mega because it has multiple UARTs for me to use while I try to learn to communicate with my device... this way I can echo everything to the serial monitor to check my work. Once I'm in the device building phase I'll only need the one UART at 921.6k as a slave. I'm also stuck at 5V reference for ADC since I'll be using automotive-grade sensors.

EDIT

Wait, that doesn't leave the door open to change the clock freq of the 16U2 chip, without affecting the main processor, does it?

I don't know if it is of any use, but the original Uno (and clones) has provision made for a crystal even though it doesn't use one. But that doesn't address the multiple UART requirement.

Idon't believe current boards are not set up to remove resonator for 328P/2560/(32U4?) and replace with crystal caps.

32U4 boards look to be crystal equipped. I am guessing it is needed to support the USB speeds, just as there is a crystal with the 8U2/16U2 USB/Serial chips.

...in order to run the serial at 921.6k baud...

Why? What's wrong with 1M?

The other device is hard-coded at 921.6k. That has been confirmed by the designer himself.

Have you considered using a bridge...
https://www.google.com/search?q=spi+uart+bridge

If you prefer something DIP, Atmel describes how to build a bridge using an ATmega8...
http://www.atmel.com/Images/doc2557.pdf

I believe the m2560 UARTs have an SPI mode.

Something to read up on, I have nine hours of flying ahead of me. Thanks.

The Mega 2560 has SPI capability.

It looks like this might be the easy button for me, for now at least:

I might try one when I get back on the continent. I need to read the documentation a little more and see what is involved in implementing it.

This did the trick, thank you for the suggestion! I'm finally able to communicate with my device:

The rest of my question involves me learning how to parse the incoming data, I'll probably start a new thread for that.