C library for using a SRAM Microchip 23LC512-I/SN connected to an ATmega328P

The SRAM Microchip 23LC512-I/SN is a very nice chip that can serve as external RAM (64KB) for the ATmega328P.  This simple C library deals with block writings and readings to that chip from the MCU, in a most efficient way (it can use assembler code internally, and some hard real-time techniques for reducing the execution time, if the user wishes to).

It has been tested with the scripts for bare programming the ATmega328P of an Arduino UNO, i.e., with the compiler that comes with the Arduino IDE.

Features:

  • It uses the SPI module of the ATmega328P, and therefore its associated MISO/MOSI/SCK pins, for communications.
  • It always uses pin 2 of PORTB as output because otherwise the SPI module of the ATmega328P does not work properly. Nevertheless, the chip select for the SRAM can be B2 or D3.
  • Including the call to the writing routine and without interrupts enabled, the transfer speed is around 5 microsecs per byte of the transmitted block (200KHz).
  • Including the call to the reading routine and without interrupts enabled, the transfer speed is around 5.3 microsecs per byte of the transmitted block (190KHz).

Installation and usage:

  • Download the library.
  • Just read the .h.