programming speed of AVRs

Go To Last Post
10 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

quick question:

at what speed is an AVR programmed? Is it dependent on clock fuses?

I have an AVR set up with an external crystal clock in circuit (on a breadboard), and it programs fine, but when I move it to a circuit on a protoboard without a crystal, it won't program.

I initially thought it wasn't programming because I forgot to use decoupling caps, but I've added these now, and it doesn't seem to work without an external crystal.

I initially thought that AVRs program at a constant speed (which would allow you to recover if your crystal blew or was damaged), but now I'm wondering.

Probably a stupid question, but I have to ask. Even better, if you could point me to where I might find this information in data sheets, I'd love that. Tried looking, but I couldn't find anything amidst the whirlpool of information.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you are missing a clock source, the AVR will not program. Since you are using the external crystal on your breadboard, your clocksource is "external crystal". If you need to run it without the crystal, enable the internal RC oscillator.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thanks for clearing that up for me. I am no longer confused by what's happening :lol:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
at what speed is an AVR programmed?

The programming speed must be less than 1/4 of the cpu speed.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There are two factors.

1. how fast can you send the programming instructions.

2. how long does the AVR take to actually program once it has received the instructions.

(1) depends on the ISP clock (typically 230kHz for a 1MHz AVR)

(2) depends on the size of your program. e.g. a full 32k flash in a Mega32 will take about 2.5 seconds. 1k of eeprom in a Mega32 will take about 10 seconds.

A lot of the time is spent in the PC sending commands to the programmer and the AVR receiving the commands. e.g. if you reduce the ISP clock to much less than the F_CPU/4 you can have a long wait.

n.b. the obsolete AT90Sxxxx devices took substantially longer to do (1).

You have possibly noticed that some programming software is an awful lot slower than necessary.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
There are two factors.

1. how fast can you send the programming instructions.

I'm using a USBTinyISP, so I'd have to look at the documentation. Are most programmers able to vary their speed?

david.prentice wrote:
2. how long does the AVR take to actually program once it has received the instructions.

I'd probably have to look at a datasheet.

david.prentice wrote:
A lot of the time is spent in the PC sending commands to the programmer and the AVR receiving the commands. e.g. if you reduce the ISP clock to much less than the F_CPU/4 you can have a long wait.

You have possibly noticed that some programming software is an awful lot slower than necessary.

I've only used AVRDUDE, so I wouldn't have a point of reference in this regard. I think AVRDUDE has an option to set the programming speed, so I'll be looking into this. I definitely notice that some rather small programs can take far longer than 10s which is a real pain when debugging. I usually resort to tracing my code on paper as it's quicker than tweaking and reloading constantly.

Edit: from the usbtiny site:

Quote:
High speed! Max clock rate is 400KHz. Write speed:1Kb/s, read speed: 2Kb/s. (Atmega8 takes 8s to write, 4s to read/verify)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

StkMtd wrote:
at what speed is an AVR programmed? Is it dependent on clock fuses?
If you are referring to programming via SPI (which I suspect that you were), then it is limited to 1/4 of the clock speed as others have said. There are, however, other means by which a particular AVR might be programmed: JTAG, DebugWire, PDI, HVPP. I believe that all of these are self-clocking and thus may not even require a main clock.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes. I was referring to regular low voltage ISP.

But at the end of the day, you still have instruction transfer and the actual programming of a flash page.

The biggest holdup is the transfer of instructions. I believe the TinyUSB is a bit-bashed USB implementation. It works but will have a significant overhead.

Likewise the JTAG and debugWire may not use the highest instruction transfer speed, and they have to satisfy a higher level protocol too.

I have just timed reading and writing 128kB of garbage to a mega128 flash with a STK500 type of programmer.

18 secs read / 25 secs write @ 1.843MHz ISP
52 secs read / 59 secs write @ 115kHz ISP

So in real life the writing takes about 7 secs longer than the reading.

In contrast with a JTAGICE-1 clone the reading takes longer than the writing.

31 secs read / 26 sec write @ 1MHz JTAG and 115kHz RS232

I have not got an AVRISP-2. But I would expect the PC comms would be a little faster via the USB. The actual SPI commands that implement the ISP will be exactly the same as a STK500. i.e. 2.3 secs @ 1.8MHz and 36.4 secs @ 115kHz.

So a typical ISP session to write 128k of flash is:
15 secs for PC comms + programmer logic.
2.3 secs to send SPI commands @ 1.8MHz ISP
7 secs to actually program 1024 128byte flash pages.

A full 8k to a mega8 will be proportionately faster for the comms and SPI. The 256 32 byte flash pages may take about 1.8 secs to actually program.

David.

Last Edited: Sat. Mar 27, 2010 - 08:44 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The DIV8 fuse matters.
By default you can send ISP bits to many
AVRs at less that ((8/8)/4)Mbps=250 kbps.
Unprogramming the fuse allows 2 Mbps.

Iluvatar is the better part of Valar.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
I have just timed reading and writing 128kB of garbage to a mega128 flash with a STK500 type of programmer.

18 secs read / 25 secs write @ 1.843MHz ISP
52 secs read / 59 secs write @ 115kHz ISP


avreal with FT2232-based adapter (amontek jtag-key, olimex arm-usb-ocd, turteliser, etc. etc. etc)

FT2232 can generate SCK with frequency 6 MHz/N, for 7.3728MHz mega128L the highest possible is 1.5 MHz, so
<3.5 secs read / <6.5 secs write @ 1.5 MHz ISP
37 secs read / 40 secs write @ 113 kHz ISP
(write-read) about 3 seconds

david.prentice wrote:
7 secs to actually program 1024 128byte flash pages.
atmega128 has 512 128word pages - 512*twd_flash = 512*5msecs ~ 2.5secs

wbr, ReAl