Arduino Forum

Using Arduino => Microcontrollers => Topic started by: r55boy on May 10, 2012, 10:32 pm

Title: Arduino using external clock and 1mhz
Post by: r55boy on May 10, 2012, 10:32 pm
I want to adjust the default operation of my atmega328s so that they will run down to 2.1v or so from 2xaa batteries.

I know i need therefore to get them running at a lower speed, and i have 4MHZ, 8MHZ and 16MHZ crystals to hand.   I need to maintain good accuracy so think i need to stick with the external crystal based clock and not the +/- 10% internal one, and i need to do serial comms so i need the BAUD rates to still work as they should.

What i cant figure out despite days to trawling many many posts is how to adjust the fuse settings and burn the new bootloader.

I think i need to adjust the clock speed in the boards.txt file, and also use the Prescaler to divide the clock down.  So i can use my 8mhz external crystal and then divide by 8 with the prescaler, but cant see how to do this.

Any help really appreciated - i am 6 months into a project and now need to get it running at low voltage.

Many thanks all...
R55Boy
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 10, 2012, 10:45 pm
Start with the correct fuse settings...
http://www.engbedded.com/fusecalc

Low = CC, high = D7, extended = FE should give you...
Quote
Ext. Crystal Osc.; Frequency 3.0-8.0 MHz; Start-up time PWRDWN/RESET: 258 CK/14 CK + 4.1 ms; [CKSEL=1100 SUT=00]
Boot Flash section size=256 words Boot start address=$3F00; [BOOTSZ=11]
Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
Serial program downloading (SPI) enabled; [SPIEN=0]
Brown-out detection level at VCC=1.8 V; [BODLEVEL=110]


The 4 MHz crystal or 8 MHz crystal should work.  The startup time is fast.  The bootloader size is appropriate for Optiboot.  The BOD ensures the processor stops running when the batteries get close to empty.
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 10, 2012, 10:48 pm

For the bootloader I suggest using a pre-built Optiboot configured for 16 MHz or 8 MHz.  For 4 MHz, the baud rate is simply halved (or quartered).

To install the bootloader I suggest using OptiLoader.
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 10, 2012, 10:49 pm

Unless someone else does it first, I'll get back to you later today regarding boards.txt.
Title: Re: Arduino using external clock and 1mhz
Post by: JChristensen on May 11, 2012, 03:00 am
8MHz on 2xAA cells works well, whether on the internal oscillator or a crystal/resonator. Here is a thread with a boards.txt entry I use, and an 8MHz version of Optiboot:

http://arduino.cc/forum/index.php/topic,101064.msg760450.html#msg760450
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 11, 2012, 11:13 am
Thanks guys...some things to try over the weekend here.

But I have one outstanding question ... How to set the prescaler to divide the clock frequency from say 8mhz down to 1mhz, which is what I want to run at.

And codling badly...you are absolutely right...I need to change the brownout setting as that's what's stopping my app now at approx 2.7 volts.

will get to work on this at home over the weekend...work as usual gets in the way!
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 11, 2012, 08:01 pm
How to set the prescaler to divide the clock frequency from say 8mhz down to 1mhz, which is what I want to run at.


Everything you need to make that adjustment: Reply #1, Reply #4, the stuff between your ears.   ;)
Title: Re: Arduino using external clock and 1mhz
Post by: spirilis on May 14, 2012, 09:18 pm
I'd probably start with setting CKDIV8 in the fuses, then at the very beginning set CLKPR.  If you intend to use the Arduino bootloader and serial I/O to reprogram it you'd probably have to custom-build the bootloader with the speed of crystal_MHz/8, although I'd probably forego the bootloader and do direct ISP programming of the sketches.

Then very early on, in setup(), set the CLKPR register.  I think there's a way you can set things even earlier than that (one of the .initX code sections?) but I've never done it.

Looks like this is the procedure for setting it:

CLKPR = 0x80;  // Set Clock-Prescalar Change Enable
CLKPR = <value>;  // Set Clock-Prescalar

Clock division of 2 = 0x01, 4 = 0x02, 8 = 0x03, 16=0x04, 32=0x05, 64=0x06, 128=0x07, 256=0x08
So when CKDIV8 fuse is active, CLKPR is preinitialized as 0x03, with CKDIV8 fuse disabled it's 0x00.
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 14, 2012, 09:26 pm
I have set the fuses now to 0x4c (not 0xcc as i am running an 8mhz processor but want to divide by 8 to give me 1mhz runspeed), and 0xd7 and 0xfe suggested.  All burned well using optiloader burned into a 328 on my UNO board.

