Metro M0 Express and Music Maker Shield

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
loopstick
 
Posts: 9
Joined: Tue Jun 15, 2010 12:09 am

Metro M0 Express and Music Maker Shield

Post by loopstick »

I'm trying to get a Music Maker Shield working with a Metro M0 Express.
Shield SPI jumpers have been solder-bridged to use SPI pins:
https://learn.adafruit.com/adafruit-mus ... rs-1214285
Shield and code works fine with Arduino Mega.
After testing with the Mega, the only code change has been to change the SPI pin definitions
using this information: https://learn.adafruit.com/adafruit-met ... el-2835948
SCK #38, MISO #36, MOSI #37 <- does not work, shield not found
SCK #24, MISO #22, MOSI #23 <- does not work, shield not found
SCK #11, MISO #12, MOSI #10 <- does not work, shield not found

Must be missing something. TIA.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Metro M0 Express and Music Maker Shield

Post by mikeysklar »

This shield might not be compatible with Metro M0.

From the guide and product page.
Works with Arduino Uno, Mega, or Leonardo
That's why we spun up the best shield, perfect for use with any Arduino Uno, Leonardo or Mega.
I would think the pinout you want to use is:

Code: Select all

    SPI SCK - connected to Digital #13 (but can be connected to the ISP header with a jumper) - used by both the SD card and VS1053
    SPI MISO - connected to Digital #12 (but can be connected to the ISP header with a jumper) - used by both the SD card and VS1053
    SPI MOSI - connected to Digital #11 (but can be connected to the ISP header with a jumper) - used by both the SD card and VS1053
You had something close, but had the MOSI as 10 which should be 11.

Also make sure you have removed the solder form the jumper shorting required for the Mega.

User avatar
loopstick
 
Posts: 9
Joined: Tue Jun 15, 2010 12:09 am

Re: Metro M0 Express and Music Maker Shield

Post by loopstick »

Thanks for the info. That was a typo on my part.

The first thing we tried was the Uno pinout as given in the tutorial:
SPI SCK - connected to Digital #13
SPI MISO - connected to Digital #12
SPI MOSI - connected to Digital #11

when that didn't work we tried using the SPI pins <-did not work.

SPI pins work with Mega but I can't get them to work with the Metro M0 Express.

How do we get in touch with Adafruit to see if the Metro M0 Express is compatible with the Music Maker Shield?

Assuming that the Metro M0 Express is not listed in the tutorial because the tutorial was written before the Metro M0 Express existed.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Metro M0 Express and Music Maker Shield

Post by mikeysklar »

I'm paid by Adafruit to help troubleshoot this. You have a combination of hardware that has not been documented, but probably can be made to work with minimal changes. The current day setup would be a Feather M0 + MusicMaker FeatherWing would be used.

Looking at the Metro M0 Express pinout shows hte SPI port is going to be off the 6-pin 2x3 ICSP port just like your MEGA had used. That means you will need the top corner jumpers soldered.

Nore the new pin numbers that Metro M0 Express uses.
Screenshot from 2023-04-03 13-26-30.png
Screenshot from 2023-04-03 13-26-30.png (61.09 KiB) Viewed 151 times

User avatar
loopstick
 
Posts: 9
Joined: Tue Jun 15, 2010 12:09 am

Re: Metro M0 Express and Music Maker Shield

Post by loopstick »

Now we're on the same page. What follows is a redux of the info in my first post, sorry if it wasn't clear before.

The Music Maker shield didn't work with the 'standard' Uno pins:
SCK #13, MISO #12, MOSI #11 <- does not work, shield not found

So...I assumed we'd have to use the 6-pin 2x3 ICSP port and solder-bridged the shield SPI jumpers.

With freshly soldered top corner jumpers, I first tried the pins as shown in the image you posted from the Metro M0 Express pinout page:
SCK #24, MISO #22, MOSI #23 <- does not work, shield not found

As you said, this should have worked. But it didn't...
so I did a little more digging and found this bit on metro M0 Express SPI pins:
https://learn.adafruit.com/adafruit-met ... el-2835948
I tried the pin definitions found on that page - to no avail:
SCK #38, MISO #36, MOSI #37 <- does not work, shield not found

I'm hoping there's something simple I've missed.
I tested the SPI pins with a Mega and that worked fine to confirm that the shield connection to SPI pins is functional, but we'd really like to be able to use the Metros we purchased for this project!

TIA.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Metro M0 Express and Music Maker Shield

Post by mikeysklar »

Thank you for the summary of the pins you have tried.

I can rig up a related setup (not identical) using a Metro M0 and Music Maker FeatherWing to help determine the SPI pins. I’ll try not specifying the pins at all using builtin default HW SPI definitions (if possible) and selecting appropriate CS pins.

User avatar
adafruit2
 
Posts: 22111
Joined: Fri Mar 11, 2005 7:36 pm

Re: Metro M0 Express and Music Maker Shield

Post by adafruit2 »

don't change the SPI pins by hand, use the default SPI port, you just need to change the other control pins like CS. post a photo of your soldered shield, maybe something got missed

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Metro M0 Express and Music Maker Shield

Post by mikeysklar »

I connected a Metro M0 Express to a FeatherWing Music Maker with minimal modification to the player_simple.ino . I was able to see the code run on the serial console and play audio.

Below is the pinouts including variable names in brackets. Note that I was connecting to the ICSP connector and using the built-in HW SPI.

Screenshot from 2023-04-05 14-51-25.png
Screenshot from 2023-04-05 14-51-25.png (41.45 KiB) Viewed 137 times

I made three small changes to the player_simple.ino:
  • comment out the breakout example and use the shield-example
  • change the baudrate to 115200
  • add a while(!Serial); to wait for serial port to come up
