SPI flash works on T-3.2 but not T-LC

Status
Not open for further replies.

linuxgeek

Well-known member
I'm using an SPI flash module from onehorse, and it works on T3.2 (MK20DX256).

But the same chip does not work on a Teensy LC. It's on a breadboard, and swapping the T-3.2 on the breadboard with a T-LC, it won't work.

Just doing the simple EraseEverything and RawHardwareTest.

T3.2 output for EraseEverything:
Flash Memory has 67108864 bytes.
Erasing ALL Flash Memory:
estimated wait: 134 seconds.
Yes, full chip erase is SLOW!
............................................................
....................................................
Erase completed
actual wait: 114 seconds.

Teensy LC output:
Flash Memory has 1048576 bytes.
Erasing ALL Flash Memory:
estimated wait: 3 seconds.
Yes, full chip erase is SLOW!
.............



Code:
#include <SerialFlash.h>
#include <SPI.h>

//const int FlashChipSelect = 10;
const int FlashChipSelect = 6; // digital pin for flash chip CS pin
//const int FlashChipSelect = 21; // Arduino 101 built-in SPI Flash

SerialFlashFile file;

const unsigned long testIncrement = 4096;

void setup() {
  //uncomment these if using Teensy audio shield
  //SPI.setSCK(14);  // Audio shield has SCK on pin 14
  //SPI.setMOSI(7);  // Audio shield has MOSI on pin 7

  //uncomment these if you have other SPI chips connected
  //to keep them disabled while using only SerialFlash
  //pinMode(4, INPUT_PULLUP);
  //pinMode(10, INPUT_PULLUP);

  Serial.begin(9600);

  // wait up to 10 seconds for Arduino Serial Monitor
  unsigned long startMillis = millis();
  while (!Serial && (millis() - startMillis < 10000)) ;
  delay(100);

  SerialFlash.begin(FlashChipSelect);
  unsigned char id[5];
  SerialFlash.readID(id);
  unsigned long size = SerialFlash.capacity(id);

  if (size > 0) {
    Serial.print("Flash Memory has ");
    Serial.print(size);
    Serial.println(" bytes.");
    Serial.println("Erasing ALL Flash Memory:");
    // Estimate the (lengthy) wait time.
    Serial.print("  estimated wait: ");
    int seconds = (float)size / eraseBytesPerSecond(id) + 0.5;
    Serial.print(seconds);
    Serial.println(" seconds.");
    Serial.println("  Yes, full chip erase is SLOW!");
    SerialFlash.eraseAll();
    unsigned long dotMillis = millis();
    unsigned char dotcount = 0;
    while (SerialFlash.ready() == false) {
      if (millis() - dotMillis > 1000) {
        dotMillis = dotMillis + 1000;
        Serial.print(".");
        dotcount = dotcount + 1;
        if (dotcount >= 60) {
          Serial.println();
          dotcount = 0;
        }
      }
    }
    if (dotcount > 0) Serial.println();
    Serial.println("Erase completed");
    unsigned long elapsed = millis() - startMillis;
    Serial.print("  actual wait: ");
    Serial.print(elapsed / 1000ul);
    Serial.println(" seconds.");
  }
}

float eraseBytesPerSecond(const unsigned char *id) {
  if (id[0] == 0x20) return 152000.0; // Micron
  if (id[0] == 0x01) return 500000.0; // Spansion
  if (id[0] == 0xEF) return 419430.0; // Winbond
  if (id[0] == 0xC2) return 279620.0; // Macronix
  return 320000.0; // guess?
}


void loop() {

}

Is there any difference between T-3.2 and T-LC with SPI?
 
They should be the same. Internally, the SPI hardware is different, but the SPI library is supposed to give the same results. LC can't go as fast.

Can you post the results from RawHardwareTest? I have a board from OneHorse sitting here, still unused. Maybe it's time to wire it up and run some tests.....
 
Here's the T3.2 output of the 128Mbit module, which is probably more common. Before i was showing the 1Gbit module.

T3.2 EraseEverything
Flash Memory has 16777216 bytes.
Erasing ALL Flash Memory:
estimated wait: 34 seconds.
Yes, full chip erase is SLOW!
.............................................
Erase completed
actual wait: 49 seconds.

T3.2 RawHardwareTest
Raw SerialFlash Hardware Test

Read Chip Identification:
JEDEC ID: 1 20 18
Part Nummber: S25FL127S
Memory Size: 16777216 bytes
Block Size: 65536 bytes

Reading Chip...

Writing 8192 signatures

Double Checking All Signatures:
all 8192 signatures read ok

Checking Signature Pairs
all 4095 signature pairs read ok

Checking Read-While-Write (Program Suspend)
write 256 bytes at 256
write time was 501 microseconds.
read-while-writing: 00 00 00 00 15 F5 95 4B
test passed, good read while writing

Checking Read-While-Erase (Erase Suspend)
erase time was 179054 microseconds.
erase correctly erased 65536 bytes
read-while-erasing: 00 00 00 00 15 F5 95 4B
test passed, good read while erasing

All Tests Passed :)

Test data was written to your chip. You must run
EraseEverything before using this chip for files.

T-LC EraseEverything never completes.
Flash Memory has 1048576 bytes.
Erasing ALL Flash Memory:
estimated wait: 3 seconds.
Yes, full chip erase is SLOW!
..........


T-LC RawHardwareTest (never completes)
Raw SerialFlash Hardware Test

Read Chip Identification:
JEDEC ID: FF FF FF
Part Nummber: (unknown chip)
Memory Size: 1048576 bytes
Block Size: 65536 bytes

Reading Chip...

Writing 512 signatures

Would love to know what's going wrong so I can use the T-LCs I have to work with flash memory. I thought for sure I was doing something dumb, but I've done it so many times in different ways and T-LC never works, T-3.2 always works. I just happen to have been using a T3.2 to do my initial tests, cause I already had that on a breadboard, but was expecting to switch it out with a T-LC when I had it working. I have other T-LCs to try, but I don't have pins on them, so I could solder those up to try another T-LC. Thanks for any help you can provide.
 
Nevermind, it was my setup. It works!

I had a bad header pin on my LC. I'm sure I had some other problem early on, but at some point I mangled a header pin pulling it on and off the breadboard. Sorry to bother you. I knew it was much more likely that it was something I was doing wrong, just couldn't see it.
 
Status
Not open for further replies.
Back
Top