Additional SRAM Issue

Hello,

I am having problems with SRAM_23LC library. I have a 23LCV1024 IC, everything is hooked up correctly. I am using a Adafruit Metro M0 Express(SAMD21). Heres a link to library: GitHub - mattairtech/SRAM_23LC: Driver for Microchip Technology Inc. 23LC (23LCV) SPI SRAM chips for AVR, SAM3X (Due), and SAM M0+ (SAMD, SAML, SAMC) microcontrollers on the Arduino platform.

Pin 13:SCK

Pin 12: SO

Pin 11: SI

Pin10: CS/SS

I sent a simple block of code, all I want to do is write a byte to a certain address and then read from the address to make sure I did it correctly. But every-time I write to it, it returns a 0.

I attached the code.Any help would be great.

#include <SPI.h>
#include <SRAM_23LC.h>

// SPI bus can be SPI, SPI1 (if present), etc.
#define SPI_PERIPHERAL    SPI
#define CHIP_SELECT_PIN   10



SRAM_23LC SRAM(&SPI_PERIPHERAL, CHIP_SELECT_PIN, SRAM_23LCV1024);



/
byte tbyte;
uint32_t address = 250;
uint8_t ubyte = 0x01;
void setup(void)
{

  SRAM.begin();
  

  Serial.begin(9600);
  delay(1000);

//write 1 to specified address,ubyte= 1
  size_t ret = SRAM.writeByte(address, ubyte);
 

}


void loop(void) {

//read address,should give a 1 if written to it correctly
  tbyte = SRAM.readByte(address);
  Serial.println("ubyte =");
  Serial.println(ubyte);
  Serial.println("tbyte =");
  Serial.println(tbyte);
  Serial.println("address =");
  Serial.println(address);


}

Can we see a schematic and photograph of your wiring please.

You’ve listed the default SPI connections for an Arduino AVR based atMega328 processor which is incorrect for the SAMD21 processor in a Metro board. If you’ve actually wired things that way, that’s your problem.

The SPI pins on the Metro M0 are only available on the 6 pin connector. You can continue to use digital pin 10 as the CS line but you need the SPI signals from the 2x3 pin connector to make your ram function.

Im a dingus lol....Works like a charm.TY!

The photo I linked to isn’t the actual board even though it’s what Adafruit posted for the M0. I got caught up in researching why it didn’t look right and I missed the fact that the 6 pin connector does indeed have +5 volts on the pin shown. You certainly don’t want to use that to power your ram!

I’m sure there is a reason that Adafruit provided 5 volts there rather than 3.3 but I have no idea why as it sure makes it more difficult to use hardware SPI.

Thank you for posting that you got it sorted.

Np, and yeah its my fault. Was to used to having those pins be used for SPI on almost every other board and figured I messed up code....And whats nice about the SAMD21 Metro M0 Epress, they didnt label the 2X3 header, so had to go through with the meter to find GND and 5V so I didnt fry the SRAM IC.