Code was built with Arduino IDE 1.x using the current Music Maker VS1053 library (v1.3.0).

Code: Select all

/*************************************************** 
  This is an example for the Adafruit VS1053 Codec Breakout

  Designed specifically to work with the Adafruit VS1053 Codec Breakout 
  ----> https://www.adafruit.com/products/1381

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

// define the pins used
//#define CLK 13       // SPI Clock, shared with SD card
//#define MISO 12      // Input data, from VS1053/SD card
//#define MOSI 11      // Output data, to VS1053/SD card
// Connect CLK, MISO and MOSI to hardware SPI pins. 
// See http://arduino.cc/en/Reference/SPI "Connections"

// These are the pins used for the breakout example
#define BREAKOUT_RESET  9      // VS1053 reset pin (output)
#define BREAKOUT_CS     10     // VS1053 chip select pin (output)
#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer = 
  // create breakout-example object!
  //Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
  // create shield-example object!
Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
  
void setup() {
  Serial.begin(115200);
  while(!Serial);    
  Serial.println("Adafruit VS1053 Simple Test");

  if (! musicPlayer.begin()) { // initialise the music player
     Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
     while (1);
  }
  Serial.println(F("VS1053 found"));
  
   if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  }

  // list files
  printDirectory(SD.open("/"), 0);
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20,20);

  // Timer interrupts are not suggested, better to use DREQ interrupt!
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

  // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
  // audio playing
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
  
  // Play one file, don't return until complete
  Serial.println(F("Playing track 001"));
  musicPlayer.playFullFile("/track001.mp3");
  // Play another file in the background, REQUIRES interrupts!
  Serial.println(F("Playing track 002"));
  musicPlayer.startPlayingFile("/track002.mp3");
}

void loop() {
  // File is playing in the background
  if (musicPlayer.stopped()) {
    Serial.println("Done playing music");
    while (1) {
      delay(10);  // we're done! do nothing...
    }
  }
  if (Serial.available()) {
    char c = Serial.read();
    
    // if we get an 's' on the serial console, stop!
    if (c == 's') {
      musicPlayer.stopPlaying();
    }
    
    // if we get an 'p' on the serial console, pause/unpause!
    if (c == 'p') {
      if (! musicPlayer.paused()) {
        Serial.println("Paused");
        musicPlayer.pausePlaying(true);
      } else { 
        Serial.println("Resumed");
        musicPlayer.pausePlaying(false);
      }
    }
  }

  delay(100);
}


/// File listing helper
void printDirectory(File dir, int numTabs) {
   while(true) {
     
     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       //Serial.println("**nomorefiles**");
       break;
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
     entry.close();
   }
}
         
Attachments
player_simple.zip
(1.9 KiB) Downloaded 3 times

User avatar
loopstick
 
Posts: 9
Joined: Tue Jun 15, 2010 12:09 am

Re: Metro M0 Express and Music Maker Shield

Post by loopstick »

MMS_SPIpins_soldered2.jpg
MMS_SPIpins_soldered2.jpg (737.47 KiB) Viewed 133 times
I'm only changing the SPI pin definitions in the code. Is that what you mean "by hand"?

As seen here commented out in the example file:
Screen Shot 2023-04-05 at 2.51.54 PM.png
Screen Shot 2023-04-05 at 2.51.54 PM.png (30.38 KiB) Viewed 133 times
Shall I leave these SPI pin definitions commented out?

Tried it with SPI pin definitions commented out and it still doesn't work
-> I don't get the debug message "Couldn't find VS1053, do you have the right pins defined?"
and it appears that none of the Serial.prints are coming through

User avatar
loopstick
 
Posts: 9
Joined: Tue Jun 15, 2010 12:09 am

Re: Metro M0 Express and Music Maker Shield

Post by loopstick »

I tried with Mikey's code and was unsuccessful:
Screen Shot 2023-04-05 at 3.14.47 PM.png
Screen Shot 2023-04-05 at 3.14.47 PM.png (35.56 KiB) Viewed 133 times

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Metro M0 Express and Music Maker Shield

Post by mikeysklar »

Yes, leave those pins commented out CLK/MISO/MOSI.

The photo you showed was of a mega board, not a Metro M0 Express.

User avatar
loopstick
 
Posts: 9
Joined: Tue Jun 15, 2010 12:09 am

Re: Metro M0 Express and Music Maker Shield

Post by loopstick »

Yes, I took the photo before I swapped the Music Maker Shield to the Metro M0 Express.

Do you need me to take another photo of the same shield?

User avatar
loopstick
 
Posts: 9
Joined: Tue Jun 15, 2010 12:09 am

Re: Metro M0 Express and Music Maker Shield

Post by loopstick »

IMG_4109.jpg
IMG_4109.jpg (587.27 KiB) Viewed 129 times
same shield, now on the Metro M0 Express.

User avatar
mikeysklar
 
Posts: 13824
Joined: Mon Aug 01, 2016 8:10 pm

Re: Metro M0 Express and Music Maker Shield

Post by mikeysklar »

Cut the mini wires between the #11 / #12 / #13 jumpers.

Since we are using default shield pins you should not need require any external jumper wires off the header pins. Are you using any of those with the M0 Express?

User avatar
loopstick
 
Posts: 9
Joined: Tue Jun 15, 2010 12:09 am

Re: Metro M0 Express and Music Maker Shield

Post by loopstick »

I am 100% sure the ICSP jumpers have good solder flow -> I'm positive this is the case because they worked with the Mega.

I cut the traces between the #11 / #12 / #13 jumpers. Double checked with a multimeter.

IT WORKS!

Tests fine with your code and the original code we were using.

Thank you!

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”