cancel
Showing results for 
Search instead for 
Did you mean: 

How do you restart a one-shot DMA transfer?

adrian239955_stm1_st
Associate II
Posted on July 03, 2010 at 16:15

How do you restart a one-shot DMA transfer?

5 REPLIES 5
adrian239955_stm1_st
Associate II
Posted on May 17, 2011 at 13:57

Given that it's required to re-load the transfer counter at the end of each transfer when in ''normal'' mode it's suprising that the ST firmware library stm32f10x_dma.c has no subroutine to do this.

Anyway, something about the way I am trying to write directly to the peripheral register seems to be unreliable as it wasn't working to begin with but is now:

DMA1_Channel6->CNDTR =  transfer_size;

The only remaining mystery is that the first byte transferred is always written into memory as zero - even though I can see the correct value on the GPIO pins with a scope. My fixed size transfer is captured starting from the next byte but is then short of one byte at the end.

As per AN2548 data is clocked in by PA6 after configuring it as an input. I have set this to clock on a rising edge which marks the valid state of my data. If I add one to the transfer size I get all the data. Peculiar.

adrian239955_stm1_st
Associate II
Posted on May 17, 2011 at 13:57

Sorry chikos, I didn't make it very clear - by one-shot I mean a discontinuous (non circular) transfer of a fixed number of bytes. The actual transfer size I am using is 48 bytes but it makes no difference. What I think is giving the trouble now is the relative timing of the clock to the data transitions.

I have been looking for the minimum setup and hold times for DMA transactions initiated by an external trigger on Timer 3 (PA6 pin) but can't find this info on the ST site. The data sheet only mentions fEXT Timer external clock being 36MHz maximum and the reference manual doesn't make any mention of timing other than the number of bus cycles per DMA transaction. I know this limits the transfer rate but I'm working below that (4.5Mtransfers/sec).
chikos332
Associate II
Posted on May 17, 2011 at 13:57

Hi,

do you think it is appropriate to use DMA for transferring just one byte each time? what is the advantage vs. using simple read/write operation w/CPU in this case?

I think it is clear that reading one byte with DMA takes more time than reading/writing directly from/to the peripheral (you have at least 3 cycles for clearing DMA enable bit, 3 cycles to write counter, 3 cycles to enable DMA ...).

Unless I didn't clearly understood the situation, my opinion is:

One byte + DMA = Circular mode only

Cheers.

chikos332
Associate II
Posted on May 17, 2011 at 13:57

Ok,

In this case I don't suspect DMA speed to be the root cause. Even no facts are provided by ST, I think that DMA speed is only relative to AHB bus which is obviously faster than APB bus on which the Timer is connected.

So unless you have an overloaded CPU, there is no way the DMA miss TIM requests.

Sorry I don't have any other clues ...

John F.
Senior
Posted on May 17, 2011 at 13:57

I use,

    //disable dma to set up data to send, then initiate transmission under DMA control

    DMA_Cmd(DMA1_Channel4, DISABLE);

    DMA1_Channel4->CMAR = (uint32_t)OutBox.TxBuffer;

    DMA1_Channel4->CNDTR = OutBox.DataCount;

    DMA_Cmd(DMA1_Channel4, ENABLE); //start dma transfer - usart 1 transmits data

then,

    //wait until the OutBox contents have been transmitted

    while (DMA_GetFlagStatus(DMA1_FLAG_TC4) == RESET)

    {

      ;  //Wait for DMA1 Channel transfer to complete

    }

    DMA_ClearFlag(DMA1_FLAG_TC4);       //must clear the transfer complete flag for next time

Are you clearing the TC flag? I'm not sure I understood your problem.

John F.