K22 DMA - DMOD setting ignored by minor loop offset?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

K22 DMA - DMOD setting ignored by minor loop offset?

543 Views
scottm
Senior Contributor II

I've got a DMA channel feeding interleaved data from a single buffer to both I2S transmit FIFO registers.  The buffered values are 32-bit words.  It works fine if I set it up with DMOD set for an 8-byte circular buffer (namely the two FIFO registers) and set SOFF = 4.  One word goes to the first FIFO, the next to the second FIFO, and then DADDR loops back to the first FIFO.  Four words are sent to each FIFO for each DMA request.

The trouble is that the natural ordering of the buffered data has it interleaved in groups of 3 words, e.g. AAABBBAAABBB.  The above solution needs it in ABAB order.  My plan was to try using the minor loop offset rather than DOFF to alternate destination registers.  However, it appears that MLOFF doesn't honor the DMOD modulo setting, which results in it running off and trashing the I2S module's registers until it runs off the end of its memory area and generates a bus fault.

Am I doing something wrong, or is that just how the minor loop offset works?  Is there more detailed documentation on its operation?  I've been over the DMA section in the K22F1M0's reference manual several times and I can't find anything that would suggest that the modulo mode shouldn't still apply.

This is not a big deal in this case.  The code that generates the data to be sent doesn't take a serious efficiency hit to write it in ABAB order, it's just an architectural issue since that code is supposed to be generic across multiple projects.  I was previously using separate buffers and separate DMA channels, which also required reordering the data.  It looks like I could go back to using separate channels and point them to the same buffer, one channel offset by 3 words, and use the minor link offset on the source address to skip the other channel's data.  Using a single channel and changing the sample format reduced the load on the DMA controller by something like 250,000 requests/second, and that's a bigger deal than the code reuse issue.  I'm just trying to understand why it's doing what it's doing.

Thanks,

Scott

Labels (1)
Tags (2)
0 Kudos
2 Replies

379 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Scott,

Please check below info about eDMA modulo:

  • Provides the ability to easily implement a circular data queue
    Size of queue is a power of 2
  • mod, a 5-bit bit field, specifies which lower address bits are allowed to increment from their original value after the address + offset calculation
    - all upper address bits remain the same as in the original value.
    - If mod = 0 disables modulo feature
  • Example: source address = 0x12345670; offset is 4 bytes so mod=4, allowing for a 24 byte (16-byte) size queue

pastedImage_1.png

Wish it helps.


Have a great day,
Ma Hui

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

379 Views
scottm
Senior Contributor II

I understand how the modulo feature works and I use it all the time for circular buffers, but my point is that the docs don't really say anything one way or another about MLOFF in modulo mode.  It was surprising to me that it didn't apply.  It looks like that property could be useful in certain circumstances, but in any case it'd be nice if the manual spelled it out.

Thanks,

Scott

0 Kudos