CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC with VLSI 1003 MP3 Decoder

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
rajshek_2010



Joined: 24 Nov 2005
Posts: 5

View user's profile Send private message Send e-mail Yahoo Messenger

PIC with VLSI 1003 MP3 Decoder
PostPosted: Tue Oct 07, 2008 12:55 am     Reply with quote

We are not able to do successful sine test. We are using the NEWMODE

SCI Interface seems to be working fine, since we are able to read write
data to registers.

Since Sine test / Memory test / SCI test are not working, looks like we
have an issue with SPI Interface.
For eg. In SCI test,
1. We shift to test mode by writing 0x0820 to the SCI Mode register
2. We are able to read the SCI Mode register as 0x0820
3. But we don’t get the same value from HDATAO register after
performing SCI test.

I am posting the sample code for reference:
Code:

//#define Mp3PutInReset() output_high(MP3_XRESET)
#define Mp3PutInReset() output_low(MP3_XRESET)

/** Release the MP3 player chip from reset */
#define Mp3ReleaseFromReset() output_high(MP3_XRESET)
//#define Mp3ReleaseFromReset() output_low(MP3_XRESET)

/** Pull the VS10xx Control Chip Select line Low */
#define Mp3SelectControl() output_low(MP3_XCS)

/** Pull the VS10xx Control Chip Select line High */
#define Mp3DeselectControl() output_high(MP3_XCS)


/** Pull the VS10xx Data Chip Select line Low */
#define Mp3SelectData() output_low(MP3_XDCS)

/** Pull the VS10xx Data Chip Select line High */
#define Mp3DeselectData() output_high(MP3_XDCS)


#define SPIPutChar spi_write


/** Write VS10xx register*/

void Mp3WriteRegister(addressbyte,highbyte,lowbyte)
{

 Mp3SelectControl();

 SPIPutChar(VS_WRITE_COMMAND); //SPIPutCharWithoutWaiting

 SPIPutChar((addressbyte));

 SPIPutChar((highbyte));

 SPIPutChar((lowbyte));

//SPIWait();

 Mp3DeselectControl();

 while (!INPUT(MP3_DREQ)); /* wait for startup */
}

int16 Mp3ReadRegister(addressbyte)
{

   int8 high_byte,low_byte;
   int16 read_data=0;

 Mp3SelectControl();

 SPIPutChar(VS_READ_COMMAND); //SPIPutCharWithoutWaiting

 SPIPutChar((addressbyte));

 while(!spi_data_is_in() );

// SPIPutChar(0xff);
// delay_us(10);
 high_byte = spi_read(0);
// SPIPutChar(0xff);
 delay_cycles(50);
// while(!spi_data_is_in() );


 low_byte = spi_read(0);

//SPIWait();

 Mp3DeselectControl();

 read_data = make16(high_byte,low_byte);

 while (!INPUT(MP3_DREQ)); /* wait for startup */

 return read_data;

}



/** Soft Reset of VS10xx (Between songs) */

void Mp3SoftReset(){


 /* Soft Reset of VS10xx */

 Mp3WriteRegister (SPI_MODE, 0x08, 0x04); /* Newmode, Reset, No L1-2 */


 Delay_ms(1); /* One millisecond delay */

 while (!INPUT(MP3_DREQ)); /* wait for startup */





  /* Set clock register, doubler etc. */


Mp3WriteRegister(SPI_CLOCKF, 0xa6, 0x96);
// Mp3WriteRegister(SPI_CLOCKF, 0x1A, 0x5E);



  Delay_ms(1); /* One millisecond delay */



  /* Send null bytes to data interface */

 Mp3SelectData();

 SPIPutChar(0);//SPIPutCharWithoutWaiting

 SPIPutChar(0);

  SPIPutChar(0);

 SPIPutChar(0);

//  SPIWait();

  Mp3DeselectData();


}


/** Set VS10xx Volume Register */


