[solved] Changing CPU speed & boards.txt

what will this effect?

Sketches built for that board will run correctly at 8 MHz.

Do I also have to fiddle with the bootloader somehow?

Possibly. To upload at 115200 baud, you will need to install a bootloader built to run at 8 MHz. You may be able to halve the baud rate and leave the existing bootloader.

Thanks for the reply.

what will this effect?

Sketches built for that board will run correctly at 8 MHz.

Everything will still work? The only info I could find relating to this was from several versions ago, and apparently some things like PWM could stop functioning properly. Have all the functions been made CPU speed-independent now, then? Just want to make sure, as this chip has a range of tasks to do, from servo control to serial comms.

Do I also have to fiddle with the bootloader somehow?

Possibly. To upload at 115200 baud, you will need to install a bootloader built to run at 8 MHz. You may be able to halve the baud rate and leave the existing bootloader.

I thought this might be the case. I suppose that changing the mega2560.upload.speed parameter will change the upload speed, but as for modifying the bootloader I've no idea where to even start. If I want to use the Arduino bootloader, I can just modify that, right? I found the .hex files, but couldn't make head nor tail of them (What with them being a long list of hex numbers...).

Thanks for the help so far...

Tom

The bootloader as hardcoded values, as are the prescallers of the pwm..
With the correct code changes all will work, for the pwm you need to change the prescallers, so they are twice as small as the ones used for 16Mhz, and you could also try to upload at half the baud rate that the bootloader is expecting because he will be indeed running at half the normal baud rate.

for the pwm you need to change the prescallers

That's a bit strong. There are lots of people using PWM @ 8 MHz who haven't changed the prescalers.

TND:
Everything will still work?

Yes.

Have all the functions been made CPU speed-independent now, then?

Independent-ish. The PWM frequency is halved.

servo control, serial comms

You're good.

I thought this might be the case. I suppose that changing the mega2560.upload.speed parameter will change the upload speed

Yup.

but as for modifying the bootloader I've no idea where to even start

Don't. Try altering the upload speed. If that doesn't work, then go after the bootloader.

If I want to use the Arduino bootloader, I can just modify that, right?

The source files and makefiles are in this folder...
{ArduinoRootFolder}\hardware\arduino\bootloaders

Someone else will have to help with the details.

Okay well to get it to run at 8MHz I wouldn't need to change the prescaler, surely, as 8MHz is still the default 'Full speed' of the chip.

Thanks for all this info though - I fininshed soldering the chips to their breakout boards yesterday, so I should be able to test burn the bootloader some time next week. I'll report back then!

Tom

How can the servos work if the ppm signal is halved?

How can the servos work if the ppm signal is halved?

