DSPRelated.com
Forums

strange DMA behaviour

Started by Ulf March 13, 2007
Hi!

Ive a very strange DMA behaviour.
I use a DMA to sent data from memory to the mcbsp transmit register
and another DMA to sent the received data from the mcbsp receive
register to memory. I use a circular buffer for the transmit register
as well as for the received data. The mcbsp uses the same frame sync
for receiving and transmitting and the transmit DMA uses the mcbsp
transmit event for synchronization and the receive DMA uses the mcbsp
receive event.

Normally the answer on the first entry of the transmit circular
buffer is at the second entry of the receive circular buffer, the
second entry of the transmit circular buffer is at the 3rd entry of
the receive circular buffer and so on (behaviour 1). But sometimes
the answer on the 1st entry of the transmit circular buffer is at the
1st entry of the receive circular buffer, the 2nd entry of the
transmit circular buffer is at the 2nd entry of the receive circular
buffer and so on (behaviour 2). And sometimes the transformation
between transmit and receive circular buffer changes during program
flow (behaviour 3).
Has anyone an idea for the reason of this troublesome behaviour?

I found a workaround for my problem and this is the strangest thing.
I use an if instruction with a condition that is normally false. The
first instruciton of the if-body is a function call. If I uncomment
the function call or if I insert some dummy instruction before the
function call my DMA works well (behaviour 1).
But the function call has nothing to do with the DMA and I can notice
by a breakpoint that the function call isn t performed. How can this
instruction affect the DMA?



Ulf-

> Ive a very strange DMA behaviour.
> I use a DMA to sent data from memory to the mcbsp transmit register
> and another DMA to sent the received data from the mcbsp receive
> register to memory. I use a circular buffer for the transmit register
> as well as for the received data. The mcbsp uses the same frame sync
> for receiving and transmitting and the transmit DMA uses the mcbsp
> transmit event for synchronization and the receive DMA uses the mcbsp
> receive event.
>
> Normally the answer on the first entry of the transmit circular
> buffer is at the second entry of the receive circular buffer, the
> second entry of the transmit circular buffer is at the 3rd entry of
> the receive circular buffer and so on (behaviour 1). But sometimes
> the answer on the 1st entry of the transmit circular buffer is at the
> 1st entry of the receive circular buffer, the 2nd entry of the
> transmit circular buffer is at the 2nd entry of the receive circular
> buffer and so on (behaviour 2). And sometimes the transformation
> between transmit and receive circular buffer changes during program
> flow (behaviour 3).
> Has anyone an idea for the reason of this troublesome behaviour?
>
> I found a workaround for my problem and this is the strangest thing.
> I use an if instruction with a condition that is normally false. The
> first instruciton of the if-body is a function call. If I uncomment
> the function call or if I insert some dummy instruction before the
> function call my DMA works well (behaviour 1).
> But the function call has nothing to do with the DMA and I can notice
> by a breakpoint that the function call isn t performed. How can this
> instruction affect the DMA?

If inserting "dummy code (or data)" has an effect, then the likely issue is
alignment. For C55x some cases might be making a double-word access on odd boundary,
DMA-accessible array/buffer not on even boundary, etc. When you insert the bogus
instruction, you might be getting correct alignment.

I suggest to study your .map file carefully for both cases, in particular a) the ISR
code for DMA events, and b) data being accessed by the DMA. If these are not showing
in your .map file then use the -g option to make all symbols global.

-Jeff