AnsweredAssumed Answered

Relationship of DAC DMA, Timer Value and Sine Table

Question asked by roofie01 on Jul 22, 2016
Latest reply on Jul 23, 2016 by roofie01
Hi,

I have an example DAC program with a sine table of 128 points. It generates a signal at 5KHz with no problem. However, it stops working at 4.6KHz when adjusting the frequency down. It uses PA4 output and TIM 6.

My goal is to produce an output of about 100Hz. So I'm unable to see the relationship of the Timer, the DAC output and the table size. A sine table is generated for the number of points, not the frequency. According to the example's defines, it should be a matter of changing the frequency:

#define   OUT_FREQ  5000     // Output waveform frequency
#define   SINE_RES    128       // Waveform resolution (table size)
#define   DAC_DHR12R1  0x40007408   // DMA writes this reg on every request
#define   CNT_FREQ   42000000        // TIM6 counter clock (prescaled APB1)
#define   TIM_PERIOD   ((CNT_FREQ)/((SINE_RES)*(OUT_FREQ)))    // Autoreload reg value

The article says:

trig freq = APB1 / (prescalar * auto_ reload_val)
and that:
output freq = trig freq / sine resolution.

My board's clock is set up as:

SYSCLK_Frequency = 84000000
HCLK_Frequency = 84000000
PCLK1_Frequency = 21000000
PCLK2_Frequency = 42000000

So what would be required make this work at a frequency of 100Hz?

Thanks for your help.














Outcomes