VS1053 Too high speed of audio

Writing software for systems that use VLSI Solution's devices as slave codecs to a host microcontroller.
Post Reply
GiovanniD91
User
Posts: 2
Joined: Thu 2024-07-04 22:28

VS1053 Too high speed of audio

Post by GiovanniD91 »

Hi everyone,
i have some issues with VS1053. I have PIC24 with SPI (7 wire) started at 320kHz. I switch the frequency of SPI at 1MHz after setting the CLOCKF register. I have implemented mem test, register test, SDI and SCI sinusoidal tests, and they works well. Hovewer, when i try to play a MP3 files, the audio output is too fast. I check the DREQ when i write and read register and when i send data of audio file. In attached image, i show you that after DREQ is high I send the data via SPI.
So, what is the problem. Why the play audio is too fast??
Anyaone can help me?

Code: Select all

// <editor-fold defaultstate="collapsed" desc="Public Function"> 
int8_t vs1053_init_firmware(void) 
{
    uint16_t temp_reg = 0;
    uint16_t temp_reg2 = 0;
    uint8_t temp_data[32];
    memset(temp_data, 0x00, 32);

    temp_reg = SM_INIT_VAL | SM_RESET;
    vs1053_write_register(VS1053_REG_MODE, temp_reg ); 
    __delay32(DELAY_10MS);
    vs1053_write_data(&temp_data[0], 32);
    
    temp_reg = SM_INIT_VAL;
    temp_reg2 = vs1053_read_register(VS1053_REG_MODE);
    if( temp_reg2 != temp_reg )
    {
        return VS1053_KO;
    }

//     Set clk
    temp_reg = HZ_TO_SC_FREQ | SC_MULT_VS1053_35X | SC_ADD_VS1053_00X;
    vs1053_write_register(VS1053_REG_CLOCKF, temp_reg);
    while(AUDIO_DREQ_GetValue() == DREQ_UNREADY)
    { 
        __delay32(DELAY_6US);
    };
    if( vs1053_read_register(VS1053_REG_CLOCKF) != temp_reg )
    {
        return VS1053_KO;
    }       
    __delay32(DELAY_500MS);
    
    spi_speed_high();
    __delay32(DELAY_100MS);
     
    // Set volume
    temp_reg = 0x29;
    vs1053_set_volume(temp_reg);
    __delay32(DELAY_10MS);
    temp_reg2 = vs1053_read_register(VS1053_REG_VOL);
    if( temp_reg2 != 0x2929 )
    {
        return VS1053_KO;
    }    
    
    temp_reg2 = vs1053_read_mem(PAR_MONO_OUT);
    if( temp_reg2 == 0)
    {
        vs1053_write_mem(PAR_MONO_OUT, 1);
        __delay32(DELAY_10MS);
        temp_reg2 = vs1053_read_mem(PAR_MONO_OUT);
        if(temp_reg2 == 0)
        {
            return VS1053_KO;
        }
    }
    
    
    temp_reg2 = vs1053_read_register(VS1053_REG_AUDATA);
    temp_reg = 0xBB80; //48KHz mono (stereo 0xbb81)
//    temp_reg = 0x1F40;
    vs1053_write_register(VS1053_REG_AUDATA, temp_reg);
    __delay32(DELAY_100MS);
    temp_reg2 =  vs1053_read_register(VS1053_REG_AUDATA);
    if( temp_reg2 != temp_reg )
    {
        return VS1053_KO;
    }       
    __delay32(DELAY_100MS);
      
    return VS1053_OK;
}
DREQ (RED) SPI CLK (BLUE)
DREQ (RED) SPI CLK (BLUE)
immagine_2024-07-05_160748732.png (2.79 KiB) Viewed 41 times
User avatar
pasi
VLSI Staff
Posts: 2144
Joined: Thu 2010-07-15 16:04

Re: VS1053 Too high speed of audio

Post by pasi »

Is the audio also playing with a higher pitch, or is there parts of it missing?
What does SCI_DECODETIME show? Does it advance once per second?

What is the actual value written to SCI_CLOCKF? What is your crystal? For 12.288MHz crystal, 0x9800 is a good default value for SCI_CLOCKF.
Visit https://www.facebook.com/VLSISolution VLSI Solution on Facebook
Post Reply