Forum Rule: Always post complete source code & details to reproduce any issue!
Page 4 of 4 FirstFirst ... 2 3 4
Results 76 to 99 of 99

Thread: Teensy3 I2S with DMA

  1. #76
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Italy
    Posts
    163
    Hey guys, I just wanted to let you know that I just ordered a Mikroelektronica Audio Codec board just like yours, as soon as I get it I will begin testing hyple's library along with USB audio streaming; the board looks like a nice starting point to debug most of the features I need for my project it also has line in/out not soldered to anything, so they are still useable! Sweet! While waiting for the codec board to be shipped, I'll try as hard as I can to finish all the modules for my audio adc/dac board, trust me I'm halfway through it I already finished the input type selector that is going to be used with an unbalanced guitar to balanced out board, also done already

  2. #77
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Italy
    Posts
    163
    Hello there, my Mikroe Audio Codec board just arrived; I'm trying the i2s_tx_dma_example but it is not working; of course I already set it to work with the Mikroe board by changing #IF 0 to #IF 1 at line 31. I also double checked the connections .... Anybody might know why?

    EDIT: Sorry, I don't know why but the headphone plug didn't like the fact that I plugged it too deep, it works flawlessly! I cannot wait to try this with my USB audio class
    Last edited by MickMad; 09-05-2013 at 06:58 PM.

  3. #78
    Quote Originally Posted by MickMad View Post
    I cannot wait to try this with my USB audio class
    So, when you plug your teensy 3 into a USB port, your computer will recognize the teensy as a USB Audio Device? And if so, will you then do isochronous transfers?

  4. #79
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Italy
    Posts
    163
    That's what I need to achieve. The big problem is that isochronous transfers are not yet implemented in teensyduino, and so there's some low level USB stuff to handle which is kinda painful. There's more info about this USB stuff on this other topic:

    http://forum.pjrc.com/threads/24014-...for-Teensy-3-0

  5. #80
    Thanks for the link. I'm sure many of us will be watching with great interest.

  6. #81
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Italy
    Posts
    163
    Hello guys, just a quick update:
    I opened a new github repo containing all the software AND hardware I'm currently working on to make a full USB Audio device out of a Teensy 3.0.
    I need to finish the USB-specific part first, and as soon as I get that right, I will start to integrate hyple's I2S library with USB. There's also some hardware stuff I'm doing that is complementary to the final design I'm trying to achieve.
    Here's the link: http://github.com/MickMad/Teensy3-USBAudio

  7. #82
    Hello,
    I revive this topic to ask some help about a project and some pins assignement
    but first a big thank you to MickMad for sharing the lib which gives a easy way to jumpin both DMA and I2S

    I d like to use the I2S receiver and transmiter separately with their own bitclock, fully assynchronous and both in slave mode.
    I thnk it is possible according to the chapter 3.9.5.2.2 which says: "The I2S/SAI transmitter and receiver support asynchronous bit clocks (BCLKs) that can
    be generated internally from the audio master clock or supplied externally"

    but there is still some mystery around MCLK, even if I dont need it in this project.

    well, in fact the goal is to receive an SPDIF signal in I2S from a DIR like CS8416 into a 1k FIFO Buffer, using DMA upon reception
    then the program will evaluate the frequency of this stream and will configure a digital oscilator over I2C, to generate the bitclock for outputing the data to a precise DAC via the I2S tranciever
    that's a precise-reclocker, this concept is well known and already exist in some FPGA implementation.

    One of my first question is about the pin out. I m lost on where are the 3+3 pins (receiver/transmiter) on the teensy3 layout, and if there is a (simple) solution to reroute them....
    in the datasheet they are called
    SAI_TX_DATA
    SAI_TX_BCLK
    SAI_TX_SYNC
    SAI_RX_DATA
    SAI_RX_BCLK
    SAI_RX_SYNC

    thank you

  8. #83
    in the meantime I found chapter 11.4.1 explaining that a port pin can be configured in alternative mode, and for example SAI_TX_BCLK could be sent to either pin number 27, 41 or 46 if they were configured respectively in Alternative 6, 4, 6

    my second problem is to understand how I could send the SAI_TX_CLK and SYNC to 4 different DAC not directly I2S compatible (AD1851) as they use a specific latch (LE) pin ... any thought welcome

  9. #84
    Junior Member
    Join Date
    Dec 2013
    Posts
    3
    Hey guys!

    I got an AudioCodecShield from Open Music Labs and tried to use it with my Teensy3 and the teensy-i2s library from this thread. I got it wired up and it kind of works, but there's a lot of clicking noise going on... lots of short impulses, quite hearable (I guess about -15db below the level of the music I'm passing through). I tried all of the examples that came with the library with the same result.

    Is this the current state or should it work without the noise? If so, what could I have done wrong? (I got the wiring from the examples and also replaced the mk20...h. Is there anything I forgot?

    Thanks a lot,
    Benni.

  10. #85
    Senior Member sumotoy's Avatar
    Join Date
    Nov 2012
    Location
    Venezia, Italia
    Posts
    421
    hello,
    just get this board from ebay for around 12 buks w free shipping. It's based on uda1380 from ntx and it's 3.3v, 5v tolerant 24bit adc/dac codec I2S with I2C control. Still dunno the limitations since it still have to arrive but wonder if can be used with this librrary or the incoming Paul one.
    On datasheet it suppose to decode MD,CD,Mp3 data stream but in some forum I've read they used as codec succesfully. It's a very cheap module, 4 time less expensive than audio codec shield and 24bit and if works can be an cheap entry level for experiments !?!?
    http://www.ebay.com/itm/UDA1380-Board-Stereo-MD-CD-Mp3-Audio-Codec-Coder-Decoder-Development-Module-Kit-/251043491316

  11. #86
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Italy
    Posts
    163
    Quote Originally Posted by sumotoy View Post
    hello,
    just get this board from ebay for around 12 buks w free shipping. It's based on uda1380 from ntx and it's 3.3v, 5v tolerant 24bit adc/dac codec I2S with I2C control. Still dunno the limitations since it still have to arrive but wonder if can be used with this librrary or the incoming Paul one.
    On datasheet it suppose to decode MD,CD,Mp3 data stream but in some forum I've read they used as codec succesfully. It's a very cheap module, 4 time less expensive than audio codec shield and 24bit and if works can be an cheap entry level for experiments !?!?
    http://www.ebay.com/itm/UDA1380-Board-Stereo-MD-CD-Mp3-Audio-Codec-Coder-Decoder-Development-Module-Kit-/251043491316
    Well, as long as it is an I2S codec it should work with hpyle's library. You should check the datasheet for the uda1380 to see how to configure the chip via I2C. If I were you I'd start writing some UDA1380 control library, like the WM8731 library used to control the mikroe audio shield, while waiting for the shipping. Let us know when you receive it

  12. #87
    Junior Member
    Join Date
    Feb 2014
    Posts
    1
    Has anyone had any luck getting 32-bit bit-depth working with hpyle's library with the Mikroe proto board? I've tried the following modifications with no luck:

    In i2s.h:

    I2S_IO_BIT_DEPTH 32
    I2S_BUFFER_BIT_DEPTH 32

    In i2s.cpp:

    I2S0_TCR |= I2S0_TCR5_FBT(SYWD); // in i2s_transmit_init()

    In the main project:

    CODEC_INTERFACE_FLAGS (WM8731_INTERFACE_FORMAT(I2S) | WM8731_INTERFACE_WORDLEN(bits32) | WM8731_INTERFACE_MASTER)

    I've also modified the dma_tx_callback to use a int32_t buffer.

    The example, at 16-bit samples works, but I'd like to take advantage of the codec's full resolution.

    Is there anything that I'm missing?

  13. #88
    Senior Member onehorse's Avatar
    Join Date
    Apr 2014
    Location
    Danville, California
    Posts
    921
    Hi, I read this thread with great interest and I am looking forward to trying this I2S proto-library myself.

    I just want to make sure I understand this thread. I want to use I2S to take data from a pair (or more) of MEMS microphones that output three-wire I2S data. Are the three I2S ports on the Teensy 3.1 the following?:

    SCK -> Teensy 9 (I2S0_TX_BCLK)
    MOSI -> Teensy 3 (I2S0_TXD0). Can also be switched to pin 22.
    DACL -> Teensy 4 (I2S0_TX_FS). Can also be switched to pin 23 or 25

    and is DACL aka word select, MOSI is serial data, and SCL is CLK.

    Are the Teensy 3.1 pin assignments arbitrary or is Teensy 3.1 pin 9 'the' I2S CLK port?

    In other words, if I make a shield with microphones to mount on a Teensy 3.1, do I have to use pins 9, 3, and 4 for I2S CLK, SD, and WS? Are there alternative ports also (in addition to the bottom pads listed above, that is)?

    I don't want to use a CODEC, but would like to perform FFT and otherwise analyze the sound picked up by the microphones. The application is echo location not audio playback per se.

    Thanks.

  14. #89
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,007
    This thread is very old, about code that was the early stepping stones to developing the audio library.

  15. #90
    Junior Member
    Join Date
    Jul 2016
    Posts
    4

    same thing with arduino

    Quote Originally Posted by hpyle View Post
    I got it wrong in the examples' comments. You have SCK to pin 11 (MCLK), but it should be to the bit-clock, pin 9 (BCLK).

    Here's the full list to check:
    SCK -> Teensy 9 (I2S0_TX_BCLK)
    MISO -> not connected for this transmit-only example
    MOSI -> Teensy 3 (I2S0_TXD0). Can also be switched to pin 22.
    ADCL -> not connected for this transmit-only example
    DACL -> Teensy 4 (I2S0_TX_FS). Can also be switched to pin 23 or 25
    SDA -> Teensy 18 (I2C0_SDA)
    SCL -> Teensy 19 (I2C0_SCL)
    3.3V -> Teensy 3.3v
    GND -> Teensy GND
    Hi,
    What if I want to use this codec with Arduino Mega2560?
    I connect like this:
    wm8731's : sck Arduino : 13
    mosi 11
    sda sda (20)
    scl scl (21)
    3.3 3.3
    gnd gnd

  16. #91
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Italy
    Posts
    163
    Quote Originally Posted by michaelpro View Post
    Hi,
    What if I want to use this codec with Arduino Mega2560?
    I connect like this:
    wm8731's : sck Arduino : 13
    mosi 11
    sda sda (20)
    scl scl (21)
    3.3 3.3
    gnd gnd
    You can't.

    The Mega2560 microcontroller does not have an I2S bus.

  17. #92
    Junior Member
    Join Date
    Jul 2016
    Posts
    4
    Quote Originally Posted by MickMad View Post
    You can't.

    The Mega2560 microcontroller does not have an I2S bus.
    Thank you for your feedback,
    ok, but it has SPI, is this not enough for wm8731?
    Which arduino module dou you suggest?

  18. #93
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Have a look at Paul's post on the Arduino forums: http://forum.arduino.cc/index.php?to...796#msg2003796

    SPI is not enough for the WM8731. You need two interfaces, one for digital audio data (I2S) and one for controlling the CODEC IC (SPI or I2C, the IC supporst both).

    Edit: Note that Pauls statement:
    However, the Teensy Audio Library really only supports I2S master mode well, where Teensy sends BCLK, LRCLK and MCLK. If your DAC or other external circuitry will be creating the clocks, Teensy probably isn't the best option at this time.
    is outdated. Teensy can run in I2S slave mode as well.

  19. #94
    Junior Member
    Join Date
    Jul 2016
    Posts
    4
    Quote Originally Posted by Ben View Post
    Have a look at Paul's post on the Arduino forums: http://forum.arduino.cc/index.php?to...796#msg2003796

    SPI is not enough for the WM8731. You need two interfaces, one for digital audio data (I2S) and one for controlling the CODEC IC (SPI or I2C, the IC supporst both).

    Edit: Note that Pauls statement:

    is outdated. Teensy can run in I2S slave mode as well.

    Thank you,
    This knowledge is so useful for me,
    What about raspberry? Is it proper for this purpose?

  20. #95
    Senior Member Ben's Avatar
    Join Date
    Jul 2013
    Location
    Germany
    Posts
    401
    Quote Originally Posted by michaelpro View Post
    What about raspberry? Is it proper for this purpose?
    I don't know if this is true for all models of Raspberries, but there seems to be an I2S bus on them:
    Click image for larger version. 

Name:	PI2-I2S-CONNECTOR.png 
Views:	327 
Size:	139.3 KB 
ID:	7687
    I don't know what this bus is capable of (bit depth, master/slave, sample rate), so you need to do some research yourself.

  21. #96
    Junior Member
    Join Date
    Jul 2016
    Posts
    4
    Quote Originally Posted by Ben View Post
    I don't know if this is true for all models of Raspberries, but there seems to be an I2S bus on them:
    Click image for larger version. 

Name:	PI2-I2S-CONNECTOR.png 
Views:	327 
Size:	139.3 KB 
ID:	7687
    I don't know what this bus is capable of (bit depth, master/slave, sample rate), so you need to do some research yourself.
    Thank you for feedback,
    I will search it,
    Another question : is there "loopback" function in wm8731? I read it's datasheet but I do not find anything related with loopback,
    I simply want : speaking to mic and hearing voice from speaker,
    Do you have any idea?

  22. #97
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Italy
    Posts
    163
    Quote Originally Posted by michaelpro View Post
    Thank you for feedback,
    I will search it,
    Another question : is there "loopback" function in wm8731? I read it's datasheet but I do not find anything related with loopback,
    I simply want : speaking to mic and hearing voice from speaker,
    Do you have any idea?
    If the datasheet says anything about that, you could just configure the WM8731 internal registers for the loopback function using the serial control interface from your Arduino-whatever and be done. You won't need any actual audio data transfer if it is implemented directly in the CODEC

    Anyway, Arduinos do not have I2S support; the only one that could have support are the ARM based ones. I for sure know that the new ATSAMD21 family of micros (used on the Arduino Zero) has an I2S interface because I'm working with it, but as far as I know no Arduino official library has yet been released for I2S.

  23. #98
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    8,230
    What's the reason not to use a teensy 3.2 ? It is ready to use for I2S..

  24. #99
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,007
    Quote Originally Posted by michaelpro View Post
    ok, but it has SPI, is this not enough for wm8731?
    TL;DR = No, not really.

    But if your definition of "enough" is sufficiently small, perhaps it is. The Open Music Labs Codec Shield used this approach, so if you really want to go to a lot of effort for very limited results on your Mega, that's the place to start. Don't believe the hype you might read on their site about that shield. Look at the examples in the actual library code to get an idea of what (very limited) capabilities are actually possible with this technique. If your application is similar to those oscillator & simple effects examples, then maybe you can make use of your Mega and WM8731 this way.

    If you want to actually play sounds from a SD card, record, implement filters, synthesize & mix many waveforms, implement more sophisticated effects, or do analysis like FFT without big gaps, get a Teensy 3.2 and save your Arduino Mega for another project where you need lots of pins but not something so demanding as quality audio.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •