AnsweredAssumed Answered

stm32f4 DMA1 stream3 I2S2 interference with USB?

Question asked by Jan Slavotínek on Dec 13, 2016
Latest reply on Dec 14, 2016 by Jan Slavotínek

Hi guys! 
I will try to describe my problem conditions as thoroughly as i can. Thank you very much for reading through!


I need to implement similar project like stm's example on audio receive from microphone (audio playback and record). So i have setted up and implemented my own project with the same settings. (previously i made fully functional project where i use ADC to sample from electret microphone and save into .wav to my flash drive under FatFs msc class. I have sampled pretty fast 48kHz and data write to USB without any problem).

Now I have a following problem: I want to make exactly the same procedure as in audio example. I am using DM1 stream3 for transferring data from my I2S2 to circullar buffer. I use one buffer for PCM write (as in the example) and i transfer content of that buffer half by half. Problem occure when i need to write that very first chunk (half of buffer) of data using f_write USB on my flash drive under FatFs. 


During debugging, i can see, that actually write goes sucessfully. and after taht program returns to main (i handle data from the main wainting for volatile uint8_t flag being set from DMA when half of WrBuffer is ready.). Problem occurs right after when another DMA IRQ occures (first half of circullar DMA buffer ready). For debugging purpouse i light an orange LED on my discovery board inside DMA IRQ and turn it off when returns from IRQ handler. When stepping into IRQ Handler i can get into my "HAL_I2S_RxHalfCpltCallback" and i see that i can sucessfully take my fresh data from half of the circullar buffer (the buffer has size 128 sizeof(uint16_t), so the half is exactly 64 uint16). Ok from there i feed the data into PDM filter "PDM_Filter_64_LSB" (using the most recent PDMfilter library for CM4F). And here it is where my code stucks! 


If i stop data writing  from WrBuffer (stop f_writing to USB) program happily fill my WrBuffer all over again infinitelly. (This level works correctly when running without USB data writing). 
But when i perfromy only 1B write from independend buffer (just some dummy data) during I2S process running, the program stucks on PDM filter function ... 


when i hit "pause" on my debugger after program seems to be stucked, it stops in disassembly on this line(08007a10):
08007a10: b.n 0x8007a10 <PDM_Filter_64_LSB+24>
08007a12: nop
08007a14: lsrs r0, r4, #2
08007a16: movs r0, #0


Have no idea what that means. When i hit another "step into" then program becomes unresponsive. 

Any ideas? 
Thanks Jan


PS: I will try to enclose my entire program including CubeMX file. It is CubeMX project + atollic truestudio project + all source code files.