cancel
Showing results for 
Search instead for 
Did you mean: 

DAC-DMA and Timer

nimaltd
Senior

I am using timer 2 for trigger DAC and GPIO to generate analog and digital values.

own timer 2 started with DMA to change ARR by an array.

My GPIO array works well and starting to change from index 0 . but my DAC array start from Index 1.

msg89464043-592494.jpg

 as you can see, the longest pulse (200ms) in latest DAC value (dac[9] = 4000) instead of (dac[0] = 2000)

 

time[0] = 200000;

time[1] = 100000;

time[2] = 100000;

time[3] = 100000;

time[4] = 100000;

time[5] = 100000;

time[6] = 100000;

time[7] = 100000;

time[8] = 100000;

time[9] = 100000;

 

dac[0] = 2000;

dac[1] = 2200;

dac[2] = 2500;

dac[3] = 2700;

dac[4] = 2900;

dac[5] = 3100;

dac[6] = 3300;

dac[7] = 3500;

dac[8] = 3700;

dac[9] = 4000;

 

pin[0] = 0x0000FFFF;

pin[1] = 0xFFFF0000;

pin[2] = 0xFFFF0000;

pin[3] = 0xFFFF0000;

pin[4] = 0xFFFF0000;

pin[5] = 0xFFFF0000;

pin[6] = 0xFFFF0000;

pin[7] = 0xFFFF0000;

pin[8] = 0xFFFF0000;

pin[9] = 0xFFFF0000;

1 ACCEPTED SOLUTION

Accepted Solutions
nimaltd
Senior

I have fixed. 

1) start DAC DMA

2) htim2.Instance->EGR = 0x01;  // trigged event by software

3) start GPIO DMA

4) start TIMER DMA

 

but why???

View solution in original post

3 REPLIES 3
nimaltd
Senior

I think DAC Trigger Rising edge does not work, it starts on falling edge of TIM2-TRGO.

 

nimaltd
Senior

I have fixed. 

1) start DAC DMA

2) htim2.Instance->EGR = 0x01;  // trigged event by software

3) start GPIO DMA

4) start TIMER DMA

 

but why???

nimaltd
Senior

Does anyone know why?