Problems with SPI when going from Arduino to Teensy 3.2

Saaif88

Member
Hey everyone,

I'm working on a project that uses an Everspin MR25H256 SPI MRAM Chip. This is similar to FRAM and SRAM, it just has increased durability. I was previously using this chip with an Arduino Micro, and everything was working just fine. I decided to upgrade my design to a Teensy 3.2, but I just can't get it to work for some reason.

Previously, I had needed to use a Logic Level Translator (TXB0104D) in order to use this chip with the Arduino Micro, since the chip is 3.3V only. In my new design, since the Teensy 3.2 is 3.3V anyways, I omitted this chip and wired the MRAM straight into the Teensy.

The thing is, the Teensy 3.2 works just fine if I use the old circuit board with the Logic Level Translator, but doesn't work when wired directly for some reason. In order to use the Teensy with the old circuit board, I just declared the SPI pins in relation to the Arduino Micro. So the declaration for the old board is:

CS = 14
SCK = 12
MISO = 11
MOSI = 13

This allows me to literally plug the Teensy 3.2 into the socket for the Arduino Micro and with the addition of 5V, 3.3V and GND, it works totally fine. Yet, if I wire this exact same chip straight into the Teensy 3.2 using the hardware SPI Pins, it doesn't work for some reason. I'm truly at a loss of why this is...

I've attached pictures of my old schematic, new schematic, and the PCB layout. I have GND on a fill, so that's why they are not connected. I'm probably missing something obvious here, but if anyone can help me, I would really appreciate it!

New Schematic.jpgOld Schematic.jpgPCB Layout.jpg
 
Sorry guys, I guess my original post was a bit confusing. I designated those pins because those are the corresponding pins on the Teensy 3.2 to the hardware SPI pins on the Arduino Micro. I've attached a picture to make it a bit more clear. I'm not using "Real" SPI on the Teensy by doing it this way, but like I said, with this assignment, I can simply plug the Teensy 3.2 into the old boards designed for the Arduino Micro, and it works just fine. I hope this makes sense. Teens 3.2 and Arduino Micro SPI Pins.jpg
 
Unfortunately, I think I've found the problem, but I'm not entirely sure what the easiest solution is...

I'm an EE, so I should know better, but I didn't check what the current outputs on the Teensy 3.2 was, and I think this is my problem. The Arduino Micro, which is the classic 32U4, states an Absolute Max of 40mA, and is generally rated for 20mA. The Teensy 3.2 on the other hand, which is the MK20DX256VLH7 has an absolute max of 25mA, and is rated for only 10mA.

The Everspin MR25H256 has a read current max of 10mA, and a write current max of 27mA. The thing is, this is the rated current at 40Mhz, and I am only trying to run this chip at 1Mhz, which lists the maximum read current at 3mA and the maximum write current at 13mA. This seems to be within the bounds of this chip, and yet, I can't seem to get it work. Is there a way to slow the SPI speed on the Teensy down even further? I'm using the Adafruit FRAM SPI Library, which has a fixed freq of 1Mhz, but if this doesn't work with the Teensy for some reason, then I'm not sure what the solution is.

Any help would be greatly appreciated guys, thanks!

View attachment MR25H256 Read Write Current.pdf
 
I think the Everspin read/write currents refer to the power drawn by the MRAM chip on the PCB Vin and not to the current on the SPI pins.

Do you have another SPI device to confirm SPI on Teensy 3.2 is working?

Or you could run this simple SPI sketch, jumper pin 12 to pin 11 to get 0 errors.
Code:
#include <SPI.h>
#define PRREG(x) Serial.print(#x" 0x"); Serial.println(x,HEX)

#define CS 10
#define SPICLOCK 1000000
#define SPI_BUFF_SIZE 1024
uint8_t rx_buffer[SPI_BUFF_SIZE];
uint8_t tx_buffer[SPI_BUFF_SIZE];

void setup() {
  Serial.begin(9600); while (!Serial);
  Serial.printf("SPICLOCK %d\n",SPICLOCK);
  pinMode(CS, OUTPUT);
  digitalWrite(CS, HIGH);

  SPI.begin();
  SPI.beginTransaction(SPISettings(SPICLOCK, MSBFIRST, SPI_MODE0));
}

void loop() {
  uint32_t t1;
  float mbs;

  for (int i = 0; i < SPI_BUFF_SIZE; i++) tx_buffer[i] = i;
  digitalWrite(CS, LOW);
  t1 = micros();
  SPI.transfer(tx_buffer, SPI_BUFF_SIZE);
  t1 = micros() - t1;
  digitalWrite(CS, HIGH);
  mbs = 8 * SPI_BUFF_SIZE / (float)t1;
  Serial.printf("Tx %d bytes in %d us  %.2f mbs \n", SPI_BUFF_SIZE, t1, mbs);

  // jumper MOSI to MISO
  for (int i = 0; i < SPI_BUFF_SIZE; i++) tx_buffer[i] = i;
  memset(rx_buffer, 0, SPI_BUFF_SIZE);
  digitalWrite(CS, LOW);
  SPI.transfer(tx_buffer, rx_buffer, SPI_BUFF_SIZE);
  digitalWrite(CS, HIGH);
  int errs = 0;
  for (int i = 0; i < SPI_BUFF_SIZE; i++) if (tx_buffer[i] != rx_buffer[i]) errs++;
  Serial.printf("errs %d  [3] %d %d \n", errs, tx_buffer[3], rx_buffer[3]);
  delay(3000);
}
 
Back
Top