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

Thread: Startup/hard reset problem.

  1. #1

    Startup/hard reset problem.

    I've got a little board I designed that has these things on it:
    - Teensy 3.2
    - SGTL5000
    - S25FL256S flash eeprom (link to Digikey page)
    - BNO055 position sensor board

    These are used to play back some sounds (in 8 channels, WOW!) that are stored on the flash. It works great! The hardware, the software etc all work.

    Except... there is a catch. It will only work with a reset of the Teensy ARM chip, either by the USB port after upload, or thorugh the little Reset pad on the bottom side of the board.

    I'm pretty sure that this has to do with the different startup times for the first three chips above. Once they are all powered up, a hard reset on the teensy always starts the other two properly. Since the guitar synth example code fromt he audio library works perfectly without any problems, I am guessing that it's the interaction between the S25FL256S flash eeprom, SerialFlash.h and the Teensy that is going wrong.

    On the other hand, with hard reset I get a click in the headphoens after sgtl50000_enable(), and when it fails I don't hear a click. So it could be to do with the sgtl5000 as well.

    I've added delays galore to the setup() function but am not getting anywhere... any ideas? Help is appreciated! Setup code is below.

    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SerialFlash.h>
    #include <Adafruit_Sensor.h>
    #include <Adafruit_BNO055.h>
    #include <utility/imumaths.h>
    // GUItool: begin automatically generated code
    AudioPlaySerialflashRaw  playFlashRaw6;  //xy=132,327
    AudioPlaySerialflashRaw  playFlashRaw1;  //xy=135,82
    AudioPlaySerialflashRaw  playFlashRaw3;  //xy=135,179
    AudioPlaySerialflashRaw  playFlashRaw5;  //xy=135,277
    AudioPlaySerialflashRaw  playFlashRaw7;  //xy=135,376
    AudioPlaySerialflashRaw  playFlashRaw4;  //xy=136,227
    AudioPlaySerialflashRaw  playFlashRaw2;  //xy=137,127
    AudioPlaySerialflashRaw  playFlashRaw8;  //xy=139,421
    AudioMixer4              mixer3;         //xy=356,330
    AudioMixer4              mixer2;         //xy=368,155
    AudioMixer4              mixer1;         //xy=484,242
    AudioOutputI2S           i2s1;           //xy=679,244
    AudioConnection          patchCord1(playFlashRaw6, 0, mixer3, 1);
    AudioConnection          patchCord2(playFlashRaw1, 0, mixer2, 0);
    AudioConnection          patchCord3(playFlashRaw3, 0, mixer2, 2);
    AudioConnection          patchCord4(playFlashRaw5, 0, mixer3, 0);
    AudioConnection          patchCord5(playFlashRaw7, 0, mixer3, 2);
    AudioConnection          patchCord6(playFlashRaw4, 0, mixer2, 3);
    AudioConnection          patchCord7(playFlashRaw2, 0, mixer2, 1);
    AudioConnection          patchCord8(playFlashRaw8, 0, mixer3, 3);
    AudioConnection          patchCord9(mixer3, 0, mixer1, 3);
    AudioConnection          patchCord10(mixer2, 0, mixer1, 0);
    AudioConnection          patchCord11(mixer1, 0, i2s1, 0);
    AudioConnection          patchCord12(mixer1, 0, i2s1, 1);
    AudioControlSGTL5000     sgtl5000_1;     
    // GUItool: end automatically generated code
    /* BNO055 setup */
    #define BNO055_SAMPLERATE_DELAY_MS (100)
    Adafruit_BNO055 bno = Adafruit_BNO055();
    #define movementThreshold 0.01
    #define FLASH_CHIP_SELECT  6
    #define SDCARD_CS_PIN    10
    #define SDCARD_MOSI_PIN  7
    #define SDCARD_SCK_PIN   14
    void setup(){ 
      SPI.setSCK(14);  // Audio shield has SCK on pin 14
      SPI.setMOSI(7);  // Audio shield has MOSI on pin 7
      Serial.println("mosi pins set");   
      Serial.println("setting audio memory");
      Serial.println("sgtl volume set");   
      delay(1000); //necessary wait for serial port to open
      /* Initialise the sensor */
                        {    /* There was a problem detecting the BNO055 ... check your connections */
                          Serial.print("Ooops, no BNO055 detected ... Check your wiring or I2C ADDR!");
     if (!SerialFlash.begin(FLASH_CHIP_SELECT)) {
        while (1) {
       Serial.println ("Cannot access SPI Flash chip");
      }    else {
       Serial.println ("OK access to SPI Flash chip");
    Serial.println("finished setup");   
    Last edited by Daniel-J; 10-29-2017 at 05:08 AM. Reason: add Digikey link for eeprom

  2. #2
    Here's the board I am using. It has a charger and step up converter for an 18650 cell, which all works great. The big black block in the middle is the BNO055 position sensor, raised above the board, and the smaller block is a split +9/-9 supply for some very old school high impedance headphones I am using. The eeprom is just scabbed onto the bottom of the board at the moment. In any case, the hardware all works great, with the exception of the startup sequence as described above.

    Click image for larger version. 

Name:	non_name.jpg 
Views:	157 
Size:	84.6 KB 
ID:	11915
    Last edited by Daniel-J; 10-29-2017 at 06:36 AM. Reason: typos

  3. #3
    Senior Member
    Join Date
    Apr 2014
    Maybe it's a power problem when starting (too slow raising voltage)? I'd add a small capacitor between the reset-pad and GND. I'd try 0.1uF or less first. This delays the reset a little.

  4. #4
    Thanks for that idea Frank. I thought that was a good idea as well so I gave it a shot with .01, .1 and .22uf, but it did not do anything other than entirely preventing startup in one or two of the combinations.

    I also put a 560K resistor to ground from the reset pin and measured the voltage drop on it, to derive the value of the internal pullup resistor. It's about 18k, so even with .01uf, we're only talking a couple milliseconds delay.

    Any ideas of where I could implement a 250ms software delay during the Teensy startup, prior to it configuring the eeprom?


  5. #5

    Adding a 50uS delay to the readID() function inside of SerialFlashChip.cpp did the trick. Code below.
    I'm guessing that the fairly large and slow(er) eeprom needed a bit of time to catch up to the Teensy.
    Of course, I do not really know what I am doing here, i was just following a breadcrumb trail of code with a blindfold on, inserting delays and Serial.println statements to figure out where the code was not doing what was wanted with the hardware.


    void SerialFlashChip::readID(uint8_t *buf)
    	if (busy) wait();
    	delayMicroseconds(50);   //added this to make it work every time on startup
    	buf[0] = SPIPORT.transfer(0); // manufacturer ID
    	buf[1] = SPIPORT.transfer(0); // memory type
    	buf[2] = SPIPORT.transfer(0); // capacity
    	if (buf[0] == ID0_SPANSION) {
    		buf[3] = SPIPORT.transfer(0); // ID-CFI
    		buf[4] = SPIPORT.transfer(0); // sector size
    	Serial.printf("The ID: %02X %02X %02X\n", buf[0], buf[1], buf[2]);

Posting Permissions

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