Hi,
Should CPU interrupt or EDMA3 service MCBSP when it is outputting audio?
Audio with acceptable qualities usually have frequency of more than 8 KHz. I have tested with polling XRDY bit of MCBSP.SPCR and write new data to DXR every time this bit becomes zero, and this was successful.
However, when the playing of audio has to be worked with other multimedia functionalities simultaneously, for example periodically updating LCD buffers for like every 1/60 seconds, I can no longer poll XRDY continuously because this will put the LCD on hold. I am therefore considering two alternatives: EDMA3 or interrupt?
Using interrupt seems easier to implement. However, each interrupt function needs to first save the context, do the work, and then restore the context, and they together consume several dozens of assembly instruction. In addition, both the audio data and the MCBSP configuration instrutions could locate in the external memory (since none of L138’s internal DSP or ARM memories is large enough to hold audio data), each instruction and data fetch might take as long as over ten cycles.
If we assume 8 KHz audio data, and 100 cycles in total for both context switch of ISR plus audio data reading and take this 100 KHz estimation as already included the memory-hierarchy fetch delay, then since MCBSP’s DXR holds only 1 unit of data a time, to play audio we then need eight thousand ISRs per second, which takes together 8×1000×100 = 0.8M cycles.
This rough calculation seems however to suggest that although there can be as many as eight thousand ISRs per second, the actual fraction of CPU time it takes, compare to an assumed typical 300MHz clock rate, is in fact very small, and this seems to suggest that interrupt based MCBSP serving can be a good choice in that it is unlikely to interfere with other routines?
I actually also implemented this ISR based MCBSP servicing and it suggested otherwise. When this executes it seems to cause problems to other routines, in particular USTIMER_delay() which uses the timer to create a specified wait/delay. There are also other ISRs being set at the same time which are periodically triggered or asynchronously triggered due to external events such as a touch, but none of these other interrupts causes appreciable disruption to USTIMER_delay() -- only the MCBSP ISR does. On the other hand, none of the other interrupts has a frequency so high as comparable to 8 KHz of the MCBSP ISR. So it seems to me that it is the high frequency of MCBSP that has caused the problem?
When using MCBSP to output audio data, which is the best and unobtrusive method? Could someone help?
Paul