I then disconnect the optiloader lines D10-D13 and connect TX and RX instead to load a sketch onto my target device but get the not in sync error and cannot upload.

My boards.txt is below...any idea what i am missing?  I ahve the freq set to 1000000, but its pointing at an 8mhz hex file which i dont really understand. 

I should be possible to upload a sketch normally even though my target 328 is running 1mhz right?

Thanks so much in advance for any help guys...

uno1.name=Arduino Uno 1mhz
uno1.upload.protocol=stk500
uno1.upload.maximum_size=32256
uno1.upload.speed=115200
uno1.bootloader.low_fuses=0x4c
uno1.bootloader.high_fuses=0xd7
uno1.bootloader.extended_fuses=0xfe
uno1.bootloader.path=optiboot
uno1.bootloader.file=optiboot_atmega328_pro_8MHz.hex
uno1.bootloader.unlock_bits=0x3F
uno1.bootloader.lock_bits=0x0F
uno1.build.mcu=atmega328p
uno1.build.f_cpu=1000000L
uno1.build.core=arduino
##############################################################
Title: Re: Arduino using external clock and 1mhz
Post by: spirilis on May 14, 2012, 09:43 pm
I believe you need to rebuild the bootloader with a different F_CPU value.  That's outside the scope of the arduino IDE I think, so you'll have to find the directory where the bootloader code is stored, edit the Makefile and run "make" to compile it.  Search around for other threads on rebuilding the bootloader.
Title: Re: Arduino using external clock and 1mhz
Post by: JChristensen on May 14, 2012, 11:24 pm

uno1.upload.speed=115200


Probably too fast for a 1MHz system clock. I'd try 19200.
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 14, 2012, 11:42 pm

Imagine James Earl Jones, Barry White, and Isaac Hayes.  Now imagine them saying, "lower".   ;)

115200 * 1000000 / 8000000 = 14400  Ouch!  I think @r55boy is going to need a new bootloader.

On a more serious note, @r55boy if you are going for low power consumption you need to get rid of the bootloader.  The alternative is ISP programming...
http://arduino.cc/en/Tutorial/ArduinoISP
Title: Re: Arduino using external clock and 1mhz
Post by: JChristensen on May 15, 2012, 12:57 am
Actually I haven't tried a bootloader with a system clock < 8MHz, I just use ICSP.
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 15, 2012, 09:39 pm
So - i have tried the no bootloader route suggested by Codling Badly.  Here is what i did:-

I burned the ArduinoISP onto a new 328P in an UNO board successfully.

I then edited the boards.txt to add the line "<board>.upload.using=arduinoisp" to tell it to use the ArduinoISP instead of the bootloader.  See below for boards.txt.  The "arduinoisp" matches the values in preferences.txt file which is also in the /hardware/arduino directory.

The i hook up the UNO board to my target chip on a breadboard (with 8mhz crystal and fuses set as per before to 0x4c, 0xd7 and 0xfe) with the D11-D13 connected and reset, Vcc and GND.

When i hit upload i get
avrdude: stk500_getsync(): not in sync: resp=0xff
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xff

Still no further forward - any more suggestions? 

It sounds so simple - "run at 1mhz" - but soooo isnt!  Thanks so much in advance for more suggestions guys...

BTW - all i really want to do is get the thing running down to 2v or so and minimise power, so if i am overcomplicating please suggest alternative...maybe Arduino is not designed to do this?

BOARDS.TXT for ArduinoISP programming instead of Bootloader:

uno1.name=Arduino Uno 1mhz
uno1.upload.protocol=stk500
uno1.upload.maximum_size=32256
uno1.upload.speed=9600
uno1.upload.using=arduinoisp
uno1.bootloader.low_fuses=0x4c
uno1.bootloader.high_fuses=0xd7
uno1.bootloader.extended_fuses=0xfe
uno1.bootloader.path=optiboot
uno1.bootloader.file=optiboot_atmega328_pro_8MHz.hex
uno1.bootloader.unlock_bits=0x3F
uno1.bootloader.lock_bits=0x0F
uno1.build.mcu=atmega328p
uno1.build.f_cpu=1000000L
uno1.build.core=arduino
##############################################################
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 15, 2012, 09:57 pm
Quote
BTW - all i really want to do is get the thing running down to 2v or so and minimise power, so if i am overcomplicating please suggest alternative...maybe Arduino is not designed to do this?


