Channel mask and EasyDMA

nRF54LM20A | nRF54LM20B Datasheet

TDM implements EasyDMA for accessing RAM without CPU intervention.

EasyDMA

The source and destination pointers for the TX and RX data are configured in TXD.PTR and RXD.PTR. The memory pointed to by these pointers will only be read or written when TX or RX are enabled in and .

The addresses written to the pointer registers TXD.PTR and RXD.PTR are double-buffered in hardware, and these double buffers are updated for every TXD.MAXCNT/RXD.MAXCNT words (containing one or more samples) read/written from/to memory. The events TXPTRUPD and RXPTRUPD are generated whenever the TXD.PTR and RXD.PTR are transferred to these double buffers.

If TXD.PTR is not pointing to the Data RAM region when transmission is enabled, or RXD.PTR is not pointing to the Data RAM region when reception is enabled, an EasyDMA transfer may result in a HardFault and/or memory corruption. See Memory for more information about the different memory regions.

The size of the RXD and TXD memory buffers are independent, but the number of transmitted bytes always equals the number of received bytes. With RXD.MAXCNT and TXD.MAXCNT being independent, data is either discarded or padded as described in Transmitting and receiving. The size of the buffers is specified in a number of bytes, however the memory is organized in 32-bit words that either contain four 8-bit samples, two 16-bit samples, one right-aligned 24-bit sample sign extended to 32 bit, or one 32-bit sample.

Channel masking

Channel masking takes place between the transceiver and the EasyDMA access to memory as illustrated in the following figure.
Figure 14. Channel masking block diagram
Page-1 Square EasyDMA EasyDMA Slave, h Square.11 Channel masking Channel masking Square.12 Memory Memory Slave, h.14 Slave, h.15 Pin, right-to-left Dynamic connector.137 Sheet.21 MCK MCK Pin, right-to-left.23 Dynamic connector.137 Sheet.25 FSYNC FSYNC Pin, right-to-left.26 Dynamic connector.137 Sheet.28 SCK SCK Pin, right-to-left.29 Dynamic connector.137 Sheet.31 SDIN SDIN Pin, right-to-left.32 Dynamic connector.137 Sheet.34 SDOUT SDOUT Rectangle Serial transceiver Serial transceiver
Which of the samples transferred over the data lines are accessed by EasyDMA, is selected by the register CONFIG.CHANNEL.MASK. In this register, channels are enabled or disabled from the memory transfers. Disabled channels are ignored - transmitted bits are zero, and received data is discarded. Enabled channels will have their data stored to, or received from, memory.
Figure 15. Channel masking example. Four channel audio input, storing only two channels to memory
Channel mask

Memory map for single channel (mono)

When the resulting data after channel masking is a single channel, the following figures show how this channel's samples are mapped to memory. The mapping is valid for both RX and TX.

