Audio playback - timer based DAC DMA

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've started a little project that involves playing back audio samples from an SD card.

 

It uses an XMega32E5 and my thinking at the moment is to use an 8 kHz timer as a trigger for DMA to copy the next two-byte sample to the DAC - essentially playing back a "block" of audio in the background (the system will be double-buffered, so the next block is read in the foreground from the SD card while background DMA is playing the current one).

 

Anybody done this before? Anyone see anything stunningly wrong with this plan?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I don't know anything about this subject, but I'm offering this because you don't have a reply yet.  It's  URL for another thread.

https://www.avrfreaks.net/forum/s...

Read all the way down to the bottom, and you may find some answers to get you on the way.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I managed to get it working. I've made a test program that uses Petit FAT to read a file and transfer it to the DAC with double-buffering.

 

The tricky part is/was that you just enable the first buffer at the start, and every time you update the next buffer, you set the repeat bit on it except for the last one. Then you wait until one of the transfer flags indicates that a buffer is free and load the next sample.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've used this technique extensively, and it works very well. I would suggest adding a low pass filter to your schematic, could be 4kHz but you could probably go to 10kHz and leave room for improved sound quality later.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

After some breadboard testing, I came to this conclusion as well. Before I ordered the boards, I added the footprint for a cap in parallel to the feedback resistor of the final amp. We'll have to see if that's enough.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It should be okay, you really don't need much when your audio is only 8khz anyway :-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Alright, you caught my attention.

 

With a quick look at the schematic, I couldn't see what / where the audio output is...

 

I was looking to see if the schematic showed a series resistor leading to the pads for you audio output LPF.

 

A "simple RC" LPF feeds a signal into a resistor, and the output of the resistor is the output signal, and it has a cap to ground.

 

Your description of a cap across a resistor doesn't describe a classic LPF, and more info on the output circuitry is needed.

 

Next comment:  The Xmega series uses the PDI interface, and unless the details have changed recently it is NOT recommended to put a 10K pull-up resistor on the Reset\ pin.

The external pull up resistor is a carry over from AVR Tiny and AVR Mega micros, (and others).

The PDI interface is suppose to have the same external impedance on both the data and the clock lines.

Although including the 10K pull up resistor on the Reset\ pin might work with some programmers, it might also cause a programing failure, (failure to connect) with some programmers with "weaker" output drivers.

 

Next comment:

Connecting input dip-switch configuration switches directly to ground is OK, maybe.

Maybe not.

 

If you have guaranteed good code, and it will never run astray, and you are manufacturing millions of boards, then go ahead and skip the inclusion of any resistor with the switches. 

 

Otherwise, it would be wise to include a small resistor in series with the switch to ground.

The purpose is to limit the current if the I/O pin is inadvertently (erroneously) configured as an output, and set high, while the pin is externally connected to ground.

This will likely damage that particular pin's I/O driver, and perhaps the chip.

 

In normal operations, this event should not occur.

 

Perhaps I am old school, but I am of the believe that the hardware should not have the ability to self destruct if an unknown software bug, or a static electricity zap, etc., sends the micro off into some unexpected mode.

 

I know it wasn't your design, but if you elect to make one from scratch, there is no reason you can't improve the circuit a bit.

 

JC