Offline
Sr. Member
Karma: 0
Posts: 405
|
 |
« on: May 01, 2012, 09:56:18 am » |
Bonsoir @ tous Voilà je possède cette carte (DEV-10587) : http://www.sparkfun.com/products/10587Elle fonctionne ,déjà une bonne chose  Mais possèdant un lecteur de carte SD (Adafruit) je n'ai pas trouvé utile de prendre cette carte : http://www.sparkfun.com/products/10628Mais voilà , la lecture de MP3 ne fonctionne pas  Pourtant j'ai respecté les conseils (intégré la LIB , modifié le fichier Sd2PinMap.h , mis les fichiers MP3 d'exemples ) It relies on the sdfatlib from Bill Greiman: http://code.google.com/p/sdfatlib/ You will need to download and install his library. To compile, you MUST change Sd2PinMap.h of the SDfatlib! The default SS_PIN = 10;. You must change this line under the ATmega328/Arduino area of code to uint8_t const SS_PIN = 9;. This will cause the sdfatlib to use pin 9 as the 'chip select' for the microSD card on pin 9 of the Arduino so that the layout of the shield works. ça ne fonctionne pas ,j'ai du oublier quelque chose  Merci pour votre aide  Cordialement Will P.S: je fais suivre le Sketch 
|
|
|
|
« Last Edit: May 03, 2012, 08:51:39 am by AlienArea51 »
|
Logged
|
The truth is elsewhere !!
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 405
|
 |
