This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

McBSP2 I2S with SDMA - last packet processing

I am writing code to play sounds using McBSP2 as an I2S master

I am currently using sdma channel to send "full" 5120 byte packets to the McBSP transmitter.

How can I handle a remaining "partial" packet?  Do I need to use an additional DMA channel and a link?

 

For example:   a 1/2 second , two channel,  16bit per channel, 32KHz sound is 64000 bytes long.

Using a full packet size of 5120 12 and 1/2 packets are needed.

 

Thanks,

Larry

  • Larry

    Can you no use 25 x 2560 byte packets? This would eliminate any partial packets.

      Paul

  • Yes, but only for that example.

     

    The problem is that the data size is not known ahead of time.  So I am forced to pick a packet size and handle a remainder packet.

    I have the transfer working using 2 DMA channels.  I am searching for a single channel solution.

    Larry

  • Larry

    Another suggestion is to pad the buffer in order to complete the frame size.

    What mechnism are you using to stop a transfer? Gating FSX when DXR is empty?
    What size of frame/THRSH1 are you using?

    Are you currently setting up the second channel specifically for the remaining words and chaining upon first channel completion?

      Paul

  • Hi Paul,

     

    I did not see your reply until now, hope I'm not too late.

     

    My goal is to be able to send an arbitrary number of audio samples thru the McBSP2 using SDMA.

    My data type is 16 bits, 2 channel.

     

    I am using the PACKET type DMA transfer (BS=1, FS=1)

    My Threshold is 5120-1

    I am currently using channel 0 to transfer complete packets

    CEN = 0xA00

    CDFI = 0x500

    CFN = number of complete packets

    I then link to channel 1 to send any partial packet

    CEN = number of samples in partial packet

    CFDi = number of samples in partial packet

    CFN =1

     

    I then enable the block complete int of SDMA 1.  When it occurs I enable the End of frame & buffer empty int on McBsp2.

    When it occurs the transfer is complete and I disable the dma and mcbsp

     

    There has got to be a better way???

     

    Larry

     

     

     

  • Hi Larry,

    This may be the best way to do it. In what way are you looking to improve this sequence?

  • Is there a method to accomplish the data transfer with only one DMA channel?

     

    I have another requirement to transfer data in an endless loop.

    When the data is an exact packet size I link the channel back onto itself and it works great.  I2S data fortever.

     

    When I have a partial packet I link the second channel back to the first.  It loops endlessly, however I hear a glitch when the restart occurs?

     

    Is this behavior expected?  Can I eliminate the glitch?

     

    Thanks,

    Larry

     

     

  • Hi Larry,

    I am going to check other audio drivers and how they handle this condition, but it doesn't seem possible to me meet both of your requirements.  Possibly a trace or profiling tool may help look at the restart condtion. What OS are you using?

  • No OS, bare metal.

     

    Thanks for looking

     

    Larry