WM8960 sound slightly faster

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

WM8960 sound slightly faster

Jump to solution
583 Views
Burjak
Contributor III

Hi, I'm using MIMXRT1170-EVK, need a few tips for setup WM8960 driver. 

I built an application that read wav file from the SD card and played it. Used two examples from SDK: 
- filex_sdcard
- sai_edma_transfer
So basically base is filex_sdcard, added shell and configuration file from sai_edma_transfer. 

System run with "beep-sound" from sai_edma_transfer, but not closing SAI, without this codes:

 

    /* Once transfer finish, disable SAI instance. */
    SAI_TransferAbortSendEDMA(DEMO_SAI, &txHandle);
    SAI_Deinit(DEMO_SAI);

 

After that, I'm executing the command to mount the SD card. (R136 not welded, so I bypassed it by command). And when it is ready I run the command to read+play wav file from SD Card.

I attached the file with the main function and configuration, it's almost the same. Except configuration changed to try play 44.1KHz audio. And .mex file that I'm using to configure pins and clocks. 

This is my problem: I loaded a metronome 60BPM audio track and when it plays I get ~65BPM frequency. 

 

#define DEMO_AUDIO_MASTER_CLOCK 6144000U
#define WM8960_I2C_ADDR 0x1A
#define BOARD_CODEC_I2C_INSTANCE             5U
#define BOARD_CODEC_I2C_CLOCK_FREQ           (24000000U)

wm8960_config_t wm8960Config = {
    .i2cConfig = {.codecI2CInstance = BOARD_CODEC_I2C_INSTANCE, .codecI2CSourceClock = BOARD_CODEC_I2C_CLOCK_FREQ},
    .route     = kWM8960_RoutePlaybackandRecord,
    .leftInputSource  = kWM8960_InputDifferentialMicInput3,
    .rightInputSource = kWM8960_InputDifferentialMicInput2,
    .playSource       = kWM8960_PlaySourceDAC,
    .slaveAddress     = WM8960_I2C_ADDR,
    .bus              = kWM8960_BusI2S,
    .format           = {.mclk_HZ    = 6144000U,
               .sampleRate = kWM8960_AudioSampleRate44100Hz,
               .bitWidth   = kWM8960_AudioBitWidth16bit},
    .master_slave     = true,
    .masterClock =
        {
            .sysclkSource = kWM8960_SysClkSourceInternalPLL,
            .sysclkFreq   = DEMO_AUDIO_MASTER_CLOCK,
        },
};

 

Can I get a few tips on how I should configure the codec for the playback 44.1KHz files? 
P.S. I can attach the whole project if needed. 

0 Kudos
1 Solution
574 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

First of all, sorry for the later reply.

MCUXpresso SDK for RT1170 already provides some audio demos with below WM8960 setting:

Hui_Ma_0-1662533956264.png

The difference with MCLK setting and under above code is auido_pll config code:

Hui_Ma_1-1662534032343.png

I checked your wm8960 setting with MCLK frequency is : 

.mclk_HZ    = 6144000U,

If there without change the external clock source (24MHz crystal), audio Pll could not provide a accuracy MCLK as setting.

I am thinking if that could be the root cause.

Thanks for the attention.

Mike

View solution in original post

1 Reply
575 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

First of all, sorry for the later reply.

MCUXpresso SDK for RT1170 already provides some audio demos with below WM8960 setting:

Hui_Ma_0-1662533956264.png

The difference with MCLK setting and under above code is auido_pll config code:

Hui_Ma_1-1662534032343.png

I checked your wm8960 setting with MCLK frequency is : 

.mclk_HZ    = 6144000U,

If there without change the external clock source (24MHz crystal), audio Pll could not provide a accuracy MCLK as setting.

I am thinking if that could be the root cause.

Thanks for the attention.

Mike