Another USB question here... same as last time; USB Audio on an ARM microcontroller. I have both endpoints (input and output) as isochronous/asynchronous transfers. In addition I have Timer Counter (TC) interrupts to poll for UI processes on my board.
To summarize, when I have a clean bypass (no USB involved), I get no interruptions; clean signal. Great!!! No weird out of sync issues with the I2S bus/codec; no weird blips, nothing. However, when USB Audio is enabled, things get weird. In my previous question on stackexchange, I didn't have any other UI processes going on (checking for button presses) so the USB audio was pretty clean.
How I read from codec to USB:
(1) USB Input enabled, start USB writes (2) Write an empty buffer to USB endpoint (3) Send USB data buffer (4) Wait for USB write callback (5) Completed USB write; do the following: (a) read next buffer from codec (I2S-DMA) and load that into USB buffers (b) Send next available USB buffer to endpoint (c) Repeat Step 4-5
Ways I have tried to poll for UI processes (button presses):
(1) USB start of frame interrupts (2) Timer Counter interrupts (3) Main while loop polling
All of these cause glitches in my USB Audio writes/codec reads. I can only guess that when an interrupt happens, my codec read gets interrupted and the mcu drops some samples. However, I'm not sure why just regular polling is causing a glitch issue. In terms of interrupt priorities, my I2S-DMA and USB interrupts are highest priority whereas my TC interrupts are very very low (like the lower number).
The question (if you haven't already guessed) is: How do I get my mcu to happily read/write continuous audio from my codec to USB while polling for these other UI processes? I can only imagine I will need to do more than button presses in the future so I'm thinking this could be applicable to other mcu peripheral applications.
Sorry in advance this is an easy question or the answer is really obvious; I'm still relatively "new" to microcontrollers and USB. I can easily figure out things in the software domain now but when it comes to hardware AND software... it's a whole different story for me. Any articles I can read without bothering anyone would also be appreciated. Thanks!
EDIT - Answer: So I know there was code here before but through posting it... I realized my mistake. In my button processing code, I had reads/writes being done to mcu's flash as well. When I removed those parts of the code, I didn't hear glitches anymore. Ugh! Sorry for bothering everyone, such a user error on my end. The reads/writes to flash were just there to save certain settings in case the user was to accidentally disconnect power.