void Mp3SetVolume(leftchannel,rightchannel)
{
 Mp3WriteRegister(11,(leftchannel),(rightchannel));
}

/** Reset VS10xx */

void Mp3Reset()
{


 Mp3PutInReset();

  Delay_ms(1);


 /* Send dummy SPI byte to initialize SPI */

  SPIPutChar(0xFF);//SPIPutCharWithoutWaiting


  /* Un-reset MP3 chip */

  Mp3DeselectControl();

 Mp3DeselectData();

 Mp3ReleaseFromReset();

// Mp3SetVolume(0xFF,0xFF);


 /* Set clock register, doubler etc. */



// Mp3WriteRegister(SPI_CLOCKF, 0xa6, 0x96); //oli 0xa66c//XTAL-35MHZ
// Mp3WriteRegister(SPI_CLOCKF, 0x1A, 0x5E); //oli 0xa66c//XTAL-35MHZ



  /* Wait for DREQ */

 while (!INPUT(MP3_DREQ));


  /* Slow sample rate for slow analog part startup */

  Mp3WriteRegister(SPI_AUDATA, 0, 10); /* 10 Hz */

  Delay_ms(100);

  /* Switch on the analog parts */

  Mp3SetVolume(0xfe,0xfe);

 // Mp3WriteRegister (SPI_AUDATA, 0xac, 0x45); //44100hz/* 8kHz */
  Mp3WriteRegister (SPI_AUDATA, 31, 64); //44100hz/* 8kHz */

//  Mp3SetVolume(20,20);

  Mp3SoftReset();
  /*********test and implement*/
//  SPISetFastClock();
}


/** VS10xx Sine Test Function - Good getting started example */
void VsSineTest()
{

  /* Reset MP3 chip */
  Mp3PutInReset();       /* Pull xRESET low -> hardware reset */
  Delay_MS(100);            /* 100 ms delay */

  /* Send dummy SPI byte to initialize SPI of Atmel microcontroller */
  SPIPutChar(0xFF);//SPIPutCharWithoutWaiting

  /* Un-reset MP3 chip */
  Mp3DeselectControl();  /* Pull xCS high    */
  Mp3DeselectData();     /* Pull xDCS high   */
  Mp3ReleaseFromReset(); /* Pull xRESET high */
  Delay_MS(100);            /* 100 ms delay     */


  GREEN_LED_ON();// = LED_ON;
  RED_LED_ON();// = LED_ON;

  /* VS10xx Application Notes, chapter 4.8 ---------------------------------*/
  /* As an example, let's write value 0x0820 to register 00 byte by byte    */
  Mp3SelectControl();    /* Now SPI writes go to SCI port                   */
  SPIPutChar(0x02);      /* Send SPI Byte, then wait for byte to be sent.   */
  SPIPutChar(0x00);      /* 0x02 was WRITE command, 0x00 is register number */
  SPIPutChar(0x08);      /* This byte goes to MSB                           */
  SPIPutChar(0x20);      /* ..and this is LSB. (0x20=Allow Test Mode)       */
  SPIPutChar(0x00);
//  SPIWait();             /* Wait until Atmel MCU signals SPI write complete */
  Mp3DeselectControl();  /* Now SPI writes don't go to SCI port             */

  delay_ms(1);
  mode_data=Mp3ReadRegister(SPI_MODE);

  while (!INPUT(MP3_DREQ));      /* Wait for DREQ = 1                               */
    ;           /* Do nothing while waiting for DREQ = 1           */

  /* Send a Sine Test Header to Data port*/
   Mp3DeselectControl();
  Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  delay_us(100);
  SPIPutChar(0x53);      /* - This is a special VLSI Solution test header - */
  delay_us(100);
  SPIPutChar(0xef);      /* - that starts a sine sound. It's good for     - */
  delay_us(100);
  SPIPutChar(0x6e);      /* - testing your code, the chip and also for    - */
  delay_us(100);
  SPIPutChar(0x44);//(0x00);      /* - seeing if your MP3 decoder was manufactured - */
  delay_us(100);
  SPIPutChar(0x00);      /* - by VLSI Solution oy. ------------------------ */
  delay_us(100);
  SPIPutChar(0x00);
  delay_us(100);
  SPIPutChar(0x00);
  delay_us(100);
  SPIPutChar(0x00);
  delay_ms(100);
  SPIPutChar(0x00);
//  SPIWait();
  Mp3DeselectData();

  RED_LED_OFF();// = LED_OFF;
  Delay_MS (10000);           /* 500 ms delay */
  GREEN_LED_OFF();// = LED_OFF;
//  WHILE(1);
  /* Stop the sine test sound */
  Mp3SelectData();
  SPIPutChar(0x45);
  SPIPutChar(0x78);
  SPIPutChar(0x69);
  SPIPutChar(0x74);
  SPIPutChar(0x00);
  SPIPutChar(0x00);
  SPIPutChar(0x00);
  SPIPutChar(0x00);
  SPIPutChar(0x00);
//  SPIWait();
  Mp3DeselectData();

  Delay_MS(500);            /* 500 ms delay */
}

