Teensy Prop Shield SerialFlash Issues

Status
Not open for further replies.
Hey everyone,

This is my first post here so if it's in the wrong place or more info is needed please let me know. I bought the Teensy Prop Shield along with the Teensy 4.1. I've run into an issue with accessing the SPI Flash Chip on the Prop Shield. None of the example sketches from the SerialFlash library seem to work. CS for the chip is on pin 6. MISO,MOSI, and SCK are connected (I managed to run a strip of DotStar LED's from the Prop Shield with no issues so the connections are fine there). I soldered the headers on it myself, I quadruple checked to make sure there were no cold solder joints on those pins. Is there something I'm missing? Did I somehow get a bum chip? User error is still a possibility but I've checked everything I can think of. Any help would be greatly appreciated!!!!
 
Just to elaborate a little more I have everything connected via jumpers at the moment because I'm a dunce and soldered breadboard pins to both the Teensy and the prop shield. I've swapped cables just to make sure they're not the problem. I'm using the SerialFlash library's example code. Here's the Erase Everything code I'm using. Serial monitor is outputting "Unable to access SPI Flash chip".

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

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);

  if (!SerialFlash.begin(FlashChipSelect)) {
    while (1) {
      Serial.println("Unable to access SPI Flash chip");
      delay(1000);
    }
  }
  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() {

}
 
Always a pain to plan soldering in advance for pin or socket and top or bottom - and picking the wrong combo leaves a hassle to deal with :(

If properly wired - and the jumpers are well connected - the jumper type and length may be affecting the connection?

Make sure the jumpers ( some chinese rubber molded are weak/fail ) actually are making a connection board to board, and even if real wires length should be short towards 3 inches or less as possible.
 
You were right, length on the jumpers was the issue. I soldered some female headers to the top of the teensy, plugged in the shield and ran erase everything again and it ran. Thanks for the help!
 
Status
Not open for further replies.
Back
Top