I'm wanting to build an MP3 player, or at least, try. I'm starting out with the VS1011E as I already had one of the chips lying around.
First of all I just want to verify that all the hardware actually functions before I start so if there's a problem I can be pretty sure it's in software, not hardware.
I came across and am trying to use the test sketches from someone else's project here: Arduino MP3 to do a quick test.
I doubt I should post the whole lot of code here, as it would take up a lot of space. I'll post the part I am having problems with in case there is some really stupid error I'm overlooking.
But the files in question can be downloaded here: Arduino MP3 or GitHub: GitHub - brokentoaster/ArduinoMP3: The Arduino MP3 shield is an add on board for developing Arduino based systems that incorporate MP3 decoding, SD cards and Joysticks. It is initially based on the work done as part of the ButterflyMP3 Project.
(I would have asked the person who did that project but I can't find a way to contact him on his website at all)
I've got the same Decoder chip - the VS1011E - that he uses in his project, and an ATMega168 running a 12MHz clock with an Optiboot bootloader compiled for 12MHz and of course custom target board defined in Arduino IDE.
Maybe Optiboot or the custom clock speed is the problem?
I also did have to update his files to use Arduino.h instead of WProgram.h - I don't know if that's a red flag for other potential problems down the line...
I have already tried the Joystick test sketch and it runs without issue, the output is all as expected.
The problem I'm having is with the MP3_TEST sketch that I tried afterwards:
// This is a Test for just the MP3 player chip and NOT MMC/SD card routines
// Should start up the board and then playsome sine wave tones.
#define BAUD 115200
#define FAT_NumberedSong_EN 1
#include <utils.h>
#include <mmc.h>
#include <vs1001.h>
#include <types.h>
MMC card; // not used but doesn't work with out it
vs1001 player;
char mp3_cs = 3;
char mp3_bsync = 2;
char mp3_dreq = 15;
char mp3_reset = 14 ;
char debugpin = 8;
//////////////////////////////////// SETUP
void setup()
{
char r,i;
unsigned long lr;
pinMode(debugpin,OUTPUT); // setup debug trigger
digitalWrite(debugpin, HIGH);
digitalWrite(mp3_dreq, HIGH); // turn on pullup resistors
digitalWrite(mp3_bsync, LOW); // turn off BSYNC
digitalWrite(mp3_reset, LOW); // turn off VS1003
digitalWrite(mp3_cs, HIGH); // turn off VS10xx SPI
pinMode(mp3_dreq, INPUT); // set pin to input
pinMode(mp3_bsync,OUTPUT); // set pin to output
pinMode(mp3_reset,OUTPUT); // set pin to output
pinMode(mp3_cs,OUTPUT); // set pin to output
// Init Serial comms and send a test message
Serial.begin(BAUD);
Serial.println("Arduino MP3 Shield VS1011 Test");
// Run some tests on the VS1011 chip
Serial.print("Init IO ... ");
player.init_io();
Serial.println("OK");
Serial.print("Init_chip ... ");
player.init_chip();
Serial.println("OK");
Serial.print("Sine_test ... ");
player.sine_test();
Serial.println("OK");
// Read out all the regesters
for (i=0;i<16;i++){
delay(10);
Serial.print("Read Reg ");
Serial.print(i,DEC);
Serial.print(": ");
Serial.println(readReg(i),HEX);
}
// Done.
Serial.println("DONE");
}
//////////////////////////////////// LOOP
void loop()
{
// Do nothing
}
/***************************************************************************
* Name: debug_trigger
* Description: pulse the debug pin low then high again as fast as you can
* Parameters: <x> char number of times to pulse the line.
* Returns: none
***************************************************************************/
void debug_trigger(char x)
{
char i;
for (i=0;i<x;i++){
digitalWrite(debugpin, LOW);
digitalWrite(debugpin, HIGH);
}
}
/***************************************************************************
* Name: readReg
* Description: read a register from the VS1011 and return 16 Bit response
* Parameters: <reg> byte address of register to read
* Returns: 16 Bit data returned from the register
***************************************************************************/
uint16 readReg(uint8 reg)
{
uint16 data;
player.read(reg, 2,&data);
return data;
}
From his website, the expected output on the serial monitor is as follows:
Arduino MP3 Shield VS1011 Test
Init IO ... OK
Init_chip ... OK
Sine_test ... OK
Read Reg 0: 820
Read Reg 1: 20
Read Reg 2: 0
Read Reg 3: 9800
Read Reg 4: 0
Read Reg 5: BB80
Read Reg 6: 0
Read Reg 7: 0
Read Reg 8: 0
Read Reg 9: 0
Read Reg 10: 0
Read Reg 11: 0
Read Reg 12: 0
Read Reg 13: 0
Read Reg 14: 0
Read Reg 15: 0
DONE
Whereas with mine, I just get:
Arduino MP3 Shield VS1011 Test
Init IO ... OK
Init_chip ... OK
Sine_test ... OK
Read Reg 0: 820
Read Reg 1: 20
Read Reg 1: 20
Read Reg 1: 20
Read Reg 1: 20
With the "Read Reg 1: 20" line repeated over and over forever...
I have tried changing the loop so it starts at another number, like 3, at which point it reads register 3, then 4, then keeps repeating the output for register 4 over and over.
Note that the registers all do print out the same numbers as his example (when the loop variable init value is changed), also that the Sine wave test passes, I can hear the tone fine.
I suspect that the VS1011E is working OK, as I doubt it could pass the IO\Init tests and also output a correct audio signal on both channels if it were faulty or wired incorrectly.
I have tried compiling both with Arduino 1.0 in Linux and Arduino 1.0.5 in Windows and both have the same issue.
Anyone got any ideas what might be going on here?