Figure 16. Memory mapping for 8 bit mono. CONFIG.SWIDTH = 8Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00010001
Memory mapping for 8-bit mono. CONFIG.SWIDTH = 8Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00010001
Figure 17. Memory mapping for 16 bit mono, left channel only. CONFIG.SWIDTH = 16Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00010001
Page-1 Rectangle Rectangle.2 Left sample 1 Left sample 1 Rectangle.3 Left sample 0 Left sample 0 Sheet.4 0 0 Sheet.5 31 31 Rectangle.6 Left sample 3 Left sample 3 Rectangle.7 Left sample 2 Left sample 2 Rectangle.8 Left sample n - 1 Left sample n - 1 Rectangle.9 Left sample n - 2 Left sample n - 2 Sheet.10 16 16 15 Sheet.12 x.PTR x.PTR Sheet.13 x.PTR + 4 x.PTR + 4 Sheet.14 x.PTR + (n*2) - 4 x.PTR + (n*2) - 4
Figure 18. Memory mapping for 24 bit mono, left channel only. CONFIG.SWIDTH = 24Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00010001
Page-1 Rectangle Rectangle.3 Left sample 0 Left sample 0 Sheet.4 0 0 Sheet.5 31 31 Sheet.12 x.PTR x.PTR Sheet.13 x.PTR + 4 x.PTR + 4 Sheet.14 x.PTR + (n*4) - 4 x.PTR + (n*4) - 4 Rectangle.16 Left sample 1 Left sample 1 Sheet.18 Sheet.19 Sheet.20 23 23 Sheet.21 Sign ext. Sign ext. Sheet.24 Sign ext. Sign ext. Rectangle.25 Left sample n - 1 Left sample n - 1 Sheet.26 Sheet.27 Sign ext. Sign ext.
Figure 19. Memory mapping for 32 bit mono, left channel only. CONFIG.SWIDTH = 32Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00010001
Page-1 Rectangle Rectangle.3 Left sample 0 Left sample 0 Sheet.4 0 0 Sheet.5 31 31 Sheet.12 x.PTR x.PTR Sheet.13 x.PTR + 4 x.PTR + 4 Sheet.14 x.PTR + (n*4) - 4 x.PTR + (n*4) - 4 Rectangle.16 Left sample 1 Left sample 1 Rectangle.25 Left sample n - 1 Left sample n - 1

Memory map for two channels (stereo)

When the resulting data after channel masking is two channels (stereo), the following figures show how this channel's samples are mapped to memory. The mapping is valid for both RX and TX.

Figure 20. Memory mapping for 8 bit stereo. CONFIG.SWIDTH = 8Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00030003
Page-1 Rectangle Rectangle.2 Right sample 1 Right sample 1 Sheet.4 0 0 Sheet.5 31 31 Sheet.10 16 16 Sheet.12 x.PTR x.PTR Sheet.13 x.PTR + 4 x.PTR + 4 Sheet.15 15 15 Sheet.28 24 24 Sheet.29 23 23 Sheet.30 8 8 Sheet.31 7 7 Rectangle.32 Left sample 1 Left sample 1 Rectangle.33 Right sample 0 Right sample 0 Rectangle.34 Left sample 0 Left sample 0 Rectangle.35 Right sample 3 Right sample 3 Rectangle.36 Left sample 3 Left sample 3 Rectangle.37 Right sample 2 Right sample 2 Rectangle.38 Left sample 2 Left sample 2 Rectangle.39 Right sample n-1 Right sample n-1 Rectangle.40 Left sample n-1 Left sample n-1 Rectangle.41 Right sample n-2 Right sample n-2 Rectangle.42 Left sample n-2 Left sample n-2 Sheet.43 x.PTR + (n*2) - 4 x.PTR + (n*2) - 4
Figure 21. Memory mapping for 16 bit stereo. CONFIG.SWIDTH = 16Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00030003
Page-1 Rectangle Rectangle.2 Right sample 0 Right sample 0 Rectangle.3 Left sample 0 Left sample 0 Sheet.4 0 0 Sheet.5 31 31 Rectangle.6 Right sample 1 Right sample 1 Rectangle.7 Left sample 1 Left sample 1 Rectangle.8 Right sample n - 1 Right sample n - 1 Rectangle.9 Left sample n - 1 Left sample n - 1 Sheet.10 16 16 Sheet.12 x.PTR x.PTR Sheet.13 x.PTR + 4 x.PTR + 4 Sheet.14 x.PTR + (n*4) - 4 x.PTR + (n*4) - 4 Sheet.15 15 15
Figure 22. Memory mapping for 24 bit stereo. CONFIG.SWIDTH = 24Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00030003
Page-1 Rectangle Rectangle.3 Left sample 0 Left sample 0 Sheet.4 0 0 Sheet.5 31 31 Sheet.12 x.PTR x.PTR Sheet.13 x.PTR + 4 x.PTR + 4 Sheet.14 x.PTR + (n*8) - 8 x.PTR + (n*8) - 8 Rectangle.16 Right sample 0 Right sample 0 Sheet.18 Sheet.19 Sheet.20 23 23 Sheet.21 Sign ext. Sign ext. Sheet.24 Sign ext. Sign ext. Rectangle.25 Left sample n - 1 Left sample n - 1 Sheet.26 Sheet.27 Sign ext. Sign ext. Rectangle.28 Right sample n - 1 Right sample n - 1 Sheet.29 Sign ext. Sign ext. Sheet.30 Sheet.32 x.PTR + (n*8) - 4 x.PTR + (n*8) - 4
Figure 23. Memory mapping for 32 bit stereo. CONFIG.SWIDTH = 32Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00030003
Page-1 Rectangle Rectangle.3 Left sample 0 Left sample 0 Sheet.4 0 0 Sheet.5 31 31 Sheet.12 x.PTR x.PTR Sheet.13 x.PTR + 4 x.PTR + 4 Sheet.14 x.PTR + (n*8) - 8 x.PTR + (n*8) - 8 Rectangle.16 Right sample 0 Right sample 0 Rectangle.25 Left sample n - 1 Left sample n - 1 Rectangle.28 Right sample n - 1 Right sample n - 1 Sheet.32 x.PTR + (n*8) - 4 x.PTR + (n*8) - 4

