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
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
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 = 0x00010001Figure 17. Memory mapping for 16 bit mono, left channel only. CONFIG.SWIDTH = 16Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00010001Figure 18. Memory mapping for 24 bit mono, left channel only. CONFIG.SWIDTH = 24Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00010001Figure 19. Memory mapping for 32 bit mono, left channel only. CONFIG.SWIDTH = 32Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00010001
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 = 0x00030003Figure 21. Memory mapping for 16 bit stereo. CONFIG.SWIDTH = 16Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00030003Figure 22. Memory mapping for 24 bit stereo. CONFIG.SWIDTH = 24Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00030003Figure 23. Memory mapping for 32 bit stereo. CONFIG.SWIDTH = 32Bit, CONFIG.CHANNEL.NUM = 2 and CONFIG.CHANNEL.MASK = 0x00030003
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.MASKFigure 26. Memory mapping for 16 bit TDM. CONFIG.SWIDTH = 16Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASKFigure 27. Memory mapping for 24 bit TDM. CONFIG.SWIDTH = 24Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASKFigure 28. Memory mapping for 32 bit TDM. CONFIG.SWIDTH = 32Bit, CONFIG.CHANNEL.NUM = n and all channels enabled in CONFIG.CHANNEL.MASK