Go Down

Topic: Due + 23lc1024 sram not working (Read 454 times) previous topic - next topic



I want to store some data to a 23lc1024 Sram but I am having trouble.

I have tried 4 or 5 different Sram Libraries and they all fail. The DUE hangs/stops at statup.

//************* code example *************

#include <SPI.h>
#include <SpiRam_Extended.h>

#define SS_PIN 10

SpiRAM SpiRam(SPI_CLOCK_DIV4, SS_PIN, CHIP_23LC1024);     //DUE hangs/stops here.

void setup()   {               

void loop()                   
  char data_to_chip[17] = "Testing 90123456";
  char data_from_chip[17] = "                ";
  int i = 0;

  // Write some data to RAM
  SpiRam.write_stream(SPI_CLOCK_DIV4, data_to_chip, 16);

  // Read it back to a different buffer
  SpiRam.read_stream(SPI_CLOCK_DIV4, data_from_chip, 16);

  // Write it to the serial port
  for (i = 0; i < 16; i++) {
  delay(1000);                  // wait for a second

//************* code example finish *************

I have tried changing the SPI clock divider to 21 84mhz/21 = 4mhz.
Tried changing CS pin to 4, 10, 52, 8.....
If I remove initCb(); from SPI.cpp / init() function the due will not hang but SPI Sram wont work (see below).

void SPIClass::init() {
   if (initialized)
   interruptMode = 0;
   interruptSave = 0;
   interruptMask[0] = 0;
   interruptMask[1] = 0;
   interruptMask[2] = 0;
   interruptMask[3] = 0;
   initCb();  // ****** comment out this line *******
   SPI_Configure(spi, id, SPI_MR_MSTR | SPI_MR_PS | SPI_MR_MODFDIS);
   initialized = true;

Does anyone have any suggestions?

Thanks for any help.



Hello altronandon,

Maybe there are several issues in your code or wiring, but :

1/ as per 23lc1024 datasheet, it should not work with SPI_CLOCK_DIV4.

2/ Parameters passed to SpiRam.read_stream and SpiRam.write_stream are not correct, first parameter should be the address, not clock speed you have previousely defined.

void SpiRAM::read_stream(int address, char *buffer, int length);
void SpiRAM::write_stream(int address, char *buffer, int length);

3/ Did you check your wiring with MISO, MOSI and SCK ?


Thanks for the reply.

I got it working by using the standard SPI library on its own. None of the SPI Sram libraries would work even though they use the standard SPI library as well.

The turboSPI DMA library works fine. Doing two int writes and two int reads takes about 15 micro secs (will try and get it faster). That's over clocking the comms speed at 40mhz.


Go Up