A short while ago I wrote about a small module that I wrote to support the Audio Codec chip present on the Mikromedia (PIC24) boards (link). What I had not noticed though was that I had been playing at home with a beta version of the board (provided very early on by the Mikroe team) while the production release rev 1.1 had departed just a little bit from the original design and used only one different component. Do you want to try and guess which one? Of course, the audio codec!
The new Mikromedia boards use the much improved, omni-capable, universal… VS1053 from VLSI technology. You can now play not only MP3 files, but also WMA, WAV and even Ogg Vorbis files, no sweat!
The device data sheet, states that the communication interface is absolutely backward compatible so when I discovered the change I felt absolutely confident it was going to be a minor update if any was required at all! Yeah right…
To spare you the excruciating 6 hours of debugging that followed, here are the key lessons (re-)learned:
- Read the frigging manual (schematic) first. It took me several hours of failing attempts at playing back various songs at different bit rates to realise that something had to be different in the clock of the device. Sure enough it was clearly documented right there in front of me. The crystal used had changed from 25MHz to 12.288MHz which requires setting the CLOCKF register with a non-default value to enable a doubling of the crystal input freq.
- And then read it again. My only excuse is that the new Mikromedia User guide was printed in a smaller format using smaller fonts as well. So I did not notice that the XCS and XDCS signals had been re-assigned to new pins. Though quickly fixing the new values (RA7 and RG12) in the HardwareProfile.h brought no joy yet.
- Don’t rush it! A consequence of #1 is that after each reset now the chip is actually “slow” or at least slower than the PIC24 it is attached to. As a consequence the SPI port needs to start with a greater pre-scaler value applied (1:8) and only later, after the CLOCKF register has been safely written to, the speed can be bumped back up to 1:2 or even 1:1.
- Don’t rush it, I said! It just happens that RA7 was used (on other Multimedia board models featuring a mini-SD card connector) as the SD_WP input signal. Mikromedia boards use a micro-SD connector instead so I ignored the overlap assuming it would not matter. Except it does! Everything seemed to work as long as I was not using the SD card interface to read an audio file from. In fact the SD_WP is always configured as an “input” as soon as FSInit() is called, while XDCS must be configured as an “output” to drive the codec correctly.
The end result is a new module dedicated to the VS1053 codec and a properly redefined HardwareProfile to match the Mikromedia v1.1.