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.

Long read/write from SD card to Flash memory prevents MCASP functionality ?

Does anyone know a read write process to Flash memory would stop McAsp functionality down the line? If I transfer 100 Blocks, the audio transmits just fine. If I transfer 300, I have a buffer underrun. 

A real mystery to me.

I am running the NDK, if that information helps. 

Cheers,

Amanda

  • Its worth mentioning that the data I'm transferring is distinct from the audio I'm playing.
  • Hi,

    Thanks for your post.

    I don't think, read write process to flash should block mcasp functionality. I think, buffer underrun issue to cause would be for some olther mess up happened with inactive n-slot TDM configuration, i guess so. McASP initialization configuration needs to be validated and error interrupts needs to be triggered to evaluate the root cause of this issue. We need to capture the mcasp register dump during debug at desired breakpoints in the code which needs to be digged further to investigate on it.

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    -------------------------------------------------------------------------------------------------------

  • Hi,

    Usually, a buffer underrun can only occur for serializers programmed to be transmitters. A buffer underrun would occur when the serializer is instructed by the transmit state machine to transfer data from XRBUF[n] to XRSR[n], but XRBUF[n] has not able to write with new data since the last time the transfer occurred. When this occurs, the transmit state machine sets the XUNDRN flag. Please try enabling transmitter underrun interrupt enable bit in XINTCTL (refer sections 25.3.32, 25.3.33 in the TRM below:

    http://www.ti.com/lit/ug/spruh77a/spruh77a.pdf

    The above is the probability of occuring Tx. underrun issue and to recover, reset the McASP and start again with the proper initialization.

    Also in one other case, the tx. underrun flag would set which is below:

    Usually, a transmit DMA error, as indicated by the XDMAERR flag in the XSTAT register would occur when the DMA (or CPU) writes more words to the DMA port of the McASP than it should. For each DMA event, the DMA should write exactly as many words as there are serializers enabled as transmitters.

    XDMAERR indicates that the DMA (or CPU) wrote too many words to the McASP for a given transmit DMA event. Writing too few words results in a transmit underrun error setting XUNDRN in XSTAT.

    Thanks & regards,

    Sivaraj K

    -------------------------------------------------------------------------------------------------------

    Please click the Verify Answer button on this post if it answers your question.

    -------------------------------------------------------------------------------------------------------

  • Hello! 

    Thanks for the the reply, Sivaraj K.

    I've recently confirmed that the issue occurs after a lengthy write to flash memory. 

    I declare the following global variable: 

    Int16 AudioTemp[576000]={0};

    If I read a bunch of audio off the SD card, and load it into flash - but load it into the same space in memory, not incrementing the indices of the array that I'm loading too, then MCASP transmits a different audio file properly after the load.

    for (i=0; i<512*8/32; i++)
    {
    
     
        Rshort = (short)(rx[i]        & 0x0000FFFF);                
        AudioTemp[*samp_ind]=Rshort;
        //printf("\nSample[%d, %d]: %d, 0x%x",*samp_ind,i,Rshort,Rshort);
        // *samp_ind=*samp_ind+1;                                                // The Offending Line 
    .
    .
    .
    }

    However, if I uncomment the line that increments the indices, the MCASP has a buffer underun after the load.  

    Again, the audio I'm transmitting is drawing from a different cyclical buffer.

    I'll find out the values in the registers now and include that in my next post. 

    Thanks again,

    Amanda

  • If I uncomment line 8 above,

    then the transmit code hangs here:

    /* Send a sample to the right channel */
    while (! ( MCASP0_SRCTL9 & 0x10 ) ); // XRDY   Here is where it hangs
    MCASP0_XBUF9_32BIT = (channel_mask[0]*Transmit << 15);

  • Here are the contents of XSTAT when it hangs (after the load to flash memory):

    XSTAT: 0x00000151
    Reserved ***********************
    XERR * XMT Error
    XDMAERR 0 - NOERROR XMT DMA bus error
    XSTAFRM 1 - YES Start of Frame-XMT
    XDATA 0 - NO Data Ready Flag
    XLAST 1 - YES Last Slot Interrupt Flag
    XTDMSLOT 0 - ODD EvenOdd Slot
    XCKFAIL 0 - NO Bad Transmit Flag
    XSYNCERR 0 - NO Unexpected XMT Frame sync flag
    XUNDRN 1 - YES XMT Underrun Flag


    The question, is why would loading <1MB to flash memory cause a buffer underrun ?
  • What I want to be clear - is that the audio transmit works perfectly.....

    Unless I perform this (seemingly unrelated) write to flash memory first, and actually increment the indices I'm writing to. When I DO increment the indices I'm writing to in SD ram, I get a buffer under-run in the audio transmit that follows. If I don't increment the indices of the array I'm writing to the audio transmit that follows also works.

    Thanks again,
    Amanda