Currently coding for atmel tiny45 microcontroller and I use several lookup tables. Where is the best place to store them? Could you give me a general idea about the memory speed differences between sram-flash-eeprom?
Compared to either type of RAM, flash memory speed is significantly slower. Because of its reduced power consumption, persistent nature and lower cost, flash is used for storage memory, in devices such as SD cards, USB drives and SSDs.
SRAM (static random access memory) is where the sketch creates and manipulates variables when it runs. EEPROM is memory space that programmers can use to store long-term information.
Flash is block-wise erasable, while EEPROM is byte-wise erasable. Flash is constantly rewritten, while other EEPROMs are seldom rewritten. Flash is used when large amounts are needed, while EEPROM is used when only small amounts are needed.
The fastest through-hole EEPROM I can find is 70ns and 128K. At least from Mouser. 70ns seems to be it with EEPROMs. EPROMs are somewhat faster: 55ns for UV-erasable parts like those I used in my POC units, or 45ns for OTP parts, which I've also tried.
EEPROM is by far the slowest alternative, with write access times in the area of 10ms. Read access is about as fast as FLASH access, plus the overhead of address setup and triggering. Because there's no auto-increment in the EEPROM's address registers, every byte read will require at least four instructions.
SRAM access is the fastest possible (except for direct register access).
FLASH is a little slower than SRAM and needs indirect addressing in every case (Z-pointer), which may or may not be needed for SRAM access, depending on the structure and access pattern of your table.
For execution times of instructions see AVR Instruction Set, especially the LPM
vs. the LDS
, LD
, and LDD
instructions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With