Recently, a project to use the codec chip to do voice acquisition and output, the driver is used stm32f405 I2S interface. Prior to not in-depth knowledge of i2s, but probably know that it is a bus for the transmission of audio data. Originally thought there is no difficult, actually use down actually also did not feel has anything special. But still in the process of use to put yourself in a hole.
Codec chip model is MAX9867, the main applications are mobile phones and hearing aids and the like. To implement STM32-driven code I first was to see the MAX9867 data, codec chip information did not say whether to support the Philips agreement I2S, only the timing diagram of each configuration is expressed. The timing of my configuration is shown in the following figure:
Then continue to see if the STM32 Manual has a communication configuration that matches this timing, there are 4 types of communication protocols supported by STM32.
We see that the two timing diagrams represent different methods, one is the rising edge latch data, one is the falling edge to change the data, but the essence is the same. The left channel is then in front, and the left channel is indicated with a low level. Since the clock polarity and channel control are the same, and this configuration is the default configuration of the codec chip, but also the first configuration of STM32. Then I configured the codec chip and the STM32 driver in this way, and also realized the function of Mic sound acquisition and playing through the horn. I certainly do not think there is any problem with communication because it is not possible to collect and play the voice data if there is a problem.
But after the problem came, due to play mic collected sound has a noise, in order to locate the problem where I saved a fixed voice in Flash with codec to play. As a result, the sound is basically covered by the noise, and the output audio signal is very cluttered with the oscilloscope. But the same voice data on ST's official Development Board to play is very pure music sound. I can't understand the problem, I don't know how to solve it.
Finally, with the help of colleagues to check the manual, it was found that the timing of codec and STM32 timing is not a match. We can see that the Philips protocol the first clock on the rising edge of the latched data is invalid, while the codec chip's first rising edge latch data is valid. This causes the STM32 to transmit to the codec the highest bit of data will be lost, but in the same mic acquisition and playback process due to the acquisition and playback of the protocol is matched, so the voice is only the last one is lost, and will not cause great loss of sound data.
Now that the problem has been found, then you must refuse it. We see that the STM32 supports a protocol named MSB for its standard, and we see that the timing diagram and the COEDC timing diagram are exactly matched. Modify the configuration of STM32, play voice data, sound output perfectly.
This lesson is still relatively profound, in the future encounter this time series is not familiar with the protocol must be carefully read the manual, to the timing of the agreement fully understand
Turn from:
: Http://blog.csdn.net/yedapeng2011/article/details/77075031?reload