cancel
Showing results for 
Search instead for 
Did you mean: 

The DMA interrupt is different between ADC and DAC

kylongmu
Associate II
Posted on October 06, 2016 at 05:35

NUCLEO-F746ZG

I'm testing the ADC and DAC work with DMA, but the interrupt is different:

the DMA of ADC can enter interrupt when Half and Full transfer.

But the DMA of DAC only interrupt when Half transfer.

Timer tmr;

DigitalOut Dac_Event(PB_1);

static int tinterval;

void DMA2_Stream0_IRQHandler(void)//ADC DMA

{

    /* USER CODE BEGIN DMA2_Stream2_IRQn 0 */

    tim4cnt++;

    if(__HAL_DMA_GET_IT_SOURCE(&DMA_ADC_Handle, DMA_IT_HT)) { //Half transfer

        tinterval = tmr.read_us();//Half DMA

        HAL_DMA_IRQHandler(&DMA_ADC_Handle);

        return;

    }

    if(__HAL_DMA_GET_IT_SOURCE(&DMA_ADC_Handle, DMA_IT_TC))//Full transfer

    {

        tinterval=tmr.read_us() - tinterval;

      HAL_DMA_IRQHandler(&DMA_ADC_Handle);

    }

}

void DMA1_Stream6_IRQHandler(void)////DAC DMA DMA1_Stream6

{

    /* USER CODE BEGIN DMA2_Stream2_IRQn 0 */

    if(__HAL_DMA_GET_IT_SOURCE(&DMA_DAC_Handle, DMA_IT_HT)) { //Half transfer

        Dac_Event = 1;

        HAL_DMA_IRQHandler(&DMA_DAC_Handle);

        return;

    }

    if(__HAL_DMA_GET_IT_SOURCE(&DMA_DAC_Handle, DMA_IT_TC)) { //Full transfer not enter

        Dac_Event = 0;

        HAL_DMA_IRQHandler(&DMA_DAC_Handle);

    }

}

4 REPLIES 4
kylongmu
Associate II
Posted on October 06, 2016 at 06:24

0690X00000603NHQAY.jpg

Change the output signal self revert, see the waveform attached.

void DMA1_Stream6_IRQHandler(void)////DAC DMA DMA1_Stream6

{

/* USER CODE BEGIN DMA2_Stream2_IRQn 0 */

if(__HAL_DMA_GET_IT_SOURCE(&DMA_DAC_Handle, DMA_IT_HT)) { //Half transfer

Dac_Event = !Dac_Event;

HAL_DMA_IRQHandler(&DMA_DAC_Handle);

return;

}

if(__HAL_DMA_GET_IT_SOURCE(&DMA_DAC_Handle, DMA_IT_TC)) { //Full transfer not enter

Dac_Event = 0;

HAL_DMA_IRQHandler(&DMA_DAC_Handle);

}

}

/*************************************************/

Yellow channel is the DAC output a SAW UP waveform,

Green channel is the DMA interrupt test output waveform.

________________

Attachments :

graphs.jpg : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HzaZ&d=%2Fa%2F0X0000000bO6%2Fi.UBgKDkbNuHTcF0bE0HX1zeOXy_su.DA4_Ag5Qvj5M&asPdf=false
Posted on October 06, 2016 at 14:18

Perhaps you should focus on how you are configuring it rather than the interrupt handlers?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kylongmu
Associate II
Posted on October 07, 2016 at 04:25

You are right, my ADC DMA work with normal mode, it's means 1 transfer to end, but my DAC DMA work with circula mode.

But the interrupt response is still strange, the DAC DMA produce twice interrupt, and it's Flag always shows half transfer.

Whatever, I can initial a global varible to identify if the interrupt is half or full.  

Walid FTITI_O
Senior II
Posted on October 07, 2016 at 10:01

Hi qiyong.mu.001, 

You would share further details as more code ( how ADC and DAC are configured)  to make users able to help you.

-Hannibal-