Pages: [1]   Go Down
Author Topic: PROGMEM access speed  (Read 874 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)

Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Great, thank you very much! smiley
Logged

Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19361
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

SE USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3783
@ssh0le
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

 smiley-razz
Logged


Global Moderator
Melbourne, Australia
Online Online
Brattain Member
*****
Karma: 511
Posts: 19361
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

True, like my font pixel data. Still, it shouldn't be a big issue.
Logged

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

Please post technical questions on the forum - not to me by personal message. Thanks a lot.

Pages: [1]   Go Up
Jump to: