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

Thread: Teensy 3.2 PropShield no Audio

  1. #1
    Junior Member
    Join Date
    May 2019
    Location
    Frankfurt,Germany
    Posts
    7

    Teensy 3.2 PropShield no Audio

    Hello ....

    Iam Newbie in Teensy Audio and I just want to test
    the Hardware i have a teensy 3.2 with a PJIRC PropShield (DAC1 Output)


    but nothing happens

    Can you check if code is correct

    Click image for larger version. 

Name:	teensytransfer.PNG 
Views:	68 
Size:	53.0 KB 
ID:	23643

    thanks a lot


    Code:
    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    
    // GUItool: begin automatically generated code
    AudioPlaySerialflashRaw  playFlashRaw1;  //xy=845.3333129882812,330.33331298828125
    AudioOutputAnalog        dac1;           //xy=1028.3333282470703,328.3333282470703
    AudioConnection          patchCord1(playFlashRaw1, dac1);
    // GUItool: end automatically generated code
    
    
    void setup() {
      Serial.begin(9600);
      AudioMemory(20);
      dac1.analogReference(EXTERNAL); // much louder!
      delay(50);             // time for DAC voltage stable
      pinMode(5, OUTPUT);
      digitalWrite(5, HIGH); // turn on the amplifier
      delay(10);             // allow time to wake up
    }
    
    void loop() {
    //Serial.println("BIG");
    //playFlashRaw1.play("BIG.RAW");
    //delay(2000);
    //Serial.println("INTEL");
    //playFlashRaw1.play("INTEL.RAW");
    //delay(2000);
    Serial.println("SOX");
    playFlashRaw1.play("SOX.RAW");
    delay(2000);
    }
    Last edited by molleonair; 02-08-2021 at 04:47 PM.

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,935
    Does this hardware work if you do a basic sinewave out the dac1? and since you can connect multiple outputs to a single source if you have a spare PWM capable pin you can try adding one there and connecting a resistor+LED to it and look for brightness changes as audio plays?

    You can also run the DAC test at https://www.pjrc.com/teensy/teensy31.html (remember to add the write to pin 5 to enable the speaker).

    The DAC driver is fragile so if it has become shorted at anypoint the hardware may be dead.

  3. #3
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    1,028
    Probably superfluous, but did you solder those 5 pins in the red circle as well?

    Click image for larger version. 

Name:	propshield_headers.jpg 
Views:	50 
Size:	36.0 KB 
ID:	23654

    Paul

  4. #4
    Junior Member
    Join Date
    May 2019
    Location
    Frankfurt,Germany
    Posts
    7
    Quote Originally Posted by PaulS View Post
    Probably superfluous, but did you solder those 5 pins in the red circle as well?

    Click image for larger version. 

