Go Down

Topic: Arduino using external clock and 1mhz (Read 13677 times) previous topic - next topic

r55boy

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!


r55boy

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?

Coding Badly

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.

r55boy

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

r55boy

#19
May 17, 2012, 01:50 pm Last Edit: May 17, 2012, 04:32 pm by r55boy Reason: 1
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... ;-(

Coding Badly

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

r55boy

#21
May 17, 2012, 10:08 pm Last Edit: May 17, 2012, 10:58 pm by Coding Badly Reason: 1
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.

GoForSmoke

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?

1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Coding Badly

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.

GoForSmoke

If it's going to run on an UNO, doesn't it have to be set for 16 MHz clock?
1) http://gammon.com.au/blink  <-- tasking Arduino 1-2-3
2) http://gammon.com.au/serial <-- techniques howto
3) http://gammon.com.au/interrupts
Your sketch can sense ongoing process events in time.
Your sketch can make events to control it over time.

Coding Badly


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.

lemming

It may also be worth looking at this webpage on low power setup of Atmega chips.

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

It has some good tips and extra powersaving features not discussed in this thread.

r55boy

#27
May 18, 2012, 03:10 pm Last Edit: May 18, 2012, 06:16 pm by r55boy Reason: 1
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 }


Coding Badly


Why do you want to use a bootloader?

r55boy

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?

Go Up