cancel
Showing results for 
Search instead for 
Did you mean: 

Most effective way to generate waveform?

Need to generate a repeating waveform with external SPI 16-bit DAC.

Using a table of values in memory, repeatedly loop through table outputting values to DAC.

Delay between outputs is constant. No glitches at repeat!

DMA only (no interrupts).

What's the most effective way to do this with ST32F427?

Thanks,

Best Regards, Dave

11 REPLIES 11
MikeDB
Lead

I'd use an SAI port assuming there's one on your chosen MCU. More flexible and more than fast enough for what you want. And loads of TI DACs will interface easily,

This turns out to be much easier than I thought (I missed 'DMA circular mode' first go around).

One timer to:

  • trigger DMA on overflow (sets update frequency)
  • generate CS signal of correct length to bracket SPI transfer (unbelievably, lame STM32F SPI module fails to do this correctly)

DMA:

  • output from sample array in memory to SPIx->DR
  • run in circular mode (NDTR is number of samples in waveform table)
  • 16-bit transfers for this DAC
  • triggered by above timer; each timer trigger does 1 transfer (not NDTR transfers as manual might lead you to believe)

Scope picture below (top trace is CS, bottom 2 traces are SPI clock and MOSI):

0690X000006DsNsQAK.png