For months, I've been using an Arduino (or Teensy) as a programmer.  The path you are on is a good choice that will get you to your goal.


Attached is the "breadboard core" I use.  The fuse settings may not be exactly what you want but this "core" is known to work so it eliminates one variable from the troubleshooting.  Simply extract the contents to your SketchRoot/hardware folder.  The final tree should be something like this...

[font=Courier New]\Arduino\Sketch\hardware\breadboard\boards.txt
\Arduino\Sketch\hardware\breadboard\bootloaders
\Arduino\Sketch\hardware\breadboard\cores
\Arduino\Sketch\hardware\breadboard\bootloaders\empty
\Arduino\Sketch\hardware\breadboard\bootloaders\empty\empty328Pat1.hex
\Arduino\Sketch\hardware\breadboard\bootloaders\empty\empty328Pat16.hex
\Arduino\Sketch\hardware\breadboard\bootloaders\empty\empty328Pat8.hex
\Arduino\Sketch\hardware\breadboard\cores\empty
\Arduino\Sketch\hardware\breadboard\cores\empty\Arduino.h
\Arduino\Sketch\hardware\breadboard\cores\empty\main.cpp
\Arduino\Sketch\hardware\breadboard\cores\empty\WProgram.h[/font]

With this "core" you can use Burn Bootloader to change the fuse settings and erase the processor (no bootloader is actually installed).


On the "programmer" (your Uno running ArduinoISP) connect an LED to pin 9.  At all times it should display a "heartbeat".  Does it?

How did you disable auto-reset on your Uno?  Capacitor?
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 16, 2012, 09:03 pm
Codling Badly

Thanks for the info mate - much appreciated.  No luck so far.

Capacitor working as required - heartbeat led is constant and no reset occurs when i try to burn the bootloader which is what we want.

I have set the fuses in the new boards.txt.  I have uploaded ArduinoISP to the UNO board.

But when i then hit "Tools->Burn bootloader with Arduino as ISP" i get the same message:

avrdude: stk500_getsync(): not in sync: resp=0xff
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xff

So the only thing i have made work is to burn a bootloader using optiloader, but then i cant load a sketch!

Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 16, 2012, 09:18 pm
More info - i just put a brand new 328p in as the target, which flashes an led on pin13, and the flashing is not interrupted at all during the attempted programming...

Am i correct linking both reset pins together and using the cap to suppress the forced reset by the UNO on upload?
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 16, 2012, 09:46 pm
More info - i just put a brand new 328p in as the target, which flashes an led on pin13, and the flashing is not interrupted at all during the attempted programming...


Excellent.

Quote
Am i correct linking both reset pins together


No.  Pin 10 on the "programmer" to RESET on the "target".  MISO to MISO.  MOSI to MOSI.  SCK to SCK.  GND to GND.  Ensure the target is powered.

Quote
and using the cap to suppress the forced reset by the UNO on upload?


Yes.  A capacitor is connected between RESET and GND on the programmer to disable auto-reset.
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 17, 2012, 12:34 pm
CodingBadly - Made the changes and still no different.

whatever i try i get the same sync error.

Capacitor and reset now correct - cap on programmer is suppressing reset, reset on target to D10, D11-D13 from prog to target, target has external crystal.  Optiloader works fine, but then i cant upload a sketch due to sync error.  ArduinoISP using my boards and your new suggestion sync error (in fact this happens even without a target chip on the breadboard).

I am wondering about uninstalling arduino (0022) and then reinstalling the latest?  Any baud rate settings anywhere - how come optiloader can do this but the arduino env cant?

I just tried using another UNO as the target board instead of my breadboard but same problem.

I note that you advised choosing "Burn bootloader" to upload a sketch using your new boards.txt, whereas if i use my one then i should be hitting upload as usual?  Is this correct?  In both cases the boards.txt says upload using arduinoisp.  i have the 4 lines connected D10-D13, and the TX/RX lines not coinnected - which must be right as this is using the ArduinoISP.

I have tried with 16 and 8mhz crystals on the target board.

ERROR:
avrdude: stk500_getsync(): not in sync: resp=0xff
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xff

MY relevant BOARDS.TXT entry:
##############################################################

uno1.name=Arduino Uno 1mhz
uno1.upload.protocol=stk500
uno1.upload.maximum_size=32256
uno1.upload.speed=9600
uno1.upload.using=arduinoisp
uno1.build.mcu=atmega328p
uno1.build.f_cpu=1000000L
uno1.build.core=arduino

