Kinetis I2S volume control

cancel
Showing results for 
Search instead for 
Did you mean: 

Kinetis I2S volume control

1,865 Views
eddiec
Contributor II

Hi!

Is there any solution can help me control I2S output volume on my mk10fn1m0? I search all the library and driver only found clock control register.

Thanks~

Labels (1)
Tags (2)
5 Replies

659 Views
martynhunt
NXP Employee
NXP Employee

Hi Eddie,

Volume control is usually done by the audio codec, or software.

Usually volume control is done through the I2C bus that the Codec and microcontroller share. The datasheet for your codec of choice should have an example on what registers to write to in order to change the volume level.

A simple way to reduce the volume with software is to divide it by bit shifting the I2S data to the right before transmitting. For example:

newWav = wavPtr[soundIndex] >> 2;

Be sure to that your compiler will keep track of the sign bit (if you are using signed data, most 16-bit audio data is signed). Otherwise you may get some very unpleasant sounds.

Best regards,

Martyn

659 Views
eddiec
Contributor II

Hello Martyn,

Thank you very much, I also think this method works but not sure, I'll tried it and report back! :smileyhappy:

With regards,

Eddie

0 Kudos

659 Views
martynhunt
NXP Employee
NXP Employee

Hi Eddie,

Have you had any luck implementing this method?

Best regards,

Martyn

0 Kudos

659 Views
eddiec
Contributor II

Hello Martyn,

Sorry for my late reply!

I am building my platform and met some clock setting problem, my board is K60F120M with our own CODEC board connected by wire, I'll do the test after setting up.

With regards,

Eddie

0 Kudos

659 Views
eddiec
Contributor II

Hello Martyn,

We have TWR-K60F120M(Rev.C ) and TWR-AUDIO-SGTL, and my system are CW10.5 and MQX4.1.0.

I test the example under mqx called "sai_dma_demo", after I change CLK_MULT from 384 to 256, then I can play and record 48kHz/16bit sound now, but when I play 48kHz/24bit wav file, the system goes wrong, datasheet says it can support up to 32bit.

May I ask you~
1. How can I test 48kHz in 24 bit correctly?

2. Where is the I2S data I can shift to control the volume in this demo code?

Any help will be appreciated!

Best regards,

Eddie

0 Kudos