Memory map for multi-channel (three or more)

The following equation can be used to calculate the address of the word storing a multi-channel sample. The equation is valid for both RX and TX. The following notation is used.
  • S is the number of data bits in a sample
  • N total number of channels per sample
  • n is the channel number of the current sample
  • m is the sample number
Figure 24. The equation for calculating the 32-bit aligned address of a multi-channel sample.

When the resulting data after channel masking is three or more the samples are stored sequentially in memory, similar to stereo. The following figures show how the samples are mapped to memory. The mapping is valid for both RX and TX.

Figure 25. Memory mapping for 8 bit TDM. CONFIG.SWIDTH = 8Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASK
Memory mapping for 8-bit TDM. CONFIG.SWIDTH = 8Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASK
Figure 26. Memory mapping for 16 bit TDM. CONFIG.SWIDTH = 16Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASK
Memory mapping for 16-bit TDM. CONFIG.SWIDTH = 16Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASK
Figure 27. Memory mapping for 24 bit TDM. CONFIG.SWIDTH = 24Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASK
Memory mapping for 24-bit TDM. CONFIG.SWIDTH = 24Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASK
Figure 28. Memory mapping for 32 bit TDM. CONFIG.SWIDTH = 32Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASK
EasyDMA32 Rectangle.3 Channel 0 : Sample 0 Channel 0 : Sample 0 Sheet.12 0 0 Sheet.13 31 31 Sheet.14 x.PTR x.PTR Sheet.15 x.PTR + 4 x.PTR + 4 Sheet.16 x.PTR + ((N-1)*4) x.PTR + ((N-1)*4) Rectangle.17 Channel 1 : Sample 0 Channel 1 : Sample 0 Rectangle.19 Rectangle.21 Channel N - 1 : Sample 0 Channel N - 1 : Sample 0 Rectangle.32 Channel 0 : Sample M - 1 Channel 0 : Sample M - 1 Rectangle.33 Channel 1 : Sample M - 1 Channel 1 : Sample M - 1 Rectangle.34 Rectangle.35 Channel n : Sample M - 1 Channel n : Sample M - 1 Rectangle.36 Sheet.37 x.PTR + 4*N*(M-1) x.PTR + 4*N*(M-1) Sheet.38 x.PTR + 4*(N*(M-1)+n) x.PTR + 4*(N*(M-1)+n) Sheet.39 Sheet.40 Sheet.41 Sheet.42 Block of N channels Sample 0 Block of N channelsSample 0 Sheet.43 Sheet.44 Block of N channels Total of M Samples Block of N channelsTotal of M Samples Sheet.45