cancel
Showing results for 
Search instead for 
Did you mean: 

DMA TCIF0 trigger immediately after DMA EN =0

Barbie
Associate II
Posted on December 12, 2012 at 10:29

I have face a problematic state.

After I finish to collect on DMA and get TCIF0=1 I collect the data and reset that flag. After that I want to write a new value in the NDTR so I disable teh DMA by register S0CR->EN=0. But immediate after doing that (even before enable teh DMA again ,I get interrupt from TCIF0=1.

Why this is happens? and how I can get over it?
6 REPLIES 6
Posted on December 12, 2012 at 11:29

Which device?

Any minimal but compilable code to reproduce the problem?

Thanks,

JW
Barbie
Associate II
Posted on December 12, 2012 at 12:13

It is STM32F207

The interrupt look like this:

void DMA2_Stream0_IRQHandler (void)

{

   if(DMA_GetITStatus( DMA2_Stream0, DMA_IT_TCIF0)== SET) // get Transfer complite 

   {

     // ADC2_EOC_present=0; // TEST TEST TEST reset ADC move data

     /* Sign to main its time to move data from DMA */

      DMA2_stream_status.data_ready_in_stream0=1;

      DMA_ClearITPendingBit(DMA2_Stream0, DMA_IT_TCIF0);

   }

}

From the interrupt I get to here:

          if( (DMA2_stream_status.DMA_stream_ready & 0x05) == 0x05) /// if both data scan ready in the DMA can retrive

{

DMA2_stream_status.data_ready_in_stream0 =0;

DMA2_stream_status.data_ready_in_stream2 =0;

.

.

.

.

and then I disable the DMA like this:

                                     DMA_Cmd(DMA2_Stream0, DISABLE); // DISABLE the DMA channel to let reconfigur DMA buffer size

                                     while (!(DMA_GetCmdStatus(DMA2_Stream0))); // check for DMA disable (not done immediately)

                                     DMA_Cmd(DMA2_Stream2, DISABLE); // DISABLE the DMA channel to let reconfigur DMA buffer size

                                     while (!(DMA_GetCmdStatus(DMA2_Stream0))); // check for DMA disable (not done immediately)                                    

and immediately I get interrupt.

A clue that can help:

It happens after it finish to run to the size of the NDTR. I use the Circular mode. Can it be a problem if it try again to start and I disable it?

Posted on December 12, 2012 at 13:54

Yes.

Look at the User Manual, RM0033 (I have rev4), ch.9.3.14 DMA transfer suspension:

''Note: Note that a Transfer complete interrupt flag (TCIF in DMA_LISR or DMA_HISR) is set to indicate the end of transfer due to the stream interruption.''

JW
Barbie
Associate II
Posted on December 12, 2012 at 14:45

This is right and I know it.

As I told I do the reading of all the buffer clear the flag and then disable the DMA. But at that stage I get a new TCIF interrupt when I know for sure  taht the DMA didn't get again to its end of buffer.

Posted on December 12, 2012 at 18:56

You wrote you use circular mode. In that mode, achieving NDIS transfers does not clear the EN bit automatically, thus DMA is still ready to transfer data. So when you write EN to 0 while being in circular mode, it constitutes transfer *suspension* regardless of whether NDIS is at its initial value or not; and that is what the above quote from the manual refers to.

In other words, every time you rewrite EN from 1 to 0, expect a Transfer Complete interrupt. You may find it illogical but that's how it's working.

JW
Barbie
Associate II
Posted on December 12, 2012 at 23:05

So what you say I can't face this flag in any case.

I think about the circular mode and I try to disable it before the DMA DIS but it still not help.

Bar.