/** VS10xx Memory Test Function - Good getting started example */
void VsMemoryTest()
{

  /* Reset MP3 chip */
  Mp3PutInReset();       /* Pull xRESET low -> hardware reset */

  Delay_MS(100);            /* 100 ms delay */


  /* VS10xx Application Notes, chapter 4.8 ---------------------------------*/
  /* As an example, let's write value 0x0820 to register 00 byte by byte    */
  Mp3SelectControl();    /* Now SPI writes go to SCI port                   */
  SPIPutChar(0x02);      /* Send SPI Byte, then wait for byte to be sent.   */
  SPIPutChar(0x00);      /* 0x02 was WRITE command, 0x00 is register number */
  SPIPutChar(0x08);      /* This byte goes to MSB                           */
  SPIPutChar(0x20);      /* ..and this is LSB. (0x20=Allow Test Mode)       */
//  SPIWait();             /* Wait until Atmel MCU signals SPI write complete */
  Mp3DeselectControl();  /* Now SPI writes don't go to SCI port             */

  delay_ms(1);

  mode_data=Mp3ReadRegister(SPI_MODE);

  while (!INPUT(MP3_DREQ))      /* Wait for DREQ = 1                               */
    ;           /* Do nothing while waiting for DREQ = 1           */

  /* Send a Sine Test Header to Data port                                   */
  Mp3SelectData();       /* Now SPI writes go to SDI port                   */
//  delay_us(100);
  SPIPutChar(0x4D);      /* - This is a special VLSI Solution test header - */
 // Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  SPIPutChar(0xEA);      /* - that starts a sine sound. It's good for     - */
 // Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  SPIPutChar(0x6D);      /* - testing your code, the chip and also for    - */
//  Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  SPIPutChar(0x54);//(0x00);      /* - seeing if your MP3 decoder was manufactured - */
//  Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  SPIPutChar(0x00);      /* - by VLSI Solution oy. ------------------------ */
//  Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  SPIPutChar(0x00);
//  Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  SPIPutChar(0x00);
//  Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  SPIPutChar(0x00);
  delay_us(100);
//  SPIWait();
  Mp3DeselectData();

  Delay_MS (40);           /* 500 ms delay */

  mode_data=Mp3ReadRegister(SPI_HDAT0);

  Delay_MS(500);            /* 500 ms delay */
}