Are you using PWM to signal Servos? (you shouldn't) Or are you asking about the Servo library?

If I really want precise control I use the timers and hardware pwm.

Okay, I'm in the process of writing the code and getting a PCB made to do the testing. But as we all know, PCBs are cheap, so I only get one test, and even then I can't call it a test. :S

I'm developing the system using a normal Arduino MEGA until then (the old 1280 version), and I think a better approach would be for me to ask - If i change the speed, what difinitely WON'T work?

Thanks
Tom

An update.

I got my breakouts made, and soldered on the ATMega2560-8AUs.

I added a new board to boards.txt, the burnt the default bootloader using a USBTinyISP from Adafruit.

Something odd then, that maybe someone with an Arduino MEGA 2560 can help me with. With the old MEGA (the 1280), the bootloader put a program like 'blink' onto the chip, such that the 'L' LED would flash periodically. I'd best drescibe it as a 'dash-dash-dash...' sequence, if you think in morse code.

But when I put the bootloader on my reduced-speed 2560s, I get a 'dot-dash-dot-dash...' light sequence. Is this an indication that the bootloader upload didn't go quite right, or does the MEG2560 bootloader just have a different default flash sequence...?

I assumed that it was just a different flash sequence.

Next, I tried to upload my program using an FTDI Friend. I had managed to upload to the Arduino MEGA1280 using this method, but when I tried to do it on my 2560, it would sit at the 'uploading to board' status.

So then I added a new board to boards.txt that would use the USBTinyISP to upload the program. When using that, the program would upload but then there were two new issues;

The serial output is garbage now. I've tried receiving at half the baud I was expecting it to send at (and I even tried double, just to see), but it was always garbage.

Uploading the first program after burning the bootloader was fine, but if I tried to upload again then I'd get an error (something about verification - I forgot to write it down) and the program wouldn't be uplaoded.

...I know it's a lot, but any thoughts?

Tom

I can think of two possible problems...

  1. Fuse settings are not correct. Try a one-second blink Sketch. You will have to use the USBTinyISP to upload. Does it appear to blink about once a second?

  2. Atmel guarantees that the internal oscillator will be ±10% when a processor leaves the factory. This can be tuned to ±1%. Around 4.5% from the target frequency, high-speed serial communication starts to be troublesome. It is possible the internal oscillator is too far from the target value. Try a Serial Sketch with a very low baud rate (300).

Thanks for the quick reply.

I did the blink-check already - it seemed okay at the time, but I will test it more thoroughly and properly tomorrow.

As for your second point, I forgot to mention that I am already using an 8MHz crystal in place of a 16MHz one. This is also why I'm not sure why the fuse settings wouldn't be correct - the datasheet gives one setting for external crsytals in the frequency range 8MHz-16Mhz. And as that's all that's really changed, surely the fuse settings should be the same...

Tom

TND:
As for your second point, I forgot to mention that I am already using an 8MHz crystal in place of a 16MHz one. This is also why I'm not sure why the fuse settings wouldn't be correct - the datasheet gives one setting for external crsytals in the frequency range 8MHz-16Mhz. And as that's all that's really changed, surely the fuse settings should be the same...

The settings for 8 MHz external crystal are the same as the settings for 16 MHz external crystal. The fuse settings in your first post look OK. Disregard the part in my previous post about the internal oscillator.

...using the USBTinyISP to upload the program...Uploading the first program after burning the bootloader was fine, but if I tried to upload again then I'd get an error (something about verification - I forgot to write it down) and the program wouldn't be uplaoded.

In my experience, once you switch the fuse settings to an external crystal, if there is a problem with the external crystal, then the processor will not communicate through an ICSP. Once the crystal issue was resolved everything worked. Your experience sounds similar to mine but not identical.

Do you have anything connected to the board?

[quote author=Coding Badly link=topic=51955.msg392049#msg392049 date=1299638026]In my experience, once you switch the fuse settings to an external crystal, if there is a problem with the external crystal, then the processor will not communicate through an ICSP. Once the crystal issue was resolved everything worked. Your experience sounds similar to mine but not identical.

Do you have anything connected to the board?[/quote]

I did have, but I took it it all out to go 'back to basics'. I connected the 'L' LED, but that's all. (Aside from the crystal, of course)

Your point about the crystal is intersting. After I'd burnt the bootloader, I could upload Blink fine the first time. Then I changed the delay to 100ms (so that it would be obvious the program had definitely uploaded), and sometimes it would upload, sometimes it would give the verification error. I was never able to upload more than 2 programs without having to re-burn the bootloader.

It would be simpler if I were able to use the FT232 breakout I have... My first thought was that it's a problem with the timings, as maybe they're never 'syncing'?

I'll try another few crystals and double check the crystal setup and report back.

Thanks for the advice so far.

By "crystal" do you mean "crystal and capacitors"?

[quote author=Coding Badly link=topic=51955.msg392160#msg392160 date=1299658953]
By "crystal" do you mean "crystal and capacitors"?[/quote]

I do!

So after all that, and all your help, it worked.

When uploading the bootloader it gave a verification error, yet I can upload programs absolutely fine.

Having uploaded and tested them, I can confirm that all functions to do with timing work fine. All I had to change was the cpu speed and upload speed, as suggested.

I've no idea why it wasn't working before, but it does now!

Thanks for all your help.

I'm glad to know you have it working and thank you for the follow-up.

Hi

Thanks alot for your post and really help the people like us.

I am trying to burn bootloader in ATMega2560 8au with 8MHZ crystal but instead of Arduino bootloader I am planning to use Gammons Bootloader.

As per your suggestion we need not to change any thing in bootloader so i think if i make change in board.txt will be enough.

Please correct me if I am wrong.

Thanks.