[ARM] MikroC SPI1, VS1053 and SDcard ?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Activity points
9,442
Guys,

I tried to play a file from SDcard on VS1053...on shared SPI1,

I've tested SDcard by itself and it's working then tested VS1053 alone and it's working....but when I combine, I can not hear anything,

Anything missing here ?

Thanks

Here's the function
Code:
/*******************************************************************************
* Function PlayMP3()
* ------------------------------------------------------------------------------
* Overview: Function runs mp3 example. Should be called frequently
* Input: Nothing
* Output: Nothing
*******************************************************************************/
void PlayMP3()
{

    unsigned long i;
    char str_file_size[22],str[22];
    char buff_size[22];


     //Init_FAT();
    //MP3_Init();
    current_file = FAT32_Open("sound.mp3", FILE_READ);
    //Debug file status
     IntToStr(current_file, str);
    UART_Write_Text("File status Line 219: \n");
    UART_Write_Text(str);
    UART_Write(CR);
    
    

  if (current_file >= 0 )
  {

    //TFT_Write_Text("3. File Opened", 90, 95);

    FAT32_Size("sound.mp3", &file_size);
    LongToStr(file_size, str);
    UART_Write_Text("Sound.mp3 size at start Line 231:\n");
    UART_Write_Text(str);
    UART_Write(CR);
    Delay_ms(500);
    
    Total_Buffers = file_size / BUFFER_SIZE;
    level = 0;
    MP3_Set_Volume(level, level);
    UART_Write_Text("3. File Opened\n");
                     while (file_size > BUFFER_SIZE)
                     {
                     
     //if(file_size > BUFFER_SIZE){     // while there is still data, send it to mp3 codec chip
                         //MP3_CS = 1;
                         //Mmc_Chip_Select = 0;
                        for (i=0; i<BUFFER_SIZE; i++)
                         {
                           Fat32_Read(current_file, mp3_buffer + i, BUFFER_SIZE);
                         }
                          UART_Write_Text("FAT32_Read Line 246!\n");
                         //Fat32_Read(current_fhandle, mp3_buffer,1);
                         //Mmc_Chip_Select = 1;
                         //
                         //MP3_CS = 0;
                        
                         //MP3_CS = 1;
                         //BSYNC = 0;
                        
                         //Delay_ms(1);
                          //UART_Write_Text("BSYNC = 0_Read Line 256!\n");
                         for (i = 0; i < BUFFER_SIZE / BYTES_2_WRITE; i++)
                         //for (i = 0; i < 32; i++)
                         {
                           MP3_SDI_Write_32(mp3_buffer + i*BYTES_2_WRITE);
                           //MP3_SDI_Write(mp3_buffer + i*BYTES_2_WRITE);
                           
                           // UART_Write(mp3_buffer[i]);
                         }
                        // UART_Write_Text("Song loop >BUFFER_SIZE..\n");
                         file_size -= BUFFER_SIZE;
                         LED = 1;

                         LongToStr(file_size, str);
                          UART_Write_Text("File size Line 286:\n");
                          UART_Write_Text(str);
                          UART_Write(CR);
                          Delay_us(10);

                     }
                       UART_Write_Text("file_size < BUFFER_SIZE will start, Line 272!\n");
                     while (file_size < BUFFER_SIZE)
                     {
                     //if(file_size < BUFFER_SIZE){     // finish playing file

                         Fat32_Read(current_file, mp3_buffer, file_size);

                         for (i = 0; i < file_size; i++){
                           MP3_SDI_Write(mp3_buffer[i]);
                          // UART_Write_Text("Song loop <BUFFER_SIZE..\n");

                         }
                         LED =0;
                         UART_Write_Text("file_size < BUFFER_SIZE has finished, Line 304!\n");
                     }

                     StopMP3_File();
   }
   else
   {
      UART_Write_Text("Failed opening file!\n");
   }
}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…