Teensy 3.2 DAC sample rate question

Status
Not open for further replies.

dmlandrum

New member
I've looked all over for an answer and can't really find one.

I'm aiming to build a real-time pitch shifter in the vein of the classic 70s units, where only the delay and circular buffer was digital, and everything else analog (including the feedback loop). I have my design and feature set mostly nailed down. However, it all hinges on being able to clock samples out to the DAC at absolutely any arbitrary rate (up to some maximum, of course). I know this can be done with R2R DACs.

My input sample rate will be fixed at 32khz, and I want the output sample rate to be able to go anywhere from 16khz up to 64khz (one octave either direction - more is okay, of course) more or less on the fly. So I guess the real question is, can the on-board DAC do that, or do I need to use an external R2R chip? (Jameco has a 12-bit one for $10 - a bit pricey, and it's a parallel input so I'd also need a 12-bit shift register, somehow, to save pins.)

Thank you all for your help!
 
That thread definitely contains information I needed to know, so thank you! I'm still kinda unsure about my main question, which has to do with setting any arbitrary sample rate at all. It seems to be implied that it can, though. I guess I get to learn how to use DMA now (every project I embark on always has at least one new thing to it).

I'm actually keeping this 12-bit on purpose, so the audio library and board are too good for what I'm doing. :)
 
I'm still kinda unsure about my main question, which has to do with setting any arbitrary sample rate at all.

If you dig into the DAC code in the audio library, you'll see the timing is controlled by the PDB timer. The key piece of info is PDB_PERIOD, defined in this header file.

On Teensy 3.2, the default F_BUS frequency is 48 MHz. So the timing is 48e6 / 1088.

Using the PDB (or other on-chip digital timers), you can't have "any arbitrary sample rate at all". You need to use an integer to configure those timers. You can write 1089 for slightly slower speed, or 1087 for slightly faster, but you can't create any arbitrary speed between those steps of approx 0.1% change. At least not using the timers in the ordinary way.

If you're thinking of a fully analog design, you should consider this timing to be similar to a volume knob on a modern stereo where it actually controls a digital attenuator inside. You see the volume changing in 0.1 dB steps on a display. Human hearing can't perceive such tiny step sizes, but they still are tiny steps and not a truly continuous analog variation.
 
Okay, thanks for the help. I guess I'm looking at using an external R2R DAC, which I was hoping to avoid because I'll also need some kind of shift register to save pins. Or go with something that has more GPIO.
 
Okay, thanks for the help. I guess I'm looking at using an external R2R DAC, which I was hoping to avoid because I'll also need some kind of shift register to save pins. Or go with something that has more GPIO.

Nobody says you can use the DAC only with the PDB. In fact, just write to the register whenever you want - that's the same as using an external R2R. Just don't use this timer and use an other mechanism (but i still not understand why the PDB is not ok ....
 
Status
Not open for further replies.
Back
Top