Problems reading Device ID on SPI (FRAM)

I am using an ARDUINO MEGA2560
Here is the datasheet of my device, the MB85RS16N

Trying to read device’s manufacturer ID. Can’t seem to get any real information. I’m aware that once you use the RDID command, that 32 bits (for this specific device) are sent to the MISO pin on the SPI device and able to be obtained by SPI.transfer and any dummy values can be sent for this.

Here is what I’ve done

  • Ensured that the Pins are correctly going into the correct GPIO slots, which on the MEGA2560 for SPI are 50, 51, 52, and 53.
  • Checked all the physical connections and ensured with multi-meter that they work and don’t interfere
  • Checked for physical damage to SPI device.
  • Checked orientation to ensure I didn’t mix up sides.
  • Because I bought 5 of these, I re-soldered a new one and tried to use that in case the first SPI device was broken.
    also performed previous step on the new one to ensure all connections were fine.

I’m brand new at this, but am wondering if it has something to do with the Clock not properly syncing? I know that the datasheet says that the device runs at 20Mhz but the ARDUINO MEGA2560 runs at 16MHz. I also do not have on the SPI device pins 3 (WP) and 7 (HOLD) connected to anything, since I believe I do not need them for this test.

Let me know if you need more information or pictures. I hope this is a Coding error.

#include <SPI.h>

// FRAM: MB85RS16N
// SPI
// 16Kilobits memory a.k.a. 2 KiloBytes

//**FRAM IC Pinout**
// 1: CS - Chip select pin
// 2: MISO - Serial data output pin (Master input, Slave output) [This reads data]
// 3: WP - Write protect pin
// 4: GND - Ground pin
// 5: MOSI - Serial data input pin  (Master output, Slave input) [This writes data]
// 6: SCK - Serial clock pin
// 7: HOLD - Hold pin
// 8: VDD - Supply voltage pin

//**FRAM IC SPI Commands** Uses binary to communicate with the chip
//  OP codes
#define WREN B00000110  //WREN command. Write enable latch (WEL), which must be set before you can write
#define WRDI B00000100  //WRDI command. Resets WEL so you can no longer write.
#define
 RDSR B00000101  //RDSR command. Reads status register data. SPDR holds 
byte about to be shifted out of MOSI line and data shifted in the MISO 
line
#define WRSR B00000001  //WRSR command. Writes data to nonvolatile memory bit of status register
#define READ B00000011  //READ command. Reads FRAM memory cell aray data.
#define WRITE B00000010  //WRITE command. Writes data to FRAM memory cell array.
#define RDID B10011111  //RDID command. Reads fixed device ID.

// Pinouts
#define MISO 50        // Yellow jumper MISO
#define MOSI 51       // Blue jumper   MOSI
#define SCK 52   // Green jumper  SCK
#define SS 53         // White jumper  CS

void setup() {
Serial.begin(9600);
pinMode(MISO, INPUT);           // Incoming data from the FRAM
pinMode(MOSI, OUTPUT);          // Outgoing data to the FRAM
pinMode(SCK,OUTPUT);            // sets serial clock to output
pinMode(SS, OUTPUT);            // sets slaveselect to output
digitalWrite(SS, HIGH);         // ensure SS stays high

// Set up to match device datasheet
SPISettings FRAM(20000000, MSBFIRST, SPI_MODE0);
SPI.begin(); // Initializes the SPI bus by setting SCK, MOSI, and CS(SS) to outputs, 
             // pulling SCK and MOSI low, and CS(SS) high.

// Write get device ID
SPI.beginTransaction(FRAM);
digitalWrite(SS, LOW);
SPI.transfer(RDID);                       // Sends OP code to FRAM chip
Serial.print ("Manufacturer: ");
Serial.println(SPI.transfer(0x00),HEX);   // prints manufacturer ID
Serial.print ("Continuation code: ");
Serial.println(SPI.transfer(0x00),HEX);   // prints Continuation code
Serial.print ("Product ID 1: ");
Serial.println(SPI.transfer(0x00),HEX);   // prints Product ID 1
Serial.print ("Product ID 2: ");
Serial.println(SPI.transfer(0x00),HEX);   // prints Product ID 2
digitalWrite(SS, HIGH);
SPI.endTransaction();
}

void loop() {
while(1);
}

Here is my output

Manufacturer: 0
Continuation code: 0
Product ID 1: 0
Product ID 2: 0

Ensured that the Pins are correctly going into the correct GPIO slots, which on the MEGA2560 for SPI are 50, 51, 52, and 53.

I doubt that. At least until you show us a correct wiring diagram. If you connect the SPI pins directly you made the first mistake. The MB85RS16N is a 3.3V device while the Mega2560 is a 5V device. You must not connect the SPI pins directly but by a level converter, use one that is SPI compatible (most are not). According to the datasheet the device is not very tolerant and may already got damaged by the too high voltage.

pylon:
I doubt that. At least until you show us a correct wiring diagram. If you connect the SPI pins directly you made the first mistake. The MB85RS16N is a 3.3V device while the Mega2560 is a 5V device. You must not connect the SPI pins directly but by a level converter, use one that is SPI compatible (most are not). According to the datasheet the device is not very tolerant and may already got damaged by the too high voltage.

I'm confused because I am using the 3.3V GPIO to power the SPI device?
attached is a picture of the wiring set up.

I'm confused because I am using the 3.3V GPIO to power the SPI device?

Sure, but the signal pins (SCKL, MOSI) also have a voltage. If you power the chip by 3.3V, the absolute maximum allowed voltage on the SPI pins (according to the datasheet) is 3.8V (Vcc + 0.5V), the device expects the SPI voltages to be equal to Vcc under normal circumstances.

Do you have to use this combination? You could go for a 3.3V Arduino or look at alternative memory chips that work at 5V e.g.

https://www.microchip.com/design-centers/memory/serial-sram-serial-nvsram

https://store.arduino.cc/arduino-due

I got a Bi-directional logic level converter (Link) and

  • attached it to my circuit.
  • using 5V GPIO from arduino to power the Bi-directional logic level converter
  • bought a new FRAM device and resoldered it to a SOP8

my outputs are somewhat random. I am mostly getting

Manufacturer: FF
Continuation code: FF
Product ID 1: FF
Product ID 2: FF

or

Manufacturer: 0
Continuation code: 0
Product ID 1: 0
Product ID 2: 0

or even

Manufacturer: FF
Continuation code: 0
Product ID 1: 80
Product ID 2: 80

I'm at a total loss as to why the outputs are intermittent.

also sometimes gives

Manufacturer: 80
Continuation code: 80
Product ID 1: 80
Product ID 2: 80

Earlier when I was using an older FRAM (that I assumed possibly became fried when I gave it 5V) I was getting values of 7 and what not, but not where they should have been.
I don't have to shift any values if the device reads MSB first, right?

That output looks like a floating pin. Post a complete wiring diagram! Did you buy a new FRAM chip? The old may be fried from your earlier try.