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 15-5 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 number of ADC samples for DMA operation. Each DMA transfer will be a single ADC result in non-FIFO mode.
- 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 in ADC sequence conversion mode, the MEMCTL start address should be smaller than the end address as the DMA source address does not roll back. Repeat sequence conversion mode cannot fill a buffer greater than the number of channels because the DMA does not have a circular mode. Once a sequence is completed, the DMA would need to be manually reconfigured to set the new destination address in order to fill a buffer larger than the number of channels in the sequence.
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) where N is the number of MEMRES channels in the device.
- 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 FIFODATA read by CPU or DMA
- MEMRESIFGx should be used as a threshold condition to generate a CPU interrupt or DMA trigger
- 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) where N is the number of MEMRES channels in the device.
- 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 FIFODATA read by CPU or DMA
- MEMRESIFGx can be used as a threshold condition to generate a CPU interrupt or DMA trigger
- Any MEMRESIFGx can be selected but improper selections can lead to an UVIFG or OVIFG getting set based on DMA speeds and ADC sampling speeds.
- 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
Table 15-5 ADC-DMA/CPU Operation Summary Matrix| Conversion 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 |