« Reply #1 on: May 01, 2012, 10:01:40 am » |
Voici le Sketch (vous pouvez le voir sur le site) car obligé d'enlever des lignes de texte : #include <SPI.h>
//Add the SdFat Libraries #include <SdFat.h> #include <SdFatUtil.h>
//Create the variables to be used by SdFat Library Sd2Card card; SdVolume volume; SdFile root; SdFile track;
char trackName[] = "track001.mp3"; int trackNumber = 1;
char errorMsg[100]; //This is a generic array used for sprintf of error messages
#define TRUE 0 #define FALSE 1
//MP3 Player Shield pin mapping. See the schematic #define MP3_XCS 6 //Control Chip Select Pin (for accessing SPI Control/Status registers) #define MP3_XDCS 7 //Data Chip Select / BSYNC Pin #define MP3_DREQ 2 //Data Request Pin: Player asks for more data #define MP3_RESET 8 //Reset is active low //Remember you have to edit the Sd2PinMap.h of the sdfatlib library to correct control the SD card.
//VS10xx SCI Registers #define SCI_MODE 0x00 #define SCI_STATUS 0x01 #define SCI_BASS 0x02 #define SCI_CLOCKF 0x03 #define SCI_DECODE_TIME 0x04 #define SCI_AUDATA 0x05 #define SCI_WRAM 0x06 #define SCI_WRAMADDR 0x07 #define SCI_HDAT0 0x08 #define SCI_HDAT1 0x09 #define SCI_AIADDR 0x0A #define SCI_VOL 0x0B #define SCI_AICTRL0 0x0C #define SCI_AICTRL1 0x0D #define SCI_AICTRL2 0x0E #define SCI_AICTRL3 0x0F
void setup() { pinMode(MP3_DREQ, INPUT); pinMode(MP3_XCS, OUTPUT); pinMode(MP3_XDCS, OUTPUT); pinMode(MP3_RESET, OUTPUT);
digitalWrite(MP3_XCS, HIGH); //Deselect Control digitalWrite(MP3_XDCS, HIGH); //Deselect Data digitalWrite(MP3_RESET, LOW); //Put VS1053 into hardware reset
Serial.begin(9600); //Use serial for debugging Serial.println("MP3 Testing");
//Setup SD card interface pinMode(9, OUTPUT); //Pin 10 must be set as an output for the SD communication to work. if (!card.init(SPI_FULL_SPEED)) Serial.println("Error: Card init"); //Initialize the SD card and configure the I/O pins. if (!volume.init(&card)) Serial.println("Error: Volume ini"); //Initialize a volume on the SD card. if (!root.openRoot(&volume)) Serial.println("Error: Opening root"); //Open the root directory in the volume.
SPI.setClockDivider(SPI_CLOCK_DIV16); //Set SPI bus speed to 1MHz (16MHz / 16 = 1MHz) SPI.transfer(0xFF); //Throw a dummy byte at the bus //Initialize VS1053 chip delay(10); digitalWrite(MP3_RESET, HIGH); //Bring up VS1053 //delay(10); //We don't need this delay because any register changes will check for a high DREQ
//Mp3SetVolume(20, 20); //Set initial volume (20 = -10dB) LOUD Mp3SetVolume(40, 40); //Set initial volume (20 = -10dB) Manageable //Mp3SetVolume(80, 80); //Set initial volume (20 = -10dB) More quiet
//Let's check the status of the VS1053 int MP3Mode = Mp3ReadRegister(SCI_MODE); int MP3Status = Mp3ReadRegister(SCI_STATUS); int MP3Clock = Mp3ReadRegister(SCI_CLOCKF);
Serial.print("SCI_Mode (0x4800) = 0x"); Serial.println(MP3Mode, HEX);
Serial.print("SCI_Status (0x48) = 0x"); Serial.println(MP3Status, HEX);
int vsVersion = (MP3Status >> 4) & 0x000F; //Mask out only the four version bits Serial.print("VS Version (VS1053 is 4) = "); Serial.println(vsVersion, DEC); //The 1053B should respond with 4. VS1001 = 0, VS1011 = 1, VS1002 = 2, VS1003 = 3
Serial.print("SCI_ClockF = 0x"); Serial.println(MP3Clock, HEX);
//Now that we have the VS1053 up and running, increase the internal clock multiplier and up our SPI rate Mp3WriteRegister(SCI_CLOCKF, 0x60, 0x00); //Set multiplier to 3.0x
SPI.setClockDivider(SPI_CLOCK_DIV4); //Set SPI bus speed to 4MHz (16MHz / 4 = 4MHz)
MP3Clock = Mp3ReadRegister(SCI_CLOCKF); Serial.print("SCI_ClockF = 0x"); Serial.println(MP3Clock, HEX);
//MP3 IC setup complete }
void loop(){
//Let's play a track of a given number sprintf(trackName, "track%03d.mp3", trackNumber); //Splice the new file number into this file name playMP3(trackName); //Go play trackXXX.mp3
//Once we are done playing or have exited the playback for some reason, decide what track to play next trackNumber++; //When we loop, advance to next track!
if(trackNumber > 100) { Serial.println("Whoa there cowboy!"); //Soft limit. We shouldn't be trying to open past track 100. while(1); } } void playMP3(char* fileName) {
if (!track.open(&root, fileName, O_READ)) { //Open the file in read mode. sprintf(errorMsg, "Failed to open %s", fileName); Serial.println(errorMsg); return; }
Serial.println("Track open");
uint8_t mp3DataBuffer[32]; //Buffer of 32 bytes. VS1053 can take 32 bytes at a go. //track.read(mp3DataBuffer, sizeof(mp3DataBuffer)); //Read the first 32 bytes of the song int need_data = TRUE; long replenish_time = millis();
Serial.println("Start MP3 decoding");
while(1) { while(!digitalRead(MP3_DREQ)) { if(need_data == TRUE) { if(!track.read(mp3DataBuffer, sizeof(mp3DataBuffer))) { //Try reading 32 new bytes of the song //Oh no! There is no data left to read! //Time to exit break; } need_data = FALSE; }
Serial.print("Time to replenish buffer: "); Serial.print(millis() - replenish_time, DEC); Serial.print("ms");
//Test to see just how much we can do before the audio starts to glitch long start_time = millis(); //delay(150); //Do NOTHING - audible glitches //delay(135); //Do NOTHING - audible glitches //delay(120); //Do NOTHING - barely audible glitches delay(100); //Do NOTHING - sounds fine Serial.print(" Idle time: "); Serial.print(millis() - start_time, DEC); Serial.println("ms"); replenish_time = millis(); } if(need_data == TRUE){ //This is here in case we haven't had any free time to load new data if(!track.read(mp3DataBuffer, sizeof(mp3DataBuffer))) { //Go out to SD card and try reading 32 new bytes of the song //Oh no! There is no data left to read! //Time to exit break; } need_data = FALSE; }
//Once DREQ is released (high) we now feed 32 bytes of data to the VS1053 from our SD read buffer digitalWrite(MP3_XDCS, LOW); //Select Data for(int y = 0 ; y < sizeof(mp3DataBuffer) ; y++) { SPI.transfer(mp3DataBuffer[y]); // Send SPI byte }
digitalWrite(MP3_XDCS, HIGH); //Deselect Data need_data = TRUE; //We've just dumped 32 bytes into VS1053 so our SD read buffer is empty. Set flag so we go get more data }
while(!digitalRead(MP3_DREQ)) ; //Wait for DREQ to go high indicating transfer is complete digitalWrite(MP3_XDCS, HIGH); //Deselect Data track.close(); //Close out this track
sprintf(errorMsg, "Track %s done!", fileName); Serial.println(errorMsg); }
void Mp3WriteRegister(unsigned char addressbyte, unsigned char highbyte, unsigned char lowbyte){ while(!digitalRead(MP3_DREQ)) ; //Wait for DREQ to go high indicating IC is available digitalWrite(MP3_XCS, LOW); //Select control
//SCI consists of instruction byte, address byte, and 16-bit data word. SPI.transfer(0x02); //Write instruction SPI.transfer(addressbyte); SPI.transfer(highbyte); SPI.transfer(lowbyte); while(!digitalRead(MP3_DREQ)) ; //Wait for DREQ to go high indicating command is complete digitalWrite(MP3_XCS, HIGH); //Deselect Control }
//Read the 16-bit value of a VS10xx register unsigned int Mp3ReadRegister (unsigned char addressbyte){ while(!digitalRead(MP3_DREQ)) ; //Wait for DREQ to go high indicating IC is available digitalWrite(MP3_XCS, LOW); //Select control
//SCI consists of instruction byte, address byte, and 16-bit data word. SPI.transfer(0x03); //Read instruction SPI.transfer(addressbyte);
char response1 = SPI.transfer(0xFF); //Read the first byte while(!digitalRead(MP3_DREQ)) ; //Wait for DREQ to go high indicating command is complete char response2 = SPI.transfer(0xFF); //Read the second byte while(!digitalRead(MP3_DREQ)) ; //Wait for DREQ to go high indicating command is complete
digitalWrite(MP3_XCS, HIGH); //Deselect Control
int resultvalue = response1 << 8; resultvalue |= response2; return resultvalue; }
//Set VS10xx Volume Register void Mp3SetVolume(unsigned char leftchannel, unsigned char rightchannel){ Mp3WriteRegister(SCI_VOL, leftchannel, rightchannel); }
@+
|
|
|
|
|
Logged
|
The truth is elsewhere !!
|
|
|
|
Ile-de-France (92 sud), France
Offline
Edison Member
Karma: 22
Posts: 1817
|
 |
« Reply #2 on: May 01, 2012, 10:07:12 am » |
ça ne fonctionne pas ,j'ai du oublier quelque chose  Et qu'est-ce qui ne fonctionne pas ? La lecture du fichier çà marche ? Est-ce que tu as essayé de mettre quelques traces pour voir où ça coince ?
|
|
|
|
|
Logged
|
Barbuduino: Arduino sur Breadboard & VinciDuino: Clone Leonardo // WR703: Mini-routeur hacké // LauchPad MSP430 et Stellaris // Panda II Arduino-like .NetMF sous VisualC# RTFC: Read That F.....g Code / RTFD: Read That F.....g Doc / RTFDS: Read That F.....g DataSheet / RTFS: Read That F.....g Schematic / Wot da ya wanna D.I.Y. today ?
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 405
|
 |
« Reply #3 on: May 01, 2012, 10:14:31 am » |
Salut J-M Merci d'avoir répondu aussi rapidement  En fait ,rien ne fonctionne ,j'ai l'impression qu'il n'y a pas d'accès à la SD ,donc pas de lecture  Au début je n'avais rien modifié , donc j'avais sur le moniteur des erreurs (SD init etc.. etc..) ,là le moniteur m'affiche (MP3 testing ) ,et reste bloqué comme un cake  Pas de son (pas d'images) la ZONE KOI !!!! @+ Will
|
|
|
|
|
Logged
|
The truth is elsewhere !!
|
|
|
|
Ile-de-France (92 sud), France
Offline
Edison Member
Karma: 22
Posts: 1817
|
 |
« Reply #4 on: May 01, 2012, 10:54:52 am » |
En fait je crois que tu ne va pas arriver à grand chose avec ce module  Regarde le schéma. Le SPI n'est pas cablé. Tel quel il n'est utilisable que pour le MIDI sur la liaison série. Il va falloir charcuter...... 
|
|
|
|
|
Logged
|
Barbuduino: Arduino sur Breadboard & VinciDuino: Clone Leonardo // WR703: Mini-routeur hacké // LauchPad MSP430 et Stellaris // Panda II Arduino-like .NetMF sous VisualC# RTFC: Read That F.....g Code / RTFD: Read That F.....g Doc / RTFDS: Read That F.....g DataSheet / RTFS: Read That F.....g Schematic / Wot da ya wanna D.I.Y. today ?
|
|
|
|
France
Offline
Edison Member
Karma: 12
Posts: 1800
There is an Arduino for that
|
 |
« Reply #5 on: May 01, 2012, 10:55:22 am » |
Cette carte ne gère pas le mode MP3. Elle est câblée en mode MIDI. This board is built around the VS1053 MP3 and MIDI codec IC, wired in MIDI mode. (extrait du site Sparkfun)
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 405
|
 |
« Reply #6 on: May 01, 2012, 11:06:29 am » |
Allez-y les gars  Je coince !! Le lecteur SD est indépendant ,donc ,si j'ai bien pigé ,j'avoue ne pas avoir regardé les 2 schémas , le problème vient des connections de la puce (VS1053 ) ?? POURTANT: Musical Instrument Shield is an easy way to add great sounding MIDI sound to your next Arduino project. This board is built around the VS1053 MP3 and MIDI codec IC, wired in MIDI mode. Simply connect a speaker/stereo/pair of headphones to the 1/8" stereo jack on the shied and pass the proper serial commands to the IC and you'll be playing music in no time! NOBODY'S IS PERFECT  Will
|
|
|
|
|
Logged
|
The truth is elsewhere !!
|
|
|
|
Ile-de-France (92 sud), France
Offline
Edison Member
Karma: 22
Posts: 1817
|
 |
« Reply #7 on: May 01, 2012, 11:13:12 am » |
Ca devrait aller Apparemment je ne vois pas de piste a couper ou broches à soulever. Juste 6 fils à tirer. il faut juste un fer fin et du fil fin genre fil à wrapper au téflon. Et de bons yeux...
|
|
|
|
|
Logged
|
Barbuduino: Arduino sur Breadboard & VinciDuino: Clone Leonardo // WR703: Mini-routeur hacké // LauchPad MSP430 et Stellaris // Panda II Arduino-like .NetMF sous VisualC# RTFC: Read That F.....g Code / RTFD: Read That F.....g Doc / RTFDS: Read That F.....g DataSheet / RTFS: Read That F.....g Schematic / Wot da ya wanna D.I.Y. today ?
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 405
|
 |
« Reply #8 on: May 01, 2012, 11:32:19 am » |
OUAI  effectivement il manque du monde  MERDE ,quel balot  C'est ça quand on est pressé comme une jeune mariée  J'ai imprimé les 2 schémas , quel con je fait  Rien de bien méchant ,je pense etre à la hauteur ,MERDE ,j'en revient pas  Je pensais que c'était au niveau soft (vachement confiance ,le MEC  ) Merci [fdufnews] toujours aussi efficace (l'oeil du Linx  ) et à toi J-M  Je ne met pas résolu sur ce post tant que je n'ai pas de résultat concluant ,va t'on savoir  !! Merci les Mecs @+ Cordialement Will
|
|
|
|
|
Logged
|
The truth is elsewhere !!
|
|
|
|
Ile-de-France (92 sud), France
Offline
Edison Member
Karma: 22
Posts: 1817
|
 |
« Reply #9 on: May 01, 2012, 11:35:09 am » |
Maintenant, si tu n'y crois pas et que tu veuilles te débarrasser d'un shield encombrant et inutile à (très) vil prix ..... 
|
|
|
|
|
Logged
|
Barbuduino: Arduino sur Breadboard & VinciDuino: Clone Leonardo // WR703: Mini-routeur hacké // LauchPad MSP430 et Stellaris // Panda II Arduino-like .NetMF sous VisualC# RTFC: Read That F.....g Code / RTFD: Read That F.....g Doc / RTFDS: Read That F.....g DataSheet / RTFS: Read That F.....g Schematic / Wot da ya wanna D.I.Y. today ?
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 405
|
 |
« Reply #10 on: May 01, 2012, 11:49:00 am » |
Vas y J-M  Tu penses que je vais en chier  (vu la tournure de ta phrase ,je me fend la poire "William" ) J'ai regardé de près ,c'est vrai c'est chaud quand mème ,avec des lunettes spéciales (pour miopes comme une taupe  ) Merde ,c'est vrai ,je viens de regarder encore une fois avec mes super loupes  ,c'est vraiment vraiment très chaud  Quel con je fais  @+ Will
|
|
|
|
|
Logged
|
The truth is elsewhere !!
|
|
|
|
France
Offline
Edison Member
Karma: 12
Posts: 1800
There is an Arduino for that
|
 |
« Reply #11 on: May 01, 2012, 02:41:49 pm » |
Apparemment je ne vois pas de piste a couper ou broches à soulever. Juste 6 fils à tirer. Attention ne pas oublier de tirer GPIO1 à la masse au lieu du +3.3V c'est ça qui force le mode MIDI par défaut.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 405
|
 |
« Reply #12 on: May 02, 2012, 07:45:13 am » |
Salut fdufnews Effectivement ,c'est ça , mais directement sur le VS1053 , donc au secour  Donc résultat des courses ,j'ai réinvesti dans une DEV10628  Je sais c'est balot  @+
|
|
|
|
|
Logged
|
The truth is elsewhere !!
|
|
|
|
France
Offline
Edison Member
Karma: 12
Posts: 1800
There is an Arduino for that
|
 |
« Reply #13 on: May 02, 2012, 09:05:51 am » |
Je sais c'est balot Mais non avec ta première carte tu peux te monter un petit synthé, et/ou une boite à rythme ou une boite à musique programmable. Il y a du potentiel dans cette carte.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Sr. Member
Karma: 0
Posts: 405
|
 |
« Reply #14 on: May 02, 2012, 09:33:29 am » |
@fdufnews Quand je disais balot ,c'était plus ,que j'aurai du regarder les 2 shémas avant d'acheter ,car franchement ,dans ma petite tete d'alien , je me suis dit c'est la meme carte mais non équipée de SD  mais non "MERDE" . avec ta première carte tu peux te monter un petit synthé, et/ou une boite à rythme ou une boite à musique programmable. Pas idiot cette idée ,merci  comme je prends soin de mes affaires (conservateur) ,donc ,je l'aurai gardé au chaud  J'ai une petite platine ampli (LM386) un boitier pour Arduino ,plus qu'a prendre quelques BP et une Duemilanove (pardon UNO) en esperant qu'elle est aussi bien (je ne sais pas pourquoi ,j'ai un doute ,Bref) ,et le tour est joué  Merci, franchement pas con ton affaire  @+ Will
|
|
|
|
|
Logged
|
The truth is elsewhere !!
|
|
|
|
|