I believe this is relevant: =20 https://secure.wikimedia.org/wikipedia/en/wiki/Noise_shaping#Noise_shaping_= and_1-bit_converters https://secure.wikimedia.org/wikipedia/en/wiki/Delta-sigma_modulation From my understanding the interpolation is basically density modulation=20 where the incoming sample value is the density, and the high frequency=20 1-bit output is averaged/low-pass filtered for the audio output. The=20 precise pulse position is driven by error feedback so that every bit=20 reduces the quantization noise in the passband, while pushing that noise=20 above the hearing threshold into the (internal analog filter's) stopband. I think all you have to do is arrange the right system clock value and=20 setup your ISR to push per-sample data into the FIFO (which will happen=20 at the sample rate as the FIFOs get consumed and the ISR called). The=20 sampling rate is set by your system clock (or external clock pin),=20 divided by the DAC divisor, and then the mandatory upsampling divisor of=20 256. So you must carefully set the system clock if you expect to=20 correctly play "normal" audio data at {8,16,22.05,32,44.1,48} ksamples/s. If you are doing arbitrary frequency synthesis, generally you accumulate=20 a phase term by adding a fractional ((desired_freq / sampling_rate) *=20 (units_per_cycle)) "tuning" term to a fixed-point counter on every=20 sample. The integer part of the counter is the index into your table. =20 The number of fractional bits sets your frequency precision. The=20 combination of input tuning value and sample rate determines the phase=20 jitter. As always, a low-pass filter of your choosing after the analog=20 output will mop up any frequency spikes above the desired frequency, but=20 the phase noise can remain. Most people use 1/256th of a circle as the unit and use the integer byte=20 to index their waveform table. As you know, a truncated table is used=20 for symmetrical waveforms such as the sine wave with the high bits of=20 the index used to negate/invert the returned value. Joe Koberg On 2011-01-18 18:40, IVP wrote: > Hi all, > > could someone expound a little about interpolation, more > particularly as implemented on the dsPIC > > Here's the relevant section of the 33F64GP802 data sheet > > Section 33. Audio Digital-to-Analog Converter (DAC) > > http://ww1.microchip.com/downloads/en/DeviceDoc/70211B.pdf > > I've had a look around Microchip and found > > Piecewise Linear Interpolation > > http://ww1.microchip.com/downloads/en/AppNotes/00942A.pdf > > which uses a table, not hardware > > and generally, > > http://en.wikipedia.org/wiki/Upsampling > > http://en.wikipedia.org/wiki/Sample_rate_conversion > > For example, I have a data table which holds 16-bit values for a > sine wave, in degree steps (included below if anyone wants it) > > Now, if I wanted to output a 1Hz sine wave, that would mean > retrieving new data each 1/360th (2.78ms) of a second. If it > was a 1kHz sine wave output, then new data each 1/360,000th > (2.78us) > > Section 33 says - > > "The digital interpolation filter up-samples the input signal to > create additional interpolated data points. The over-sampling > ratio is 256:1, or 256x the incoming sampling rate. For example, > a 100 ksps input signal (the maximum sampling rate) produces > 25.6M data points per second" > > So my retrieval rate from a data store is the 'sampling rate' ? > > If I interpret correctly, > > Table 33-1 shows that if this were data for a variable or irregular > wave (eg speech or music), the over-sampling clock is set to the > maximum frequency component. eg for a digitised 44.1kHz signal, > the over-sampling clock would need to be set to (256 * 44100), > or 11.289600MHz > > To make full use of the interpolation then, is it simply necessary > to have an over-sampling clock that is only as fast as the highest > component or should it be *at least* as fast as the highest > component ? > > IOW, if the over-sampling clock is fast enough (256kHz) to > interpolate data for a 1kHz signal, then how does it interpolate > just 256 intermediate points at 1Hz ? > > Joe > > ;0 - 90 degrees, 16-bit decimal > ; > ;Signed > ; > ;0x7FFF =3D Most positive output voltage > ;0x0000 =3D Midpoint output voltage > ;0xFFFF =3D Value just below midpoint > ;0x8000 =3D Minimum output voltage > > ;1st quadrant -> table > ;2nd quadrant -> reverse table > ;3rd quadrant -> -table > ;4th quadrant -> reverse -table > > ;Unsigned > ; > ;0xFFFF =3D Most positive output voltage > ;0x8000 =3D Midpoint output voltage > ;0x7FFF =3D Value just below midpoint > ;0x0000 =3D Minimum output voltage > ; > ;1st quadrant -> table + 32768 > ;2nd quadrant -> reverse (table + 32768) > ;3rd quadrant -> 32767 - table > ;4th quadrant -> reverse (32767 - table) > > sine90: .word 0 ; 0 > .word 570, 1143, 1713, 2287, 2857 ; 1 - 5 > .word 3424, 3994, 4561, 5124, 5688 ; 6 - 10 > .word 6252, 6812, 7369, 7926, 8480 ;11 - 15 > .word 9031, 9581,10125,10669,11206 ;16 - 20 > .word 11744,12275,12802,13327,13848 ;21 - 25 > .word 14365,14877,15384,15886,16384 ;26 - 30 > .word 16875,17364,17845,18324,18796 ;31 - 35 > .word 19261,19720,20175,20621,21063 ;36 - 40 > .word 21498,21924,22347,22763,23169 ;41 - 45 > .word 23569,23966,24349,24729,25099 ;46 - 50 > .word 25466,25820,26168,26508,26839 ;51 - 55 > .word 27164,27482,27786,28085,28376 ;56 - 60 > .word 28658,28930,29195,29451,29697 ;61 - 65 > .word 29933,30162,30381,30592,30791 ;66 - 70 > .word 30981,31165,31335,31499,31649 ;71 - 75 > .word 31794,31928,32049,32164,32269 ;76 - 80 > .word 32364,32449,32524,32587,32642 ;81 - 85 > .word 32688,32721,32747,32760,32767 ;86 - 90 --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .