EmbeddedRelated.com
Forums

MSP430F1612: generating sinusoidal signals

Started by Marius Hancu February 7, 2007
Hello:

What would be the most efficient (i.e. minimizing the involvement of 
resources) and fastest way to generate sinusoidal signals (using the DAC 
for output) in the TI MSP430F1612?

Just approximate (can be stepped, output by the DAC, not filtered), in 
the audio range (up to 6KHz or so).

I heard that part of the necessary algorithms are HW-wired somewhere in 
the chip, not sure.

Thanks.
Marius Hancu
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.

Any ideas?

Marius Hancu


Marius.Hancu@gmail.com 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. > > Any ideas? > > Marius Hancu
DMA is good when you _already_ have the samples (a period) stored somewhere in the DMA accessible memory. If this is the case then - there you are. But in case by "generating", in your original message, you mean you need to calculate those samples, then I suggest you have a look at "Table look-up and interpolate" algorithms (you can find an Application Note on TI's page, I think it was written for '2x DSPs). Succes :-) Adrian
On Wed, 07 Feb 2007 21:38:38 -0500, Marius Hancu wrote:

> I heard that part of the necessary algorithms are HW-wired somewhere in > the chip, not sure.
Does the chip incorporate a DDS? If it does then maybe that is what you are looking for? I believe you can get DDS chips that a uC can interface to. They are also pretty straight forward to implement in an FPGA too. You could implement a DDS in software but only if it was very low frequency. 6KHz sounds too high for that approach though. Paul.
On 7 Feb 2007 19:26:11 -0800, Marius.Hancu@gmail.com 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
On Thu, 08 Feb 2007 14:23:09 +0000, Paul Taylor wrote:

> On Wed, 07 Feb 2007 21:38:38 -0500, Marius Hancu wrote: > >> I heard that part of the necessary algorithms are HW-wired somewhere in >> the chip, not sure. > > Does the chip incorporate a DDS? If it does then maybe that is what you > are looking for? I believe you can get DDS chips that a uC can interface > to. They are also pretty straight forward to implement in an FPGA too. You > could implement a DDS in software but only if it was very low frequency. > 6KHz sounds too high for that approach though. > > Paul.
OK - forget all of that. My new reader wasn't showing *any* of the other responses in this thread. I think it's a problem with the tiscali news service. Need to change... or just use google groups. Regards, Paul.
Paul Taylor wrote:
>
... snip ...
> > OK - forget all of that. My new reader wasn't showing *any* of > the other responses in this thread. I think it's a problem with > the tiscali news service. > > Need to change... or just use google groups.
See my sig. You don't want to use google. -- Some free news servers. I use teranews and gmane. <http://www.teranews.com> (1 time charge) (free) <http://news.aioe.org> (free) <http://dotsrc.org> (free) <http://www.x-privat.org/international.php> (free) <http://motzarella.org/?language=en> (free) <http://gmane.org/> (mail-lists via news) (free) <http://www.newsfeeds.com/signup.htm> (pay) <http://www.individual.net/ (low pay)
On Thu, 08 Feb 2007 17:06:50 -0500, CBFalconer wrote:


>> Need to change... or just use google groups. > > See my sig. You don't want to use google.
Thanks - I agree with you about not wanting to use google. Regards, Paul.