Skip to main content
Matti Sillanpaa
Associate III
Oct 16, 2017 12:38 PM UTC
Question

24khz audio output

Posted on October 16, 2017 at 14:38

Hi.

I'm trying to output 24khz mono pcm data over SAI to wm8994 codec. 16khz mono seems to work OK, but 24 is not supported by ST by default. I've made some changes for the support to codec and sai init. Now I wonder what else needs to be changed.

As baseline I've let the clock configurators use same clock paths as 48khz (44 vs 48 khz domains). Slot number and stereo mode from sai perspective is also handled in SAI init:

if (channels == 1) {

   haudio_out_sai.Init.MonoStereoMode = SAI_MONOMODE;

   haudio_out_sai.SlotInit.SlotNumber = 2;

}else {

   haudio_out_sai.Init.MonoStereoMode = SAI_STEREOMODE;

   haudio_out_sai.SlotInit.SlotNumber = 4;

}

in wm8994.c -> init function I added 24khz selection to output path according to cirrius wm8994 spec (v.4.5).

case AUDIO_FREQUENCY_24K:

   /* AIF1 Sample Rate = 24.000 (KHz), ratio=256 */

   counter += CODEC_IO_Write(DeviceAddr, 0x210, 0x0053);

break;

CubeMX doesn't give the option to configure the SAI into 24khz mode. Is there some limitation or is this just left out? is there any other things I should consider when enabling the 24Khz mode?

#stm32f769i-disco-audio-wm8994
This topic has been closed for replies.

1 reply

Matti Sillanpaa
Associate III
Oct 17, 2017 12:26 PM UTC
Posted on October 17, 2017 at 14:26

Ok, the changes were OK and works with 24khz wav.

Problem is my mp3 decoding. It seems to have lot of distortion.