Go Down

Topic: [solved] Changing CPU speed & boards.txt (Read 4 times) previous topic - next topic

TND

Feb 11, 2011, 11:29 pm Last Edit: Mar 14, 2011, 09:09 pm by TND Reason: 1
Hi,

I've asked this before, but never got a definitive answer... I have an ATMega2560-8AU chip that I want to make a standalone circuit from. Its given speed is 8MHz, not the normal 16MHz.

If I make a new board profile in boards.txt based on the current 2560 one, such as;

Code: [Select]
##############################################################

mega2560.name=Arduino Mega 2560

mega2560.upload.protocol=stk500v2
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.hex
mega2560.bootloader.unlock_bits=0x3F
mega2560.bootloader.lock_bits=0x0F

mega2560.build.mcu=atmega2560
mega2560.build.f_cpu=8000000L
mega2560.build.core=arduino

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


what will this effect? Do I also have to fiddle with the bootloader somehow? The datasheet says that the timer fuse settings won't change (apparently there is one setting for an external xtal at 8-16MHz).

Thanks
Tom
Tom

Coding Badly

Quote
what will this effect?


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

Quote
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.

TND

Thanks for the reply.

Quote
Quote
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.

Quote
Quote
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
Tom

Senso

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.

Coding Badly

Quote
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.

Go Up