The ADC has a dedicated interface for communicating to and from the DMA. This interface is useful to offload work from the CPU by using the DMA to store ADC results to memory automatically. Figure 12-4 shows the signals that make up this interface:
Note: The “DMA trigger count” signal indicates the number of samples that can be transferred by the DMA upon one trigger request. The “DONE status” signal is used by the ADC to generate the DMA DONE interrupt and it indicates if the DMA data transfer of programmed block size is completed.
The DMAEN bit in the CTL2 register is used to enable the DMA for ADC data transfer. The DMAEN bit is cleared by ADC hardware when the DMA “DONE status” signal is asserted. Software is expected to re-enable the DMA using DMAEN to arm the ADC to generate the next DMA trigger.
The ADC also incorporates an optional First-In-First-Out buffer to provide a way for ADC results to be stored for future use, such as transferring to memory by the DMA. Either the CPU or the DMA can be used to move data from the ADC regardless of whether the FIFO is enabled or disabled. The memory result flags in the RIS register of the third event publisher serve as the FIFO threshold and can be unmasked to generate the DMA trigger.
The following sections explain the details of using the ADC+DMA/CPU in various conversion modes and with the FIFO enabled or disabled
ADC-DMA/CPU Operation in Non-FIFO Mode (FIFOEN=0)
ADC-DMA/CPU Operation in Non-FIFO Mode (FIFOEN=0)
- Single Conversion and Repeat Single Conversion
- Configure STARTADD bits to select the desired MEMCTLx register
- MEMCTLx is correlated to MEMRESx
- MEMRESx is correlated to MEMRESIFGx
- Configure MEMCTL CHANSEL bits to select the desired ADC channel
- Conversion data is available in MEMRESx
- MEMRESIFGx can be set to generate a CPU interrupt or the DMA trigger
- SAMPCNT must be programmed to 1 by SW for DMA operation
- The conversion overflow flag OVIFG is set when the ADC updates MEMRESx before the previous sample is read by the CPU or DMA
- The conversion underflow flag UVIFG is set when the CPU or DMA reads the MEMRESx register before the next conversion result is available
- Sequence Conversion and Repeat Sequence Conversion
- Configure STARTADD bits to select the first MEMCTL in the sequence
- Configure ENDADD bits to select the last MEMCTL in the sequence
- MEMCTLx is correlated to MEMRESx
- MEMRESx is correlated to MEMRESIFGx
- Configure each MEMCTLx CHANSEL bits to select the desired ADC channels
- Conversion data is available in MEMRESx
- MEMRESIFGx can be set to generate a CPU interrupt or the DMA trigger
- SAMPCNT must be programmed by SW to a suitable value based on threshold setting by SW for DMA operation
- The conversion overflow flag OVIFG is set when the ADC updates MEMRESx before the previous sample is read by the CPU or DMA
- The conversion underflow flag UVIFG is set when the CPU or DMA reads the MEMRESx register before the next conversion result is available
Note: For DMA based operation, the MEMCTL start address should be smaller than the end address for single sequence conversion as DMA source does not roll back. Repeat sequence conversion mode does not support DMA based data transfer because the DMA does not support circular addressing mode.
ADC-DMA/CPU Operation in FIFO Mode (FIFOEN=1)
- Single Conversion and Repeat Single Conversion
- Configure STARTADD bits to select the desired MEMCTLx register
- MEMCTLx is NOT correlated to MEMRESx
- MEMRESx is correlated to MEMRESIFGx
- Configure MEMCTL CHANSEL bits to select the desired ADC channel
- Conversion data is loaded sequentially into MEMRES0,1,2,….N (organized as a FIFO)
- The CPU or DMA must read ADC samples from the dedicated FIFODAT register and not from MEMRES registers directly
- Data in the FIFO is always compacted with two samples and provided as 32-bit data upon a FIFODAT read by CPU or DMA
- MEMRESIFGx can be used as a threshold condition to generate a CPU interrupt or DMA trigger
- For full use of the FIFO, the last MEMRESIFG can be used
- SAMPCNT must be programmed by SW to a suitable value based on threshold setting for DMA operation
- The conversion overflow flag OVIFG is set when the ADC updates MEMRESx before the previous sample is read by the CPU or DMA
- The conversion underflow flag UVIFG is set when the CPU or DMA reads the FIFODAT register before the conversion result is available in the MEMRESx registers.
Note: Single conversion mode with FIFO enabled is not recommended for CPU or DMA based operation. It will lead to underflow condition and unwanted 16-bit data will have to be discarded in software.
- Sequence Conversion and Repeat Sequence Conversion
- Configure STARTADD bits to select the first MEMCTL in the sequence
- Configure ENDADD bits to select the last MEMCTL in the sequence
- MEMCTLx is NOT correlated to MEMRESx
- MEMRESx is correlated to MEMRESIFGx
- Configure each MEMCTLx CHANSEL bits to select the desired ADC channels
- Conversion data is loaded sequentially into MEMRES0,1,2,….N (organized as a FIFO)
- The CPU or DMA must read ADC samples from the dedicated FIFODAT register and not from MEMRES registers directly
- Data in the FIFO is always compacted with two samples and provided as 32-bit data upon a FIFODAT read by CPU or DMA
- MEMRESIFGx can be used as a threshold condition to generate a CPU interrupt or DMA trigger
- For full use of the FIFO, the last MEMRESIFG can be used
- SAMPCNT must be programmed by SW to a suitable value based on threshold setting for DMA operation
- The conversion overflow flag OVIFG is set when the ADC updates MEMRESx before the previous sample is read by the CPU or DMA
- The conversion underflow flag UVIFG is set when the CPU or DMA reads the FIFODAT register before the conversion result is available in the MEMRESx registers
Note:
- The data in FIFODAT register won't be cleared automatically after CPU or DMA
reads. New conversion data overwrites the previous data in FIFODAT register.
- To ensure synchronized
reading of bytes from the 32-bit FIFO, which stores 16-bit samples, specific
DMA triggers can be used. In particular, selecting MEMRES1, MEMRES3,
MEMRES5, MEMRES7, MEMRES9 and MEMRES11 will synchronize the reading
of bytes from the FIFO with the corresponding MEMRESx bytes.
- If the ADC is disabled during either the repeat sequence mode or normal
repeat mode, it's worth noting that an additional conversion may occur
before the ADC completely stops.
Table 12-5 ADC-DMA/CPU Operation Summary MatrixConversion Mode | FIFO Disabled (FIFOEN=0) Samples not compacted Read from MEMRESx registers directly | FIFO Enabled (FIFOEN=1) Samples always compacted Read from FIFODAT register only |
---|
CPU Read/Write | DMA Read/Write | CPU Read/Write | DMA Read/Write |
---|
Single | Supported | Supported SAMPCNT=1 Sample in 16 bits | Not recommended Underflow flag will set Unwanted 16-bits should be ignored | Not recommended Underflow flag will set Unwanted 16-bits should be ignored |
Repeat Single | Supported | Supported SAMPCNT=1 Sample in 16 bits | Supported MEMRESIFG=CPU interrupt FIFODAT read in 32-bits | Supported MEMRESIFG=DMA trigger SAMPCNT=Samples in 32-bits |
Sequence | Supported | Supported SAMPCNT=Sample in 16 bits STARTADD<ENDADD | Supported MEMRESIFG=CPU interrupt FIFODAT read in 32-bits | Supported MEMRESIFG=DMA trigger SAMPCNT=Samples in 32-bits |
Repeat Sequence | Supported | Not Supported | Supported MEMRESIFG=CPU interrupt FIFODAT read in 32-bits | Supported MEMRESIFG=DMA trigger SAMPCNT=Samples in 32-bits |