1 2 Previous Next 27 Replies Latest reply on Aug 19, 2015 9:52 AM by Intel_Peter

    Driver for WM8731 codec

    Sriranjan

      I want to write a library for the WM8731 with intel edison.The following are needed.

      1)Timer to external clock and ISR on that

      I saw a Timer interrupt example in the edison folder

      2)Wire.h (I2C to configure the WM8731 codec but when I include Wire,h I get an error saying no such file or directory.I dug through the edison folders and found that wire.h is there in it.)

      3)SPI (with a custom slave select pin flipping at 44,8,2, or 88Khz).

       

      Please let me know how shall I move forward. I do not want to use the Dummy codec or I2S driver (as I could not get much help on it.I already developed a library for another micro controller and I am through over how to implement it using Wire,SPI and Timer interrupts but I do not know the specifics on Edison).

        • 1. Re: Driver for WM8731 codec
          Sriranjan

          So how do I capture an external clock as a timer interrupt on the Edison? And at what maximum baud rate can the edison operate on its Rx,Tx pins?

          • 2. Re: Driver for WM8731 codec
            Intel_Peter

            The interrupts on Edison aha been discussed on other threads. I suggest you to read the following threads:

             

            Re: Timer Interrupts in Intel Edison

            Edison Interrupt Service Routine

            Edison ISR

             

            Peter.

            • 3. Re: Driver for WM8731 codec
              Sriranjan

              I read the posts. Using MRAA lib and C code it is possible to attach to an external interrupt on rising ,falling or both edges. I want to do it in arduino IDE. One guy mentioned that using arduino IDE he was able to use external interrupts but I do not know if used MRAA lib in the IDE.I do not know if MRAA lib can be used in the arduino IDE.I think you cannot use it then in that case how did he ("madhura" Edison ISR ) used external interrupts in the IDE? Also I want my frequency of the ISR be like freq/div. I want to use an external clock of 11.111111mhz as the interrupt and the ISR should run at 44khz which is 11111111/256. How do I do this in the arduino IDE?

              • 4. Re: Driver for WM8731 codec
                Vincenze

                There is a driver on Sergey's page about his DAC based on WM8731:

                http://www.malinov.com/Home/sergeys-projects/audio-block-for-intel-edison

                This patch adds a driver into Linux: edison-wm8731.patch

                He wrote how to compile it in in the Linux image.

                 

                I haven't tried to connect a DAC to Intel Edison, but here is the theory of the operation:

                1. You run the driver for Intel Edison that outputs digital signals via the I²S bus. You can use the dummy driver which manages the I²S signal through 3 output lines plus 1 input line. The format is 3-wire PCM DSP format, 24-bit, 48000 samples per second. Essentially, you need a DAC that supports this format through 3 wires (many want 4 wires that include the  MCLK signal).

                2. You use SPI or I²C to configure WM8731 using the same format: slave, PCM DSP format, 24-bit, 48000 samples per second..

                Sergey shows a simple I²C configuration script here:

                Intel Edison - Simple I2S Audio Setup - Malinov Family Web Presence

                3. You run an MP3 player through the configured dummy driver.

                 

                I don't understand why you want to use Arduino interrupts.

                Are you trying to use a slow software solution instead of the built-in hardware?

                 

                The Linux kernel already has a driver for WM8731, you can try to modify it.

                Linux drivers for Wolfson devices | Open Source at Wolfson Microelectronics

                • 5. Re: Driver for WM8731 codec
                  Sriranjan

                  I am able to configure the WM8731 codec using Wire.h (i2c) commands but I am not able to track an external interrupt which runs at 11Mhz.I actually need to track the external interrupt clock at 11Mhz/256 (= 44 khz audio sampling rate) etc. So is there a way to access quark's functionality for external interrupts with some C code rather than the high level arduino code. I am able to track an interrupt which runs at 2 hz or so but not at high speed like 11mhz/256. When I developed a driver for Arduino Due for the same codec I had to skip the high level code and code it in C to get the desired performance. So I want to know like instead of using the arduino commands is it possible to do some low level coding for the Quark for tracking external interrupts, doing SPI transfers and setting pins high or low at high speeds. It was possible with the ARM3X8E on the Arduino Due.I want to do the same here.

                  • 6. Re: Driver for WM8731 codec
                    Sriranjan

                    I am able to configure the WM8731 codec using Wire.h (i2c) commands but I am not able to track an external interrupt which runs at 11Mhz.I actually need to track the external interrupt clock at 11Mhz/256 (= 44 khz audio sampling rate) etc. So is there a way to access quark's functionality for external interrupts with some C code rather than the high level arduino code. I am able to track an interrupt which runs at 2 hz or so but not at high speed like 11mhz/256. When I developed a driver for Arduino Due for the same codec I had to skip the high level code and code it in C to get the desired performance. So I want to know like instead of using the arduino commands is it possible to do some low level coding for the Quark for tracking external interrupts, doing SPI transfers and setting pins high or low at high speeds. It was possible with the ARM3X8E on the Arduino Due.I want to do the same here.

                    • 7. Re: Driver for WM8731 codec
                      Sriranjan

                      I am looking at this page

                      http://www.malinov.com/Home/sergeys-projects/audio-block-for-intel-edison

                      How do I get the data into my code (like left_in and right_in variables with the codec data in my code)?

                      • 8. Re: Driver for WM8731 codec
                        Sriranjan

                        The only hurdle that is stopping me right now is the question : "How do I track an external interrupt at 11Mhz/256 frequency using the Edison and this timing should drive the ISR"?

                        • 9. Re: Driver for WM8731 codec
                          Sriranjan

                          The following code which uses timeinterruptone.h is not at all reliable.

                           

                               #include <TimerOne.h>    

                               int myi=0;

                               bool ledon=0;

                               void setup()

                               {

                                 // Initialize the digital pin as an output.

                                 // Pin 13 has an LED connected on most Arduino boards

                                 system("echo 40 > /sys/class/gpio/export");

                                 pinMode(13, OUTPUT);   

                                 Serial.begin(9600);

                                 Timer1.initialize(4); // set a timer of length 100000 microseconds (or 0.1 sec - or 10Hz => the led will blink 5 times, 5 cycles of on-and-off, per second)

                                 Timer1.attachInterrupt( timerIsr ); // attach the service routine here

                               }

                          • 10. Re: Driver for WM8731 codec
                            Sriranjan

                            The gap between the peaks keep on changing .There should be some reliable method to handle timers,ISRs and external interrupts. I need support here.

                            • 11. Re: Driver for WM8731 codec
                              Sriranjan

                              IMG_20150811_141043.jpg

                              As you can see the gaps between the pin highs (pin high turned on and off in the ISR) keeps on changing. So managing an interrupt at a fixed frequency is not being possible.

                              • 12. Re: Driver for WM8731 codec
                                Sriranjan

                                Will the mraa.h give a better handling of interrupts?

                                • 13. Re: Driver for WM8731 codec
                                  Sriranjan

                                  I am getting a stable output at 125us delay and the peaks are equally space. This means I can get audio at 8Khz.

                                  IMG_20150811_144937.jpg

                                  • 14. Re: Driver for WM8731 codec
                                    Sriranjan

                                    I read the following from the interrupt.c in the core directory.

                                     

                                    * interrupt.c

                                    *

                                    * Provides a pseudo interrupt inteface which is broadly an analoge of the Arduino pin based interrupt

                                    * callback mechanism

                                    * We don't support 'real' interrupts from kernel to user-space right now since that's way out of scope

                                    *

                                    * Author: Bryan O'Donoghue <bryan.odonoghue@intel.com>

                                     

                                    So if the interrupts were managed at the kernel level would it be possible to track the 11Mhz/256 frequency signal?

                                    1 2 Previous Next