/** VS10xx SCI Test Function - Good getting started example */
void VsSCITest()
{

  /* Reset MP3 chip */
  Mp3PutInReset();       /* Pull xRESET low -> hardware reset */

  Delay_MS(100);            /* 100 ms delay */

  Mp3WriteRegister(SPI_MODE,0x08,0x20);

  delay_ms(1);

  mode_data=Mp3ReadRegister(SPI_MODE);

  while (!INPUT(MP3_DREQ))      /* Wait for DREQ = 1                               */
    ;           /* Do nothing while waiting for DREQ = 1           */

  /* Send a Sine Test Header to Data port                                   */
  Mp3SelectData();       /* Now SPI writes go to SDI port                   */
  while (!INPUT(MP3_DREQ));

  SPIPutChar(0x53);      /* - This is a special VLSI Solution test header - */
  while (!INPUT(MP3_DREQ));
  SPIPutChar(0x70);      /* - that starts a sine sound. It's good for     - */
  while (!INPUT(MP3_DREQ));
  SPIPutChar(0xee);      /* - testing your code, the chip and also for    - */
  while (!INPUT(MP3_DREQ));
  SPIPutChar(0x48);//(0x00);      /* - seeing if your MP3 decoder was manufactured - */
  while (!INPUT(MP3_DREQ));
  SPIPutChar(0x00);      /* - by VLSI Solution oy. ------------------------ */
  while (!INPUT(MP3_DREQ));
  SPIPutChar(0x00);
  while (!INPUT(MP3_DREQ));
  SPIPutChar(0x00);
  while (!INPUT(MP3_DREQ));
  SPIPutChar(0x00);
  while (!INPUT(MP3_DREQ));
//  SPIWait();
  Mp3DeselectData();


  while (!INPUT(MP3_DREQ))      /* Wait for DREQ = 1                               */
    ;           /* Do nothing while waiting for DREQ = 1           */


  mode_data=Mp3ReadRegister(SPI_HDAT0);

  while (!INPUT(MP3_DREQ));

  mode_data=Mp3ReadRegister(SPI_MODE);

    while (!INPUT(MP3_DREQ));

  mode_data=Mp3ReadRegister(SPI_STATUS);

    while (!INPUT(MP3_DREQ));

  mode_data=Mp3ReadRegister(SPI_CLOCKF);

    while (!INPUT(MP3_DREQ));

  mode_data=Mp3ReadRegister(SPI_VOL);

  Delay_MS(500);            /* 500 ms delay */
}



int8 spi_man_read(void)
{
   signed int8 bit_cnt, data=0;

   for(bit_cnt=7;bit_cnt>=0;bit_cnt--)
   {
      OUTPUT_LOW(MP3_XSCLK);
      delay_cycles(2);
      OUTPUT_HIGH(MP3_XSCLK);
      OUTPUT_HIGH(MP3_XSI);
      if(INPUT(MP3_XSO))   bit_set(data,bit_cnt);
      delay_cycles(2);
      OUTPUT_LOW(MP3_XSI);
   }
   return data;

}

Hoping someone is there to help us out.
giomm
Guest







PostPosted: Mon Oct 13, 2008 8:41 am     Reply with quote

Hi rajshek_2010

I'm using a VS1053, slightly different of vs1003 but I think the sine wave test are similar mode.

I've found a lot of issue about the spi com with this chip, 1st of all the speed.
You need to initialize the pic spi baudrate not over 1Mbit, otherwise the chip cannot rx correct data, 1st op after boot you need to setup a CLOCKF (rise the chip clock to > 50Mhz) register and so you can rise the baudrate to 10Mbit or more.

Before any other test on chip try to read a status register, the only register that boot value is more than 0 (check the boot value on datasheet), if you read something different to 0 o ff your vs1003 probably understang you so try other commands or a sine test.

Also check the DREQ pin, if it's low one second after boot, probably you have an hardware problem.

Bye
Giomm
rajshek_2010



Joined: 24 Nov 2005
Posts: 5

View user's profile Send private message Send e-mail Yahoo Messenger

thanks
PostPosted: Sat Oct 18, 2008 9:57 am     Reply with quote

thanks a lot giom. You are absolutely correct. We wrote our own spi instead of PIC h/w spi. The chip started working perfectly.

But now the issue is too slow for us. I need to use the H/W spi of PIC.
Will try setting the CLOCK>50Mhz and let you knw.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group