Shop OBEX P1 Docs P2 Docs Learn Events
Propeller interfacing with an external Audio DAC — Parallax Forums

Propeller interfacing with an external Audio DAC

Samgot7Samgot7 Posts: 4
edited 2012-11-02 03:18 in Propeller 1
Is there any example code on how to interface the prop with an external DAC such as one of the Wolfson products? I have read about other people interfacing the prop to Wolfson DAC's, but I can't find anything on OBEX or any example code. I know that different DAC's would require different code, but if someone has already written the code for a certain DAC then I would just use that. I have seen where the prop can be used to play audio without an external DAC, but I am wanting more of an audiophile grade sound. I suppose that a driver for a DAC would be written in PASM, but right now I am totally lost when it comes to PASM. I have used SPIN and have a basic understanding of that, but am still at a beginner level. So far, I have enjoyed experimenting with the prop and want to learn more about it. Anyhow, if anyone could help me out, or point me in the right direction as far as what I need to learn to code my own driver, I would appreciate it.

Sam

Comments

  • Mark_TMark_T Posts: 1,981
    edited 2012-10-31 10:40
    Samgot7 wrote: »
    Is there any example code on how to interface the prop with an external DAC such as one of the Wolfson products? I have read about other people interfacing the prop to Wolfson DAC's, but I can't find anything on OBEX or any example code. I know that different DAC's would require different code, but if someone has already written the code for a certain DAC then I would just use that.

    Indeed - I feel guilty as I have interfaced to a variety of such ADCs/DACs and not put anything in the Obex - anyway here's a DAC driver for I2S - aimed at the WM8524, but any 24-bit I2S bus chip needing a full or partial set of MCLK, BCLK, LRCLK should work with this I think.

    I use an MCLK of Prop clock / 8 and LRCLK of Prop clock / 2048. With a 6.144MHz xtal and pll16x, Prop clock = 98.304MHz, MCLK = 12.288MHz, LRCLK = 48kHz (sample rate).

    Another cog is going to have to update the samples at 48kHz of course!
  • Samgot7Samgot7 Posts: 4
    edited 2012-10-31 14:34
    Awesome! I really appreciate the code and also the fast response! I wish I knew how to write these kinds of things in PASM, but I currently lack the programming skills. I have studied electronics and have designed audio amps and such down to the component level, but I haven't done very much with microcontrollers. In fact, the Prop is my first encounter with a microcontroller, so I am still a newbie. Again, I appreciate the response. Let me know if I can help you in anyway, maybe not with the prop since my knowledge is limited, but with other areas of electronics.

    Sam
  • Mark_TMark_T Posts: 1,981
    edited 2012-10-31 15:33
    Looking again at that driver of mine, I think its using left-justified encoding, which not all I2S devices will support (the 8524 needs the right control inputs setup IIRC).
    The code makes use of 2 counters, one for the MCLK and one for the BCLK (bit clock) and then the LRCLK is set (as is the data pin) in code with 8 instructions per bit, relying on the Prop's deterministic timing (though I think it has to resync to the BCLK line after accessing hub memory).

    I know I've posted something like this before on the forum, just not sure where or which driver... At some point I will update my audio mixer post in the Projects forum. Promise.
  • Samgot7Samgot7 Posts: 4
    edited 2012-10-31 19:58
    Yes, I was looking at your code and noticed that you had placed a comment "use left justified format" and I was wondering what would need to be changed if I wanted to interface to an I2S device. I looked at the WM8524 data sheet and noticed that it would accept left or right justified data as well as I2S. While some of the other Wolfson products and various other DAC/ADC's will only accept I2S. Would there be much change required to interface your driver to I2S? I was looking at your code and referring to the PASM "Assembly Elements" as a guide. Due to my lack of knowledge, I felt like I was trying to navigate a dark hall way with a small LED light...lol. At any rate, I would be able to use the WM8524 with your driver without any changes right? Since the WM8524 will accept left justified data. Again, I appreciate the help
  • Mark_TMark_T Posts: 1,981
    edited 2012-11-01 04:03
    For standard I2S you just have to send a dummy bit before the 24 data bits - so rather than 24 data + 8 dummy, you send 1 dummy, 24 data, 7 dummy... Or equivalently toggle the LRCLK one bit-time earlier.
  • Samgot7Samgot7 Posts: 4
    edited 2012-11-01 23:50
    Oh, ok. Thank you. Are you able to play .wav files or .mp3 files using this driver? At some point I would like to be able to play and record files from and to an SD card using an DAC and ADC. I have found plenty of examples for playing files from an SD card without using an external DAC. That is great for getting the most functionality out of the prop, but isn't suitable for audiophile grade sound; that is where a dedicated DAC comes into play. Anyhow, I am surprised that more people(prop users) haven't experimented with using external audio DAC/ADC's; the prop is quite capable and has been around for a while. I have investigate other microcontrollers, but I haven't seen any "newbie-friendly" way of processing audio on any platform, at least not through I2S. The driver that you have posted is the first that I have seen available for the prop.
  • Mark_TMark_T Posts: 1,981
    edited 2012-11-02 03:18
    I've just coupled ADCs and DACs, or a software signal generator. Synchronization to a signal source isn't handled in this river, but the LRCLK line is available for that.
Sign In or Register to comment.