Name:	propshield_headers.jpg 
Views:	50 
Size:	36.0 KB 
ID:	23654

    Paul
    yes i did and the sine-wave works

  5. #5
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    1,028
    Quote Originally Posted by molleonair View Post
    the sine-wave works
    Good, so the hardware seems to be OK then.
    So the issue is playing the .raw file, either the file itsself or the audio library.
    Did you try the WaveFilePlayer example using an ordinary 44.1kHz/16bit .wav file?

    Paul

  6. #6
    Junior Member
    Join Date
    May 2019
    Location
    Frankfurt,Germany
    Posts
    7
    Hi Paul thnx for Help

    i found the Problem

    i add
    SerialFlash.begin (6);
    to setup and it works

    it was realy difficult to find this in the Web
    Maybe someone should add an Example in Arduino Teensy Audio Folder

    but now i have to add Fastled to this Teensy and i dont understand when i have to deselect the SerialFlash CS Line (Pin6)
    and Select the PIN7 to enable Fastled Data on Prop Shield cause they connected to the same SPI Signals

    i want play a sound file and update LED Matrix while playing this file

    may you have a tip for me

  7. #7
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,383
    Quote Originally Posted by molleonair View Post
    Hi Paul thnx for Help

    i found the Problem

    i add
    SerialFlash.begin (6);
    to setup and it works

    it was realy difficult to find this in the Web
    Maybe someone should add an Example in Arduino Teensy Audio Folder

    but now i have to add Fastled to this Teensy and i dont understand when i have to deselect the SerialFlash CS Line (Pin6)
    and Select the PIN7 to enable Fastled Data on Prop Shield cause they connected to the same SPI Signals

    i want play a sound file and update LED Matrix while playing this file

    may you have a tip for me
    I ran into problems switching back and forth between using the SPI device (in my case it was driving two ST7735 displays) and using the prop shield for doing ws2812b/neopixels.

    Here is the thread where it was discussed, and Paul S. and KurtE's answers:


    This is the code that I use in a wrapper function around the basic neopixel objects. I don't think I've used this in some time, so the code may have bit-rotted.

    Code:
    #ifdef SPI_HAS_TRANSACTION
    
    // Return true if the pin is one of the special SPI0 pins for ouptut
    static inline bool
    is_spi0_pin (Neopixel_pin_t pin)
    {
      if (pin < 0)
        return false;
    
    #if PROCESSOR_TEENSY_ARM
      switch (pin)
        {
        default:
          break;
    
    #if PROCESSOR_TEENSY_3_5 || PROCESSOR_TEENSY_3_6
        case 27:			// 3.5/3.6 alternate SCLK0
        case 28:			// 3.5/3.6 alternate MOSI0
    #endif
        case  7:			// alternate MOSI0
        case 11:			// normal MOSI0
        case 13:			// normal SCLK
        case 14:			// alternate SCLK
          return true;
        }
    #endif
    
      return false;
    }
    
    #endif
    
    // display the pixels and possibly blink the LED
    
    void
    Neopixel_object::show (void)
    {
      if (lowlevel)
        {
    #ifdef SPI_HAS_TRANSACTION
          bool pin_spi_p  = do_spi_reserve && is_spi0_pin (pin_neopixel);
          bool pin2_spi_p = do_spi_reserve && is_spi0_pin (pin_neopixel2);
    
          if (do_spi_reserve)
    	{
    	  // beginTransaction prevents SPI bus conflicts
    	  // We need to reset 11 & 13 to being digital pins
    	  // https://forum.pjrc.com/threads/46640-Neopixels-with-SPI-transactions-on-prop-shield-working-with-ST7735-SSD1351-displays
    	  SPI.beginTransaction (SPISettings(24000000, MSBFIRST, SPI_MODE0));
    
    	  if (pin_spi_p)
    	    pinMode (pin_neopixel, OUTPUT);
    
    	  if (pin2_spi_p)
    	    pinMode (pin_neopixel2, OUTPUT);
    
    	  // Doing uncanny eyes, we need a slight delay after doing the beingTransaction so that the first LED doesn't glitch
    	  if (do_spi_delay)
    	    delay (do_spi_delay);
    	}
    #endif
    
          if (pin_enable >= 0)
    	digitalWrite (pin_enable, HIGH);
    
          lowlevel->show ();
    
          if (do_blink)
    	blink ();
    
          if (pin_enable >= 0)
    	digitalWrite (pin_enable, LOW);
    
    #ifdef SPI_HAS_TRANSACTION
          if (do_spi_reserve)
    	{
    	  // allow other libs to use SPI again
    	  SPI.endTransaction ();
    
    #if PROCESSOR_TEENSY_3_X || PROCESSOR_TEENSY_LC
    	  if (pin_spi_p)
    	    {
    	      volatile uint32_t *reg = portConfigRegister (pin_neopixel);
    	      *reg = PORT_PCR_MUX (2);
    	    }
    
    	  if (pin2_spi_p)
    	    {
    	      volatile uint32_t *reg = portConfigRegister (pin_neopixel2);
    	      *reg = PORT_PCR_MUX (2);
    	    }
    
    #elif PROCESSOR_TEENSY_4_x
    	  if (pin_spi_p || pin_spi2_p)
    	    Serial.println ("Need to add Teensy 4.0 transaction support");
    #endif
    
    	}
    #endif
        }
      else
        abort_with_message ("Neopixel_object::show, no lowlevel neopixel");
    }
    Here is the code that sets the various PROCESSOR_TEEENSY macros:
    Code:
    #if defined(__MK20DX128__)
    #define PROCESSOR_TEENSY_3_0		1
    #define PROCESSOR_TEENSY_3_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 3.0"
    
    #elif defined(__MK20DX256__)
    #define PROCESSOR_TEENSY_3_1		1	// 3.1 and 3.2 are identical except for the voltage regulator
    #define PROCESSOR_TEENSY_3_2		1
    #define PROCESSOR_TEENSY_3_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 3.2"
    
    #elif defined(__MKL26Z64__)
    #define PROCESSOR_TEENSY_LC		1
    #define PROCESSOR_NAME			"PJRC Teensy LC"
    
    #elif defined(__MK64FX512__)
    #define PROCESSOR_TEENSY_3_5		1
    #define PROCESSOR_TEENSY_3_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 3.5"
    
    #elif defined(__MK66FX1M0__)
    #define PROCESSOR_TEENSY_3_6		1
    #define PROCESSOR_TEENSY_3_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 3.6"
    
    #elif defined(__IMXRT1052__)
    #define PROCESSOR_TEENSY_4_BETA1	1
    #define PROCESSOR_TEENSY_4_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 4.0 Beta1"
    
    #elif defined(__IMXRT1062__)
    #define PROCESSOR_TEENSY_4		1
    #define PROCESSOR_TEENSY_4_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    
    #if defined(ARDUINO_TEENSY40)
    #define PROCESSOR_TEENSY_4_0		1
    #define PROCESSOR_TEENSY_4_1		1
    #define PROCESSOR_NAME			"PJRC Teensy 4.0"
    
    #elif defined(ARDUINO_TEENSY41)
    #define PROCESSOR_TEENSY_4_0		0
    #define PROCESSOR_TEENSY_4_1		1
    #define PROCESSOR_NAME			"PJRC Teensy 4.1"
    
    #else
    #define PROCESSOR_TEENSY_4_0		0
    #define PROCESSOR_TEENSY_4_1		0
    #define PROCESSOR_NAME			"PJRC Teensy 4.x"
    #endif
    
    #else
    #warning "Unknown Teensy, fix Meissner_Config_Teensy.h"
    #define PROCESSOR_NAME			"PJRC Unknown Teensy"
    #endif

  8. #8
    Junior Member
    Join Date
    May 2019
    Location
    Frankfurt,Germany
    Posts
    7
    Quote Originally Posted by MichaelMeissner View Post
    I ran into problems switching back and forth between using the SPI device (in my case it was driving two ST7735 displays) and using the prop shield for doing ws2812b/neopixels.

    Here is the thread where it was discussed, and Paul S. and KurtE's answers:


    This is the code that I use in a wrapper function around the basic neopixel objects. I don't think I've used this in some time, so the code may have bit-rotted.

    Code:
    #ifdef SPI_HAS_TRANSACTION
    
    // Return true if the pin is one of the special SPI0 pins for ouptut
    static inline bool
    is_spi0_pin (Neopixel_pin_t pin)
    {
      if (pin < 0)
        return false;
    
    #if PROCESSOR_TEENSY_ARM
      switch (pin)
        {
        default:
          break;
    
    #if PROCESSOR_TEENSY_3_5 || PROCESSOR_TEENSY_3_6
        case 27:			// 3.5/3.6 alternate SCLK0
        case 28:			// 3.5/3.6 alternate MOSI0
    #endif
        case  7:			// alternate MOSI0
        case 11:			// normal MOSI0
        case 13:			// normal SCLK
        case 14:			// alternate SCLK
          return true;
        }
    #endif
    
      return false;
    }
    
    #endif
    
    // display the pixels and possibly blink the LED
    
    void
    Neopixel_object::show (void)
    {
      if (lowlevel)
        {
    #ifdef SPI_HAS_TRANSACTION
          bool pin_spi_p  = do_spi_reserve && is_spi0_pin (pin_neopixel);
          bool pin2_spi_p = do_spi_reserve && is_spi0_pin (pin_neopixel2);
    
          if (do_spi_reserve)
    	{
    	  // beginTransaction prevents SPI bus conflicts
    	  // We need to reset 11 & 13 to being digital pins
    	  // https://forum.pjrc.com/threads/46640-Neopixels-with-SPI-transactions-on-prop-shield-working-with-ST7735-SSD1351-displays
    	  SPI.beginTransaction (SPISettings(24000000, MSBFIRST, SPI_MODE0));
    
    	  if (pin_spi_p)
    	    pinMode (pin_neopixel, OUTPUT);
    
    	  if (pin2_spi_p)
    	    pinMode (pin_neopixel2, OUTPUT);
    
    	  // Doing uncanny eyes, we need a slight delay after doing the beingTransaction so that the first LED doesn't glitch
    	  if (do_spi_delay)
    	    delay (do_spi_delay);
    	}
    #endif
    
          if (pin_enable >= 0)
    	digitalWrite (pin_enable, HIGH);
    
          lowlevel->show ();
    
          if (do_blink)
    	blink ();
    
          if (pin_enable >= 0)
    	digitalWrite (pin_enable, LOW);
    
    #ifdef SPI_HAS_TRANSACTION
          if (do_spi_reserve)
    	{
    	  // allow other libs to use SPI again
    	  SPI.endTransaction ();
    
    #if PROCESSOR_TEENSY_3_X || PROCESSOR_TEENSY_LC
    	  if (pin_spi_p)
    	    {
    	      volatile uint32_t *reg = portConfigRegister (pin_neopixel);
    	      *reg = PORT_PCR_MUX (2);
    	    }
    
    	  if (pin2_spi_p)
    	    {
    	      volatile uint32_t *reg = portConfigRegister (pin_neopixel2);
    	      *reg = PORT_PCR_MUX (2);
    	    }
    
    #elif PROCESSOR_TEENSY_4_x
    	  if (pin_spi_p || pin_spi2_p)
    	    Serial.println ("Need to add Teensy 4.0 transaction support");
    #endif
    
    	}
    #endif
        }
      else
        abort_with_message ("Neopixel_object::show, no lowlevel neopixel");
    }
    Here is the code that sets the various PROCESSOR_TEEENSY macros:
    Code:
    #if defined(__MK20DX128__)
    #define PROCESSOR_TEENSY_3_0		1
    #define PROCESSOR_TEENSY_3_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 3.0"
    
    #elif defined(__MK20DX256__)
    #define PROCESSOR_TEENSY_3_1		1	// 3.1 and 3.2 are identical except for the voltage regulator
    #define PROCESSOR_TEENSY_3_2		1
    #define PROCESSOR_TEENSY_3_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 3.2"
    
    #elif defined(__MKL26Z64__)
    #define PROCESSOR_TEENSY_LC		1
    #define PROCESSOR_NAME			"PJRC Teensy LC"
    
    #elif defined(__MK64FX512__)
    #define PROCESSOR_TEENSY_3_5		1
    #define PROCESSOR_TEENSY_3_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 3.5"
    
    #elif defined(__MK66FX1M0__)
    #define PROCESSOR_TEENSY_3_6		1
    #define PROCESSOR_TEENSY_3_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 3.6"
    
    #elif defined(__IMXRT1052__)
    #define PROCESSOR_TEENSY_4_BETA1	1
    #define PROCESSOR_TEENSY_4_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    #define PROCESSOR_NAME			"PJRC Teensy 4.0 Beta1"
    
    #elif defined(__IMXRT1062__)
    #define PROCESSOR_TEENSY_4		1
    #define PROCESSOR_TEENSY_4_X		1
    #define PROCESSOR_TEENSY_3_OR_4_X	1
    #define PROCESSOR_TEENSY_ARM		1
    
    #if defined(ARDUINO_TEENSY40)
    #define PROCESSOR_TEENSY_4_0		1
    #define PROCESSOR_TEENSY_4_1		1
    #define PROCESSOR_NAME			"PJRC Teensy 4.0"
    
    #elif defined(ARDUINO_TEENSY41)
    #define PROCESSOR_TEENSY_4_0		0
    #define PROCESSOR_TEENSY_4_1		1
    #define PROCESSOR_NAME			"PJRC Teensy 4.1"
    
    #else
    #define PROCESSOR_TEENSY_4_0		0
    #define PROCESSOR_TEENSY_4_1		0
    #define PROCESSOR_NAME			"PJRC Teensy 4.x"
    #endif
    
    #else
    #warning "Unknown Teensy, fix Meissner_Config_Teensy.h"
    #define PROCESSOR_NAME			"PJRC Unknown Teensy"
    #endif

    Ok thats too much for me ...
    iam newbee and dont know how to use wrapper code

    maybe i try Pauls WS2812 non Blocking lib
    i think it could work cause it uses serial ports to send the data stream
    its not easy for me but i try

    thnx so much to all of you

  9. #9
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    4,383
    Quote Originally Posted by molleonair View Post
    Ok thats too much for me ...
    iam newbee and dont know how to use wrapper code
    The wrapper code is just a class that I have that has the neopixel data structure as a member, plus some other elements, such as the pins used, etc.

    Basically you need something like this:
    Code:
      // beginTransaction prevents SPI bus conflicts
      // We need to reset pins 11/13 to be normal digital pins
      // https://forum.pjrc.com/threads/46640-Neopixels-with-SPI-transactions-on-prop-shield-working-with-ST7735-SSD1351-displays
      SPI.beginTransaction (SPISettings(24000000, MSBFIRST, SPI_MODE0));
      pinMode (11, OUTPUT);
      pinMode (13, OUTPUT);
      delay (10);                        // possibly we need a small delay
    
      // Enable LEDs
      digitalWrite (7, HIGH);
    
      // Do the show function
      pixels.show ();
    
      // Wait for any SPI transactions to finish
      SPI.endTransaction ();
    
      // Reset pins 11/13 to be SPI mode
      volatile uint32_t *pin11 = portConfigRegister (11);
      *pin11 = PORT_PCR_MUX (2);
    
      volatile uint32_t *ping13 = portConfigRegister (13);
      *pin13 = PORT_PCR_MUX (2);
    
      // Disable LEDs
      digitalWrite (7, HIGH);
    
      delay (10);                        // possibly we need a small delay
    Quote Originally Posted by molleonair View Post
    Ok thats too much for me ...
    maybe i try Pauls WS2812 non Blocking lib
    i think it could work cause it uses serial ports to send the data stream
    its not easy for me but i try

    thnx so much to all of you
    Or just don't use the prop shield to do the level shifting and use some pin other than 11 or 13. But you need to test whether the pin will work with 3.3v data signals. Many newer ws2812b/neopixels will work with 3.3v signals, some won't (particularly older designs). I think the SK6812 based LEDs will work with 3.3v.

Posting Permissions

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