12

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?

kostaspap
  • 345
  • 4
  • 10

1 Answers1

11

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.

JimmyB
  • 12,101
  • 2
  • 28
  • 44
  • @MarekK You're absolutely right. IIRC, the actual EEPROM read operation only has a penalty of about 2 clock cycles. - However, the need to first write the address to access to EEARx and then triggering the read via EECR requires three extra instructions for every byte read. – JimmyB Jan 12 '15 at 10:04
  • It is not so bad in many cases. I wish they will implement FRAM or MRAM in the microprocessors, it would deliver absolutely new approach and efficiency. – MrHIDEn Jan 13 '15 at 13:34