Content originally posted in LPCWare by jaguarondi on Mon Feb 15 08:43:07 MST 2010
Well, I've the RDB1768 development board and the first example I've been working on is "RDB1768cmsis_AudioMeter".
I have to say that I'm quite afraid when I see that. Basically it works, I compile and executes, audio is looped from line-in to line-out and level meters are displayed. Tuning it was a real nightmare, I couldn't get anything I2S work as expected until I realized most of the code is completely wrong.
First the I2C module isn't correct at all, the ACK/NACK management is wrong in both read and write functions. The result was that the audio codec was never programmed as it should have been. As the codec was in default master mode, it is generating the I2S clock that the LPC tries to override by also generating it. This explains why changing registers on the I2S peripheral didn't work like expected. On the example, values for I2S peripheral seem to have been chosen by trial and error until something works. They're wrong but just work on the faster clock from the codec.
The codec is right justified by default while the code and comments say it's I2S so there are some obscure shifts added to deal with the right justified data received why obviously in I2S the shifts shouldn't be there.
In the end, I had to correct the I2C module, then configure the codec correctly (values in the example are not correct) and read/write the I2S data as it should.
I must admit that I'm quite afraid reading some other code from the examples when I see how wrong this one was. Any experience?
Thank you
David