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~
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
Hi Eddie,
Have you had any luck implementing this method?
Best regards,
Martyn
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
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