Upload to 328p slow with USB AVR Programmer

Hi,

I am using the USB AVR Programmer (https://www.pololu.com/catalog/product/1300) to program a 328P which is on a 7-Segment Serial Display I got from Sparkfun (http://www.sparkfun.com/products/9765. The program uploads and executes properly, however it seems to take longer than it should and I get a timeout at the end when it tries to verify the upload. I have used the programmer successfully for other devices so I don’t think its the programmer.

Here is the output:

Launching C:\WinAVR-20100110\bin\avrdude -pm328p -cavrispv2 -PCOM4 -v -Uflash:w:main.hex:a 
Output:

avrdude: Version 5.10, compiled on Jan 19 2010 at 10:45:23
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "C:\WinAVR-20100110\bin\avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : avrispv2
         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                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65     5     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : STK500V2
         Description     : Atmel AVR ISP V2
         Programmer Model: AVRISP
         Hardware Version: 15
         Firmware Version Master : 2.10
         Vtarget         : 0.0 V
         SCK period      : 69.5 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.07s

avrdude: Device signature = 0x1e950f
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "main.hex"
avrdude: input file main.hex auto detected as Intel Hex
avrdude: writing flash (2902 bytes):

Writing | ################################################## | 100% 64.35s

avrdude: 2902 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex auto detected as Intel Hex
avrdude: input file main.hex contains 2902 bytes
avrdude: reading on-chip flash data:

Reading | avrdude: stk500_2_ReceiveMessage(): timeout
avrdude execution aborted
####

Anyone have a clue what is happening?

TIA,
Mike

Hello. 64s is definitely too slow! It looks like the SCK period / ISP frequency setting on your programmer is incorrect. Please run the configuration utility that came with the programmer’s drivers to set the programmer to use 200 kHz. Alternatively you can run avrdude with the “-B 3” option.

The default frequency is 200 kHz, which is fast enough to program most AVRs in seconds, but slow enough to work on most AVRs even if they are running at 1 MHz. Do you know how the ISP frequency setting got changed on your programmer?

–David

No I don’t know how it got changed. I don’t think I ran the utility before (but I could be wrong). I will check this tonight when I get home.

Thanks David,
Mike

Hi David,

That did, it works! SCK period is now 252.9 us. Before I made the change the configuration utility did not have a value in the ISP frequency dropdown. I set the ISP frequency to 200kHz as you suggested and the slow write and timeout at the end are gone.

Thanks!
Mike

Hi Mike,

I’m glad to hear it’s fixed.

There are a number of ways to change the programmer’s ISP frequency, including our configuration utility, AVR Studio, and avrdude. Is it possible you copied and ran an avrdude command that used the -B argument to change the ISP frequency?

- Ben

Hi Ben,

That is possible. Now that I know what to look for, it should not be a problem again.

Thanks for your help,
Mike