Go Down

Topic: Can I run an Atmega168 at 1Mhz (Read 1 time) previous topic - next topic

zooto68

Can I run an Atmega168 at 1Mhz with the Arduino bootloader on it? if so, what do I need to do to get the bootloader to work?

I want to make a battery operated device where speed is not critical so running it at 1Mhz (or even 8Mhz if that is easier) will give a much logner battery life.

Has anyone done this before?

dcb

#1
Dec 06, 2008, 10:18 pm Last Edit: Dec 06, 2008, 10:19 pm by dcb Reason: 1
I'm sure it is doable but it might take a custom bootloader to get the communications right or possibly you can just change the upload speed to some value that is 1/8 of the lilypad.  

dcb

#2
Dec 08, 2008, 05:00 pm Last Edit: Dec 08, 2008, 05:04 pm by dcb Reason: 1
Ok, 1mhz  it works!!  I hacked together an example from the lilypad bootloader, tested millis and serial communication too.

1. exit arduino
2. unzip http://opengauge.org/projects/slowduino.zip to your bootloader directory
3. edit your boards.txt and add this to the bottom of the file and save it:
Code: [Select]

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

slowduino.name=slowduino

slowduino.upload.protocol=stk500
slowduino.upload.maximum_size=14336
#slowduino.upload.speed=19200
slowduino.upload.speed=2400

#slowduino.bootloader.low_fuses=0xe2
slowduino.bootloader.low_fuses=0x62
slowduino.bootloader.high_fuses=0xdd
slowduino.bootloader.extended_fuses=0x00
slowduino.bootloader.path=slowduino
slowduino.bootloader.file=slowduinoBOOT_168.hex
slowduino.bootloader.unlock_bits=0x3F
slowduino.bootloader.lock_bits=0x0F

slowduino.build.mcu=atmega168
slowduino.build.f_cpu=1000000L
slowduino.build.core=arduino


4. start arduino, select board slowduino, burn bootloader.
5. enjoy :)

It is hacked to run at 2400 baud for uploading.  here is a script I had to tweak but it also sends out data at 2400 baud from the script running @1MHZ:

Code: [Select]

#define ledPin 13

void setup(){
 pinMode(ledPin,OUTPUT);
 Serial.begin(19200);
 UBRR0L=25;//2400 baud @1mhz hack
}

void loop(){
 digitalWrite(ledPin,HIGH);
 delay(1000);
 digitalWrite(ledPin,LOW);
 delay(1000);

 Serial.println(F_CPU);
}


Of course it could be better/faster baud, but if you don't care about that then this works.

Note: It doesn't matter if you have a crystal installed, these settings will effectively ignore it (same with lilypad).

RedDot

Thanks, might give this a try later

zooto68

Cool. I will give this a go too. Thanks.

Go Up