Emulate SPI EEPROM on a ATmega328

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

For debugging purposes, I need to emulate a SPI EEPROM, such as 25LC640A, using an ATmega328 (in avr-gcc or Arduino).

Do you know if this has already been done?

Best regards,
David

25LC640A
http://ww1.microchip.com/downloa...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is probably easier and quicker to just buy a 25LC640A.

You cannot get the AVR SPI to return data at anything like the 25LC640A speed. You also have to emulate the protection mechanisms etc.

Simply emulating 'perfect' behaviour is of course trivial. From a program's point of view, you would be reading or writing n bytes of data to/from a RAM address starting at location loc in the EEPROM. The mega328 could use an external I2C eeprom since it does not have 8k of eeprom or ram.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I only need to emulate read operations, at 400 kHz.
As it is read, I can put the 8kbytes in the ATmega328 in its 32 kbytes flash program memory.
I guess that is should not be too difficult to emulate that,
but one never know until he starts implementing it. :)
it's only better to reuse things, that's why i asked if this was already done.

Regards,
David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you want to read at 400kHz, the slave has 2.5us to load a return value. You can manage this either by the Slave polling or by interrupts.

Bear in mind that the Slave is going to manage some external memory of its own. So it must be able to respond fast enough as a 25LC640A while reading its own SPI or I2C memory.

I bought one from Farnell last week for £0.80. I am sure that I could emulate one with a non-AVR controller. I am also sure that it would take more than 10 minutes to write the emulation.

Oops. I have just re-read your last post. If the data is already in flash memory, then it is simple. Especially if you do not have to worry about busy-write write-protect etc.

David.