Pages: [1]   Go Down
Author Topic: arduino and vs1003  (Read 3661 times)
0 Members and 1 Guest are viewing this topic.
Houston
Offline Offline
Jr. Member
**
Karma: 0
Posts: 95
Electronics is just part of life.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so i bought the vs1003 breakoutboard from cutedigi.com

http://www.cutedigi.com/product_info.php?products_id=4343&osCsid=f4a3935e2c6ffb73cc702f7bfc2acb1e

i started learning sdi communication and i think i got some of it down, im not sure if im doing all this right on the code so can you guys please let me know where im going wrong or what i need to change?

Code:
#include <SPI.h>
#include <SD.h>

File myFile;
const int sdi = 8;            //the sdi interface for the vs1003
const int sci = 9;            //the sci interface for the vs1003
const int sdss = 10;

const int xreset = 4;
const int dreq = 5;

byte SM_RESET = 0x0004;
byte toSend = 0xF844;

void setup(){
  Serial.begin(9600);
  Serial.print("Initializing sd card....");
  pinMode(sdss, OUTPUT);
  if(!SD.begin(10)){
    Serial.print("Initialization failed!");
    return;
  }
  Serial.print("Initialization Succesful!\r\n");

}

void loop(){
  if(SD.exists("song1.mp3")){
    Serial.print("Song1 exists!\r\n");
    myFile = SD.open("song1.mp3", FILE_READ);
  }
  boolean done = false;
  while(!done){
    setSPI();
    digitalWrite(sci,LOW);
    if(digitalRead(4))
      digitalWrite(4,LOW);
    delay(1);
    SPI.transfer(0x0);
    SPI.transfer(SM_RESET);
    delay(7);
    if(digitalRead(5)){
      done = true;
    }
  }
    SPI.transfer(0x0);
    SPI.transfer(toSend);
   
   
    SPI.transfer(0xB);
    SPI.transfer(0x0000);
   
   
    digitalWrite(sci,HIGH);
    digitalWrite(sdi,LOW);
   
    SPI.transfer(0x0);
    SPI.transfer(0x0);
    SPI.transfer(myFile);
   
    for(int i = 0; i < 1048; i++){
      SPI.transfer(0x0);
    }
    myFile.close();
}

void setSPI(){
  SPI.begin();
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE0);
  SPI.setClockDivider(SPI_CLOCK_DIV8);
}

thanks for the help! =)
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

since both the SD library and the SPI library use SPI bus they will conflict with eachother.
i don't really know how to solve that as im trying to do the same with my new VS1053B breakout
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 48
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

since both the SD library and the SPI library use SPI bus they will conflict with eachother.
i don't really know how to solve that as im trying to do the same with my new VS1053B breakout

It is not difficult. I have the vs1053 running sharing the same SPi bus with the SD card using the sd library. Providing you use the proper chipselects things will be ok. See my example here, it may help http://kalum.posterous.com/private/sHqcofxooc
Logged

Pages: [1]   Go Up
Jump to: