Go Down

Topic: PROGMEM access speed (Read 911 times) previous topic - next topic

Krack123

Hello everybody,

I've been searching on the web for an hour or so and I couldn't find much information about PROGMEM access speed.

I'm currently writing the code for a POV globe (I have not yet received the components, but they are on their way!) and I realised that I'm running out of SRAM (only 2.5 Kb available).

I would like to use Flash memory to store my data, but my question is: will it be fast enough?

I would have to do at least 92 160 accesses per second, and 245 760 at the most.

If it is not fast enough, I can do two thirds of these accesses in SRAM and only the third in PROGMEM, but again, same question here...

Thanks for your help!

Osgeld

I dont have a hard number for you, but it does take extra steps to get data from PROGMEM so it will be a little slower than normal SRAM, but at that point your counting cpu cycles at 16Mhz (what is that like 64ns per cycle) ... using arduino your wasting 10x the cycles switching a pin over banging the registers, so  it may not be enough to effect your project
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Krack123

Thanks for your fast answer!

However, I'm unsure about the last part; are you saying that it will be alright or not?

(sorry for that, english is not my main language >.<)

Osgeld

I am saying the best way to find out is to check it yourself, but I think it would be fine, as your speed problems (if you have any)  is more likely to be getting the signals out to the LED's due to switching speed in the arduino libraries (thats the cost of being portable and easy to use across many chips)

http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Krack123

Great, thank you very much! :)

Nick Gammon

In this project I read font data from program memory when timing was very tight:

http://www.gammon.com.au/forum/?id=11608

I think you will find it takes 3 clock cycles to read from PROGMEM compare to two for RAM. So it is 62.5 nS slower (per byte).

Code: [Select]

245760 * 62.5e-9 * 2 = 0.03072 seconds
...
245760 * 62.5e-9 * 3 = 0.04608 seconds


So you would lose about 15 mS to read 245760 of them from PROGMEM rather than RAM.

Mind you, you don't have 245760 bytes of PROGMEM, nor RAM.

http://www.gammon.com.au/electronics

Osgeld

in fairness he didnt say bytes, but accesses ... it could be 4 bytes accessed 245760 times a second for all we know

:P
http://arduino.cc/forum/index.php?action=unread;boards=2,3,4,5,67,6,7,8,9,10,11,66,12,13,15,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,86,87,89,1;ALL

Nick Gammon

True, like my font pixel data. Still, it shouldn't be a big issue.
http://www.gammon.com.au/electronics

Go Up