Re: MSP430F1612: generating sinusoidal signals



On 7 Feb 2007 19:26:11 -0800, Marius.Hancu@xxxxxxxxx wrote:

OK, I've found this reference:

DMA eases CPU's workload for waveform generation
Code uses the fewest cycles to implement periodic waveform with DACs.

Mike Mitchell, Texas Instruments, Houston, TX; Edited by Brad Thompson
and Fran Granville -- EDN, 12/5/2005

http://www.edn.com/article/CA6288034.html

Not sure if something better can be done with this processor in terms
of periodic waveform generation.

It depends what frequency accuracy / frequency step is needed and what
the spurious response requirements are.

In the beginning of that article, there was a simplistic calculation
about using a programmed approach to generate a 1 kHz sine wave using
a 32 kHz sample and interrupt rate. The waveform looks good on an
oscilloscope even without the LPF, but for audio applications, this
would be an overkill.

For audio applications just over 2-3 times the highest sine wave
frequency should be enough.

If the highest sine frequency you needed is 6 kHz, then 16 kHz might
be the suitable interrupt rate, which would be 1/2 of the interrupt
rate of the initial 32 kHz programmed case, so the load figures would
also be one half of that example.

The numerically controlled oscillator can be used to generate quite
clean waveforms with modest sampling frequencies.

In this case, for each frequency that needs to be generated, perhaps a
16 bit phase accumulator would be enough. At each interrupt, a phase
increment (depending of the frequency needed) is added to the phase
accumulator, which may freely overflow. The highest bits of the phase
accumulator (say 8 bits) are used to address the sine look-up table
and the table element value is loaded into the DAC. In this case the
frequency tuning step is 16000 Hz/65536 or 0,24 Hz and the look-up
table would contain 256 elements.

As long as the sampling frequency is not a harmonic multiple of the
sine wave frequency, different elements in the look-up table are
addressed at different cycles, so even when observing the waveform
before the LPF with an oscilloscope, after a few overlapping traces, a
clean sine wave will appear on the screen.

Of course, other phase accumulator sizes and look-up table sizes can
be used, but these involve some extra shift instructions.

In the article, the 32 kHz sampling rate with 1 MHz crystal frequency
caused 58 % load for a single output frequency, so with 16 kHz sample
rate would be above 29 %, due to the extra instructions to extract the
high bits from the phase accumulator. With 8 MHz crystal frequency,
the load would be about 4 %.

Paul

.



Relevant Pages

  • Re: Waveform horror! Is a 44.1 kHz sampling rate sufficient?
    ... I then zoomed in on the waveform to take a peek, ... A FFT gives a spread of frequencies centered around the 19 kHz, but, ... sine wave to that data you would find it would fit really well. ...
    (sci.electronics.basics)
  • Re: Walkman, at 30, a mystery to teen
    ... playback waveform will never represent the original analog waveform as ... as a high end analog device. ... Even a simple 1000 Hz sine wave will not come ... from 20 Hz to 20 kHz and an extended frequency response up to 100 kHz! ...
    (rec.radio.shortwave)
  • Re: Walkman, at 30, a mystery to teen
    ... playback waveform will never represent the original analog waveform as ... as a high end analog device. ... Even a simple 1000 Hz sine wave will not come ... from 20 Hz to 20 kHz and an extended frequency response up to 100 kHz! ...
    (rec.radio.shortwave)
  • Re: IM distortion: why related to level?
    ... This assumes the waveform is incorrectly encoded. ... example the 19 kHz and 20 kHz components are ... difference tones but didn't think it through. ... frequency of the brickwall filter, and at 21 kHz, you're sailing ...
    (rec.audio.tech)
  • Re: Recording digital data to analog tape... revisited
    ... the output waveform on playback looks almost ... Can you try recording a 3 kHz sine wave? ... The waveforms look to me like his recorder has no bias. ... DC during the highs and lows puts a constant, same-direction magnet bias ...
    (comp.arch.embedded)

Loading