AW: [En-Nut-Discussion] RAM vs. program memory speed

Ernst Stippl ernst at
Fri Nov 3 22:18:53 CET 2006


There are 2 instructions for reading "data" out of program flash memory: LPM
and ELPM. The Atmel Atmega128 manual (Rev. 2467L–AVR–05/04) states that each
of these 2 instructions uses 3 clock cycles to execute. You may want to
compare this to the instructions needed to access RAM ...

I do not believe the RAM access time is that significant (unless the memory
is very slow), it's simply the numbers of and clock cycles per  instruction
needed to access the data in ROM or FLASH.



-----Ursprüngliche Nachricht-----
Von: en-nut-discussion-bounces at
[mailto:en-nut-discussion-bounces at] Im Auftrag von José Vallet
Gesendet: Donnerstag, 02. November 2006 12:28
An: Ethernut mail list
Betreff: [En-Nut-Discussion] RAM vs. program memory speed

Hello all.

While reading the FAQ I have noticed that, in order to save RAM, it is 
possible to access string variables straight from ROM by defining the 
string literals as prog_char.

In my application I have quite some strings that are suitable for this 
change, but I am concerned about speed issues because my application 
uses those strings intensively.

So, my question is, is it faster/slower to access data straight from 
program memory than from RAM in Ethernut 2.1?

My thoughts:
In the AVR manual it says that for the internal RAM it takes 2 clk 
cycles to fetch the data. Considering the cpu freq=14.7456MHz, a single 
clock takes 67.81ns, and therefore internal RAM access takes 135.6ns.
I haven't found anything about the ROM timing access, but I would expect 
it to be fast because the program data is fetch in a single clk cycle.

Also the external memory speed has to be considered, which about the 
specs says that the "Read cycle time" is minimum 55ns. Therefore less 
than a clk cycle. However, external RAM access takes more cycles than 
internal, due to the address latch and so on.

 From this I might assume that ROM access is, in average, faster than 
RAM access (taking into account internal and external), unless I am 
missing  something (most likely).

Any comments, please? (appreciated)


En-Nut-Discussion mailing list
En-Nut-Discussion at

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.24/514 - Release Date: 02.11.2006

No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.13.21/509 - Release Date: 31.10.2006

More information about the En-Nut-Discussion mailing list