YOUR modified BOARDS.TXT relevant entry:
###########################################################################

atmega328Pbb0.name=ATmega328P @ 1 MHz  (external oscillator; BOD level1)
atmega328Pbb0.upload.using=arduino:arduinoisp
atmega328Pbb0.upload.maximum_size=32768
atmega328Pbb0.bootloader.low_fuses=0x4c
atmega328Pbb0.bootloader.high_fuses=0xD7
atmega328Pbb0.bootloader.extended_fuses=0xfe
atmega328Pbb0.bootloader.path=empty
atmega328Pbb0.bootloader.file=empty328Pat1.hex
atmega328Pbb0.build.mcu=atmega328p
atmega328Pbb0.build.f_cpu=1000000L
atmega328Pbb0.build.core=arduino:arduino
atmega328Pbb0.build.variant=arduino:standard
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 17, 2012, 01:50 pm
Possibly related - the bootloader burned by optiloader - if i put that chip then in a Duemilanove i get sync errors.  some of my 328p's work only in UNO, some work only in Duemilanove.

Sorry if this is just confusing things... ;-(
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 17, 2012, 08:39 pm
Sorry if this is just confusing things... ;-(


It is.  You may be able to keep it all straight.  I cannot.  I suggest committing to one processor and one goal.  Do not add more processors to the mix until you get something that works.  Do not flip between a bootloader and ISP; pick one.  (ISP is a better choice for a low power project).
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 17, 2012, 10:08 pm
Right mate - sorry.  I have made a discovery - and its REALLY basic.

1. I put a fresh bootloader onto chip using Optiloader.
2. I load the BLINK sketch (using UNO 16MHz std board) - all fine
3. I hit load again to load the sketch a second time - fails.

Some of the logs attached from avrdude (had to chop it to get it under 9500 bytes to post).  So basically after a load a sketch to my chip, it wont take any more sketches, until i reburn the bootloader using optiloader.

Code: [Select]
Binary sketch size: 1018 bytes (of a 32256 byte maximum)
C:\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM5 -b115200 -D -Uflash:w:C:\Users\Sean\AppData\Local\Temp\build4803119672540980343.tmp\Blink.cpp.hex:i

avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

        System wide configuration file is "C:\arduino-0022\hardware/tools/avr/etc/avrdude.conf"

        Using Port            : \\.\COM5
        Using Programmer      : stk500v1
        Overriding Baud Rate  : 115200
avrdude: ser_open(): setting dtr
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv:
avrdude: Recv:
        AVR Part              : ATMEGA328P
        Chip Erase delay      : 9000 us
        PAGEL                 : PD7
        BS2                   : PC2
        RESET disposition     : dedicated
        RETRY pulse           : SCK
        serial program mode   : yes
        parallel program mode : yes
        Timeout               : 200
        StabDelay             : 100
        CmdexeDelay           : 25
        SyncLoops             : 32
        ByteDelay             : 0
        PollIndex             : 3
        PollValue             : 0x53
        Memory Detail         :

avrdude: verifying ...
avrdude: 1018 bytes of flash verified
avrdude: Send: Q [51]   [20]
avrdude: Recv:
avrdude: Recv:

avrdude done.  Thank you.

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


Then i press UPLOAD again:

Code: [Select]
Binary sketch size: 1018 bytes (of a 32256 byte maximum)
C:\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM5 -b115200 -D -Uflash:w:C:\Users\Sean\AppData\Local\Temp\build6732692812831451024.tmp\Blink.cpp.hex:i

avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
        Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

        System wide configuration file is "C:\arduino-0022\hardware/tools/avr/etc/avrdude.conf"

        Using Port            : \\.\COM5
        Using Programmer      : stk500v1
        Overriding Baud Rate  : 115200
avrdude: ser_open(): setting dtr
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv:
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: Send: Q [51]   [20]
avrdude: Recv:
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

avrdude done.  Thank you.
Title: Re: Arduino using external clock and 1mhz
Post by: GoForSmoke on May 17, 2012, 11:00 pm
You know these chips ship with internal clock set up as 8 MHz / 8 = 1 MHz?
Just saying, if you want 1 MHz then why bother with external clock at all unless you want precise?

And I wonder, from what I see on the pin map if you don't use external crystal then all 8 PORTB pins should be open for use?

Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 17, 2012, 11:28 pm
Quote
1. I put a fresh bootloader onto chip using Optiloader.


Using the latest version of OptiLoader?

Quote
2. I load the BLINK sketch (using UNO 16MHz std board) - all fine


Just so I'm clear... You upload OptiLoader to your Uno, run OptiLoader to install a bootloader to a processor on a breadboard, move the breadboard processor to your Uno for testing.  Correct?

Quote
3. I hit load again to load the sketch a second time - fails.


That indicates the lock-bits were not correctly set.
Title: Re: Arduino using external clock and 1mhz
Post by: GoForSmoke on May 18, 2012, 12:40 am
If it's going to run on an UNO, doesn't it have to be set for 16 MHz clock?
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 18, 2012, 12:50 am

Actually, it doesn't.  But the baud rate has to be adjusted (divided by 2 or 16) -or- a bootloader configured for the slower clock has to be installed.

In any case, I assume the end-goal is ISP uploads and that the with-bootloader attempt is a way-point.
Title: Re: Arduino using external clock and 1mhz
Post by: lemming on May 18, 2012, 05:23 am
It may also be worth looking at this webpage on low power setup of Atmega chips.

http://www.sparkfun.com/tutorials/309 (http://www.sparkfun.com/tutorials/309)

It has some good tips and extra powersaving features not discussed in this thread.
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 18, 2012, 03:10 pm
lemming - thx for the link - will spend some time digesting that.

Coding - i think u are bang on - i think i have screwed up the lock fuse - i changed the code in optiloader to get it to set my fuses after programming to my desired values - in the code below I changed the 0x2f,0,0,0,0 to 0x2f, Lowfuse, Highfuse, Efuse, 0.

I strongly suspect that this is not correct and need to find how to do this, for now i will set it back to 0x2f,0,0,0,0 and try again when i get home...

"atmega328P" }
,
0x950F, /* Signature bytes for 328P */
{
0x3F,0xFF,0xDE,0x05,0 }
,
{
0x2F,0,0,0,0 }

Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 18, 2012, 08:42 pm

Why do you want to use a bootloader?
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 20, 2012, 09:39 pm
I am used to using "upload sketch" but dont want bootloader specifically for sure - more than happy and hoping to use your suggestion provided previously.  I was only looking at bootloaders as i was trying to change fuse settings to set up the CKDIV8 and Brownout disable.  Wow - it seems like weeks ago i set out to achieve something seemingly so simple!!  :~

Been working this problem some more and i think the problem is baud rate.

Remember that optiloader works to my target board, but burning bootloader from within the Arduino environment doesnt, and neither does using your atmega328Pbb boards.txt file boards.

The error is:-
Code: [Select]
Binary sketch size: 1042 bytes (of a 32768 byte maximum)
C:\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM5 -b9600 -Uflash:w:C:\Users\Sean\AppData\Local\Temp\build5032370817224311009.tmp\Blink.cpp.hex:i

avrdude: Version 5.4-arduino, compiled on Oct 11 2007 at 19:12:32
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "C:\arduino-0022\hardware/tools/avr/etc/avrdude.conf"

         Using Port            : \\.\COM5
         Using Programmer      : stk500v1
         Overriding Baud Rate  : 9600
avrdude: ser_open(): setting dtr
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Send: 0 [30]   [20]
avrdude: Recv:
avrdude: stk500_getsync(): not in sync: resp=0xff
avrdude: Send: Q [51]   [20]
avrdude: Recv:
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0xff

avrdude done.  Thank you.


So - i tried the command line, and get the same problem until i switch to baudrate of 19200.  then it works:

Code: [Select]
C:\arduino-0022>avrdude -p m328p -P com5 -c avrisp -b 19200

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.13s

avrdude: Device signature = 0x1e950f

avrdude: safemode: Fuses OK

avrdude done.  Thank you.


So - how do i force the baudrate to 19200 instead of the 9600 that the arduino environment is using?  Does this make sense?
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 20, 2012, 09:45 pm
By the way - the port is set to 19200 baud in control panel.
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 20, 2012, 09:54 pm
This is definitely it!  I intercepted the command being generated and updated the baud rate in there from 9600 to 19200, see below, and IT WORKED!!!  So how to i make the IDE use a baud rate of 19200 when generating these command lines?

Code: [Select]
C:\arduino-0022\hardware/tools/avr/bin/avrdude -CC:\arduino-0022\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega328p -cstk500v1 -P\\.\COM5 -b19200 -Uflash:w:C:\Users\Sean\AppData\Local\Temp\build3447786868117704274.tmp\Blink.cpp.hex:i


My boards.txt is below and contains the 19200 baud.

Code: [Select]
atmega328Pbb0.name=ATmega328P @ 1 MHz  (external oscillator; BOD level1)

atmega328Pbb0.upload.using=arduino:arduinoisp
atmega328Pbb0.upload.maximum_size=32768
atmega328Pbb0.upload.speed=19200
atmega328Pbb0.bootloader.low_fuses=0x4c
atmega328Pbb0.bootloader.high_fuses=0xD7
atmega328Pbb0.bootloader.extended_fuses=0xfe
atmega328Pbb0.bootloader.path=empty
atmega328Pbb0.bootloader.file=empty328Pat1.hex
atmega328Pbb0.build.mcu=atmega328p
atmega328Pbb0.build.f_cpu=1000000L
atmega328Pbb0.build.core=arduino:arduino
atmega328Pbb0.build.variant=arduino:standard
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 22, 2012, 04:53 am
[font=Courier New]atmega328Pbb0.name=ATmega328P @ 1 MHz  (external oscillator; BOD level1)
atmega328Pbb0.upload.protocol=arduino
atmega328Pbb0.upload.maximum_size=32256
atmega328Pbb0.upload.speed=19200
atmega328Pbb0.bootloader.low_fuses=0x4c
atmega328Pbb0.bootloader.high_fuses=0xD7
atmega328Pbb0.bootloader.extended_fuses=0xfe
atmega328Pbb0.bootloader.path=empty
atmega328Pbb0.bootloader.file=empty328Pat1.hex
atmega328Pbb0.build.mcu=atmega328p
atmega328Pbb0.build.f_cpu=1000000L
atmega328Pbb0.build.core=arduino:arduino
atmega328Pbb0.build.variant=arduino:standard
[/font]
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 23, 2012, 10:06 pm
Coding - with these change to boards.txt i get error "avrdude: Can't find programmer id "arduino".

i have uploaded ArduinoISP to my programmer board and have it hooked up to the target on a breadboard.

My problem is just now that the Arduino environment seems to be setting the avrdude -b parameter to 9600 when it should be 19200 and i cant see why.  when i manually invoke avrdude and use -b 19200 it works.

thanks again for your help on this mate.
Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 23, 2012, 10:35 pm

Remove this line from your [font=Courier New]boards.txt[/font] file...

[font=Courier New]atmega328Pbb0.upload.using=arduino:arduinoisp[/font]
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 25, 2012, 10:21 pm
Coding - i dont have that line in there - just the lines in your posting below.  i guess its the upload.protocol it doesnt like ?

Boards.txt below.  Remember my only problem now is just the baud rate it is insisting on using...

Thanks...

Code: [Select]
atmega328Pbb0.name=ATmega328P @ 1 MHz  (external oscillator; BOD level1)

#atmega328Pbb0.upload.using=arduino:arduinoisp
atmega328Pbb0.upload.protocol=arduino
#atmega328Pbb0.upload.maximum_size=32768
atmega328Pbb0.upload.maximum_size=32256
atmega328Pbb0.upload.speed=19200
atmega328Pbb0.bootloader.low_fuses=0x4c
atmega328Pbb0.bootloader.high_fuses=0xD7
atmega328Pbb0.bootloader.extended_fuses=0xfe
atmega328Pbb0.bootloader.path=empty
atmega328Pbb0.bootloader.file=empty328Pat1.hex
atmega328Pbb0.build.mcu=atmega328p
atmega328Pbb0.build.f_cpu=1000000L
atmega328Pbb0.build.core=arduino:arduino
atmega328Pbb0.build.variant=arduino:standard
Title: Re: Arduino using external clock and 1mhz
Post by: r55boy on May 28, 2012, 02:00 pm
Guys any idea here?  All seems correct, and Coding Badly has this working, but no joy for me.  I've been tearing my hair out for a month now, and certainly know so much more about boards.txt etc etc, but fail with the baud rate that it insists on using, despite me telling it otherwise. Arghhhh!

Thanks for any steers...
Title: Re: Arduino using external clock and 1mhz
Post by: GoForSmoke on May 28, 2012, 02:10 pm
I can't be sure but you could try to back up your boards.txt and actually remove the lines you have commented out.

Title: Re: Arduino using external clock and 1mhz
Post by: Coding Badly on May 28, 2012, 09:49 pm

If everything else is correct (e.g. the entry in boards.txt) the baud rate is defined in the programmers.txt file...

[font=Courier New]arduinoisp.name=Arduino as ISP
arduinoisp.communication=serial
arduinoisp.protocol=stk500v1
arduinoisp.speed=19200[/font]