Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: hang when trying to play raw files from SPIflash

  1. #1

    hang when trying to play raw files from SPIflash

    hello folks:

    I'm wondering if anyone has insight into the problem ia having trying to play raw files from spi flash.

    I'm using my own board with an SGTL5000 that a Teensy 3.2 plugs into. So far it has worked perfectly to stream WAV files from SD out through the SGTL5000. I've also done wavetable synthesis, so I am thinking that hardware is OK.

    Yesterday I added a Spansion S70FL256P0XMFI001 SPI flash. Erase, listfiles and copy from SD to flash all work as expected. It's screaming fast.. 1.2MB per second!

    I'm now trying to get the play raw files working form SPI flash, but I am unsuccessful.
    Audio files have been exported as signed, little endian, 44.1K 16 bit pcm RAW, and then exported to the newly erased SPI flash from an SD card.
    When i run the code below, it always hangs when it gets to the line playFlashRaw1.play(filename).
    Code is below. Thanks for any ideas you might have.

    Daniel
    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    
    // GUItool: begin automatically generated code
    AudioPlaySerialflashRaw  playFlashRaw1;  //xy=201.80308532714844,253.8939208984375
    AudioOutputI2S           i2s1;           //xy=702.871337890625,260.2803039550781
    AudioConnection          patchCord1(playFlashRaw1, 0, i2s1, 0);
    AudioConnection          patchCord2(playFlashRaw1, 0, i2s1, 1);
    AudioControlSGTL5000     sgtl5000_1;     //xy=742.1666717529297,337.1666717529297
    
    // GUItool: end automatically generated code
    #define FLASH_CHIP_SELECT  6
    
    void setup() {
      // put your setup code here, to run once:
      sgtl5000_1.enable();
      sgtl5000_1.volume(.7);
      
    Serial.begin(115200);
    delay(1000);
    
      // Start SerialFlash
      if (!SerialFlash.begin(FLASH_CHIP_SELECT)) {
        while (1) {
          Serial.println ("Cannot access SPI Flash chip");
          delay (1000);
        } }
        else {
          Serial.println ("OK access to SPI Flash chip");
        }
      
    
    
    AudioMemory(20);
    
    Serial.println ("exiting setup");
    
    }
    
    
    void playFile(const char *filename)
    {
      Serial.print("Playing file: ");
      Serial.println(filename);
    
      // Start playing the file.  This sketch continues to
      // run while the file plays.
        Serial.print("just before the playflashraw command");
    
      playFlashRaw1.play(filename);
      Serial.print("after the playflashraw command");
    
      // A brief delay for the library read WAV info
      delay(10);
    
      // Simply wait for the file to finish playing.
    
    while (playFlashRaw1.isPlaying()) {
      Serial.print("inside the while playing loop");
      delay(100);
        // uncomment these lines if you audio shield
        // has the optional volume pot soldered
        //float vol = analogRead(15);
        //vol = vol / 1024;
        // sgtl5000_1.volume(vol);
      }
    }
    
    void loop() {
    Serial.println ("entered main loop");
    // put your main code here, to run repeatedly:
    playFile("21.RAW");
    playFile("30.RAW");
    playFile("41.RAW");
    playFile("51.RAW");
    playFile("60.RAW");
    }

  2. #2
    One thing I have discovered so far is that the S70FL256P0XMFI001 is a dual die flash chip ( 2 x 128Mbit dies in one package) Therefore it has two chip selects, and each die has to be configured, erased, written and formatted separately. I had the two chip selects tied together. Now I have CS2 tied high, but it's still not working. Getting closer though!

    D

    PS it would be good to add the dual die note to the tests file in the Serialflash repository.

  3. #3
    Solved. And it only took me 10 or 15 hours to realize that these two lines were missing:

    SPI.setSCK(14); // Audio shield has SCK on pin 14
    SPI.setMOSI(7); // Audio shield has MOSI on pin 7

    The example code ran perfectly because, well, it has those lines.

    D

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •