11 Replies Latest reply on Mar 16, 2017 10:58 AM by SpiderKenny

    I2C and WM8731 Codec Board (MIKROE-506)

    joe_nasti

      i2cdetect cannot detect codec board with i2cdetect on either I2C-1 or 6 via:

      a) mini-breakout board + usb cables for power/console + bi-directional/i2c friendly level shifters (tried both Sparkfun and Adafruit) = empty i2cdetect table

      OR

      b) Sparkfun I2C block (includes level shifters) + Sparkfun Base block (for power/console via usb cables) = "lost arbitration" messages which I haven't spent much time looking into

       

      I am trying to dust off all of Sergey's audio related work (blog, forum post) and get Edison working with a MikroeElektronika's Audio Codec Proto board (MIKROE-506) that is based off of the WM8731 (datasheet).  Edison should be communicating to the Codec board via I2C for control and SPI for data.

       

      I have verified the codec board works by hooking it up to an Arduino Uno like this project here, which uses both I2C and SPI. I can hear the sine tone from the example with the headphones. Using the Arduino Wire library, I scan the Arduino I2C bus and it always find the codec board.

       

      Other things I've tried to rule out anything:

       

      - I2C on Edison w/mini-breakout with and without level shifters can i2cdetect other I2C sensors (e.g. MCP4725 DAC)

      - Edison + Sparkfun Base Block + Sparkfun ADC block can i2cdetect

      - Sparkfun Bus Pirate can always find the codec board with it's I2C 7bit address brute force search in any setup I've tried above in this post (found using both 100khz and 400khz I2C speed)

      I2C>(1)

      Searching I2C address space. Found devices at:

      0x34(0x1A W)

      - Bus Pirate I2C Sniifer when I run i2cdetect looks ok but there is nothing found by i2cdetect back on Edison:

      I2C>(2)

      Sniffer

      Any key to exit

      [0x07-[][0x09-[][0x0B-[][0x0D-[][0x0F-[][0x11-[][0x13-[][0x15-[][0x17-[][0x19-[][0x1B-[][0x1D-[][0x1F-[][0x21-[][0x23-[][0x25-[][0x27-[][0x29-[][0x2B-[][0x2D-[][0x2F-[][0x31-[][0x33-[][0x35-[][0x37-[][0x39-[][0x3B-[][0x3D-[][0x3F-[][0x41-[][0x43-[][0x45-[][0x47-[][0x49-[][0x4B-[][0x4D-[][0x4F-[][0x51-[][0x53-[][0x55-[][0x57-[][0x59-[][0x5B-[][0x5D-[][0x5F-[][0x61-[][0x63-[][0x65-[][0x67-[][0x69-[][0x6B-[][0x6D-[][0x6F-[][0x71-[][0x73-[][0x75-[][0x77-[][0x79-[][0x7B-[][0x7D-[][0x7F-[][0x81-[][0x83-[][0x85-[][0x87-[][0x89-[][0x8B-[][0x8D-[][0x8F-[][0x91-[][0x93-[][0x95-[][0x97-[][0x99-[][0x9B-[][0x9D-[][0x9F-[][0xA1-[][0xA3-[][0xA5-[][0xA7-[][0xA9-[][0xAB-[][0xAD-[][0xAF-[][0xB1-[][0xB3-[][0xB5-[][0xB7-[][0xB9-[][0xBB-[][0xBD-[][0xBF-[][0xC1-[][0xC3-[][0xC5-[][0xC7-[][0xC9-[][0xCB-[][0xCD-[][0xCF-[][0xD1-[][0xD3-[][0xD5-[][0xD7-[][0xD9-[][0xDB-[][0xDD-[][0xDF-[][0xE1-[][0xE3-[][0xE5-[][0xE7-[][0xE9-[][0xEB-[][0xED-[][0xEF-[]

      - Pull up resistors - I've tried combinations of 1k external pullups and/or modifying the internal ones (here) in the /sys/kernel/debug/gpio_debug/gpio*

      - Also have tried various gpio export/etc as mentioned in the I2C section of the Edison Arduino Board guide (even though I do no have that board)

      - Tried configuring Edison I2C speeds (default was 'fast', but tried 'std' with no luck, WM8731 should support up to fast/400khz)

      - Wrote test C programs using the MRAA library to try to 'talk' to this codec board with no luck

       

      I feel like the only things I haven't tried is to either get the Arduino breakout board and/or power the mini-breakout board via external power supply. My I2C SDL/SCL lines at their longest are 40cm (2x20cm, connecting thru level shifter).

       

      I reached out to Sergey (SergeyK) directly and he never did connect up Edison to this codec board. He re-used his own custom audio board (which I am shopping around from different PCB/A places). In the post, he mentions hooking up multiple power supplies to the codec board, which is only necessary if you're not using level shifters. He was a great help and gave fast, detailed replies to my emails but troubleshooting something funky like this wasn't going to get done over email.

       

      Thanks for any help,

      Joe

       

      Using default firmware

      root@edison:~# uname -a

      Linux edison 3.10.98-poky-edison+ #1 SMP PREEMPT Mon Jun 6 14:32:08 PDT 2016 i686 GNU/Linux

        • 1. Re: I2C and WM8731 Codec Board (MIKROE-506)
          vinu_gk

          Hi joe_nasti,

           

          The WM8731 doesn't respond to i2cdetect commands. I think its mentioned in the datasheet that the device is write only. I had the same issue before.

           

          regards,

          Vinu

          1 of 1 people found this helpful
          • 2. Re: I2C and WM8731 Codec Board (MIKROE-506)
            joe_nasti

            Well now things are making some sense. I knew it had to be something obvious! I had tried i2cget commands also, but that'd be doing the same thing (trying to READ)...Thanks vinu_gk!

             

            The datasheet does say:

            The WM8731/L is a write only device and will only respond to the R/W bit indicating a write.

            If WM8731 only supports write requests, I did try the i2cdetect -q option but Edison i2c does not support SMBus Quick Write. I'm not sure there is anything else to try there with that command. I guess i2cset commands will tell me if the codec is connected and powered correctly.

             

             

            When I try to run Sergey's i2cset commands to initialize, it's a bit flaky where some work and some don't. I believe this has something to do with the high voltage levels that are coming from my level shifters. The WM8731 can only handle 3.6V and my scope is telling me I can peak that pretty easily. That being said, I still cannot hear audio playback with my headphones - no matter turning the volume all the way up (0x7f).

             

            In another thread (https://communities.intel.com/thread/111754), SpiderKenny suggests I rebaseline my firmware to Sergey's old one. I will have to give that a try...but in the meantime, does anyone know what could have changed with the audio subsystem or the dummy codec or something from firmware edison-src-ww18-15.tgz to iot-devkit-prof-dev-image-edison-20160606-patch.zip besides maybe the IoT stuff on top?

            • 3. Re: I2C and WM8731 Codec Board (MIKROE-506)
              joe_nasti

              I've been exchanging posts with SpiderKenny in his thread that I referred to earlier (Fixed: The current yocto image build for Edison ).

               

              I rebuilt the firmware image off ww18-15 with Sergey's WM8731 patch and enabled it in the boot param 'audio_codec_name'. After configuring the ALSA settings, I feel like I'm closer but still not operational.

               

              Here's my latest post there (https://communities.intel.com/message/457392#457392), the whole thing is flaky. Some boots will complain of the -517 error, while sometimes it will complain of the -121 error....BUT then there are times where it DOES NOT COMPLAIN. I can actually use aplay or mpg123 to play to hw:1,0 (default:CARD=wm8731audio) - but I do not hear any audio from the codec board 3.5mm headphone jack. So software thinks it's working, but hardware doesn't seem to be.

              • 4. Re: I2C and WM8731 Codec Board (MIKROE-506)
                joe_nasti

                Thanks to several people offline (SergeyK, SpiderKenny, vinu_gk, squaredn) - I finally was able to play audio (still need to test recording). The bottom line is I should've 'listened' to the blogs and posts exactly before insisting I should be able to connect this another way. Level shifters DO NOT work here no matter what I tried - you HAVE to use different power supplies from Edison to power the WM8731 chip.

                 

                The solution? Use a combination of both of Sergey's posts (one, two)

                SW:

                - I rebuilt the firmware image off ww18-15 with Sergey's WM8731 patch and enabled it in the boot param 'audio_codec_name'.

                - Using AlexT's repo, install mpg123 and download a sample mp3 like the one from here

                 

                HW:

                - Modify the codec board like this picture (thanks squaredn!). This isn't my picture, I broke off the top of the inductor trying to cut/lift the L2 leg. It's a little flaky playing the audio but it works. Sergey told me I could remove the inductor if I needed to get more reliable but this inductor is in a circuit to improve audio quality. I need to test with and without it to see what I'm going to do for my situation.

                Modified Codec.jpg

                1 of 1 people found this helpful
                • 5. Re: I2C and WM8731 Codec Board (MIKROE-506)
                  SpiderKenny

                  Good work @joe_nasti

                   

                  I avoided using level shifters by running the WM8731 at 1.8 V for all the I/O

                  -Kenny

                  • 6. Re: I2C and WM8731 Codec Board (MIKROE-506)
                    joe_nasti

                    SpiderKenny, I know the WM8731 datasheet on page 6 says DCVDD/Core typically runs at 1.5V - but it can support 3.6V MAX! I figured this is what MikroElektronika was reading too when they designed the board the way they did - only one VCC pin of 3.3V. What is this newbie missing? Level shifters should have worked??? I'll take the win here, but have to get to the bottom of why these didn't work.

                    • 7. Re: I2C and WM8731 Codec Board (MIKROE-506)
                      SpiderKenny

                      I tied pin 1 and 27 to 1.8 V and pin 14 to +3v3 (for audio)

                      But you are right that Level shifters should have worked.

                      Which ones did you use?

                       

                      (I've found that the Edison  uses  weak pull-ups and the type of level shifters which don't need a direction pin get confused with which direction to pass the signals.

                      For example on an RS232 port I was using the internal pull up of the Receive line in an FTDI CMOS Cable was strong enough to make the level shifter to think that the line was input rather than output.)

                      • 8. Re: I2C and WM8731 Codec Board (MIKROE-506)
                        joe_nasti

                        I'm surprised you didn't also put pin 8 to +3v3 HPVDD, it also is listed as an 'Analogue Supply' in that same table I reference on page 6.

                         

                        I tried two bi-directional sets from Adafruit (https://www.adafruit.com/product/757) and Sparkfun (https://www.sparkfun.com/products/12009).

                         

                        Did you even try to manipulate the Edison internal pull-ups via command line (e.g. Using Edison internal pull up/down resistors ) like it says in the Arduino Breakout guide? (I don't have the Arduino Breakout for Edison, but it has a lot of good reference info there). The internal pull ups can be configured as 2, 20 or 50 kohm (w/I2C pins capable of 910 ohms). I only ever tried adding external resistors (only tried 2.2kohm I think) on the I2C SDA and SCL lines thru the level shifters. I never tried any other lines or stronger resistors.

                         

                        There was this Arduino <-> Codec Board project on Github (https://github.com/soundspotter/ArduinoUNO_AudioCodecMikroe506). This is what I used to verify my codec board worked. Now that I got things working with Edison, I referenced back to the project. He has you hook up 220ohm series resistors between the ADC/DACLRC lines. Do you think this is the combination of pins and resistor strength to use Edison w/Codec Board as-is? I am still learning the actual math/etc behind all of this circuitry.

                        • 9. Re: I2C and WM8731 Codec Board (MIKROE-506)
                          SpiderKenny

                          joe_nastiTurns out I just forgot to mention pin 8 :-)

                          Here's a partial schematic of my board:

                          Screen Shot 2017-03-16 at 09.15.12.png

                           

                          And an image of the actual board:

                          (Forgive the crude hand soldering - this was a prototype hand built by me, including hand soldering the 70 Pin header!)

                          Screen Shot 2017-03-16 at 09.17.58.png

                          • 10. Re: I2C and WM8731 Codec Board (MIKROE-506)
                            joe_nasti

                            Thanks for sharing, Kenny...I really need to step my soldering game up for those fine-pitched parts....any secret for getting the 70-pins connected and verified working?

                            • 11. Re: I2C and WM8731 Codec Board (MIKROE-506)
                              SpiderKenny

                              joe_nasti Yeah - I clean the pads with isopropyl alcohol, then put a small amount of solder on one corner pad. (eg, pad 1)

                              I then slide the part into place, and solder down the one pad. Don't worry at this stage if you short it to neighbouring pads. Then align the part and solder the diagonally opposite pad. (eg, pad 70).

                              Then put some good quality flux all over all the pads. Drag a small blob of molten solder along all the pads. Using flux and a clean soldering tip you can wick away any shorts. Use a microscope or magnifying glass to check the connection.

                               

                              This works well for me, the magic is the flux, it helps keep the solder going only where it is mean to. The flux in multi-core solder won't do it. You can use multi-core solder, but you'll still need extra flux. I use a gel-type tacky flux rather than a liquid flux pen.

                              1 of 1 people found this helpful