Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 9 months ago.
Two-layer(nested) DMA loop on FRDM-KL46Z (SimpleDMA mod?)
Hi all
I would like to implement a two layer DMA loop using only one DMA channel :
inner loop is triggered by I2S-TX DMA request, it writes 1Word to I2S TX data register (since the FIFO is only for 1 Word)
outter loop is triggered, when inner loop is done. It should simply provide next data for the inner loop... N times (N-configurable)
I could create the inner loop with SimpleDMA, it's working great!
Any ideas, how to implement the outer-loop on a FRDM-KL46z ?
using SimpleDMA (maybe slightly modified) with some additional Register operations is preferable
Should be not a active_waiting (blocking) structure like : while (counter<N) do inner_loop; counter++;
Best Regards D.Becker
Question relating to:
1 Answer
8 years, 9 months ago.
From the reference manual (http://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCEQFjAAahUKEwiH3Z-L2erIAhVEUhQKHadADuE&url=http%3A%2F%2Fcache.freescale.com%2Ffiles%2Fmicrocontrollers%2Fdoc%2Fref_manual%2FKL46P121M48SF4RM.pdf&usg=AFQjCNEkex_9fGx5PcRe8P5n1r_cClqXcQ&sig2=yW23dPh5yE-g-e32g6PlKA). Then at page 374 there is something about linking DMA channels. SimpleDMA itself cannot do it, but you might use that to modify it to meet your requirements?
Of course you can also do this in software using the DMA interrupt, but if you make it work in hardware that is nicer. It might depend on where your data is coming from if this works for you.
Hi Erik. Thank you for the hint with Link channel, didn't saw it till now. It could work, but unfortunately not at the same DMA channel... it looks like I'll need all 4 ch. for I2S read/write.
posted by 30 Oct 2015Lucky it has 4 channels ;). But yeah for read + write and a linked one for both, you don't have many other choices.
posted by 30 Oct 2015I found some information on page 358, about reactivating the DMA loop using SW or DMA MUX.
It's quite complicated but could work with 2 Ch. only, without link channel
P.S. Freescale manuals are not very self-explaining ;-)
posted by 31 Oct 2015Agreed, finding also which channel muxes to which peripheral is close to impossible. Instead of just linking the section in the DMA MUX part, they let you search it for yourself.
You can of course always do it in software. Although I can imagine this won't be trivial timing wise for I2S, especially if that I2S has no buffer of itself.
Depending on your exact requirements, wouldn't it be an option to use a double buffer? One being transmitted by DMA to I2S, the other one filled by whatever source you use. And then swapping the two around in software.
posted by 31 Oct 2015I2S should send/receive USB audio data and also play some tones from the memory. I will use double buffer (ping-pong)
USB frame is 1ms, it has (48kHz 16bit format stereo) 96 Words. (I'm using mbed USB Audio class)
I2S FIFO on this IC is ONE! Word and will send a DMA request every word. (this is my inner loop) The major loop should simply increase the pointer and provide next word as far as the small loop is ready (96 times), without SW.
I tried to do it in SW - no success, the MCU is doing some other stuff like UART, I2C, IO controll - my Audio will be currupted.
posted by 31 Oct 2015