I am using several 23LC1024 SRAM chips to share data between an Arduino and a Raspberry PI 3 running Windows 10 IOT. I am using SPI to send and read data from the 23LC1024. I am having trouble getting the data to write and read back correctly. I am using a Logic Analyzer to check my commands at formatted correctly. I am using the SPI0 from the PI. I am using this 23LC1024 Data sheet (http://ww1.microchip.com/downloads/en/DeviceDoc/20005142C.pdf) and Application notes for 23LC1024 (http://ww1.microchip.com/downloads/en/AppNotes/01484A.pdf). I am using figure 1 as an example for my schematic, with 4.7kOhm resistors, and 100nF Capacitor. I have the chip set to read/write 32 bit pages.
Here is a capture of my write command to address 0 and 0xAA as my data. []
Here is a capture of my read command to address 0. []
The return data is all 0's.
I am using SPI Mode 0 (CPOL = 0, CPHA = 0), with a clock speed of 100000. Here is how I define my constants used by the PI.
static class SRAMConsts
{
//SRAM Instruction
public const Byte RDMR = 0x5;
public const Byte WRMR = 0x1;
public const Byte WRITE = 0x2;
public const Byte READ = 0x3;
//SRAM Modes
public const Byte BYTE_MODE = 0x00;
public const Byte PAGE_MODE = 0x80;
public const Byte SEQUENTIAL_MODE = 0x40;
//SRAM Page size
public const Byte PAGE_SIZE = 0x20;
//SRAM Max Speed
public const int Spi_Max_Speed = 0x1312d00; // 20MHz
//SRAM Spi Mode
public const SpiMode Mode0 = SpiMode.Mode0;
}
Here is my code to read and write a page to the SRAM.
public void readPage(UInt32 address, ref byte[] data)
{
byte[] cmd = new byte[4];
byte[] result = new byte[32];
cmd[0] = SRAMConsts.READ;
cmd[1] = (byte)(address >> 16);
cmd[2] = (byte)(address >> 8);
cmd[3] = (byte)(address);
GPIO_CS.Write(GpioPinValue.High);
_23LC1024_Sram.Write(cmd);
_23LC1024_Sram.Read(result);
GPIO_CS.Write(GpioPinValue.Low);
data = result;
}
public void writePage(UInt32 address, ref byte[] data)
{
byte[] cmd = new byte[4];
cmd[0] = SRAMConsts.WRITE;
cmd[1] = (byte)(address >> 16);
cmd[2] = (byte)(address >> 8);
cmd[3] = (byte)(address);
GPIO_CS.Write(GpioPinValue.High);
_23LC1024_Sram.Write(cmd);
_23LC1024_Sram.Write(data);
GPIO_CS.Write(GpioPinValue.Low);
}
I am able to successfully read and write to the chips from an Arduino, but still can not get the PI to read and write correctly. I am hoping this setup will allow the PI to share a common address space with the Arduino so that the Arduino can be used to produce data.
Any ideas as to why my PI is not communication properly with the SRAM chip.