This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC-DMA set up MSP430fr5969

Other Parts Discussed in Thread: MSP430WARE

Hi,

i would like to move data from ADC12MEM0 from its memory location to a choosen mamoery location by the means of DMA.

the ADC is working correctly.

Here it follows DMA configuration :

__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) ADC_MEM_0_ADDRESS); //SHOULD BE ADC12MEM0 // Source single address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) IMAGE_START_ADDRESS); // Destination single address
DMACTL0 =DMA0TSEL_26; //DMA Trigger Assignments:26==ADC12 end of conversion
DMA0SZ =12544; // Block size
DMA0CTL = DMADT_4 | DMASRCINCR_0 | DMADSTINCR_3 | DMADSTBYTE |DMASRCBYTE; // Rpt, inc


DMA0CTL |= DMAEN; // Enable DMA0

i expect the DMA to transfer 12544 byte at once, and at each ADCcycle i expect DMA0SZ to decrease of one unit.

But looking at DMA0SZ durign the dug it seems like it doen't even decreases at any ADC cycle

despite what it is written in the datasheet SLAU367b

"DMAxSZ register decrements with each word or byte transfer."

what am i missing?

thx in advance

irene

  • There may be a useful example in the MSP430F55xx examples under MSP430ware_1_80_00_17 - it is the dma_04 example, and it may do a similar thing to what you are trying to do. It may also have some of the DMA and ADC setup info that would be required.

    Hopefully that helps.

  • thx i will have a look at it

    Irene

  • HI ,

    i can't find the example dma_04...

    would you be so kind to send me the example code?

    It would be really kind of you

    Thx in advance

    Irene

  • /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //  MSP430F552x Demo - DMA0, Single transfer using ADC12 triggered by TimerB
    //
    //  Description: This software uses TBCCR1 as a sample and convert input into
    //  the A0 of ADC12. ADC12IFG is used to trigger a DMA transfer and DMA
    //  interrupt triggers when DMA transfer is done. TB1 is set as an output and
    //  P1.0 is toggled when DMA ISR is serviced.
    //  ACLK = REFO = 32kHz, MCLK = SMCLK = default DCO 1048576Hz
    //
    //                 MSP430F552x
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32kHz
    //          --|RST          XOUT|-
    //            |                 |
    //            |             P1.0|-->LED
    //            |             P5.7|-->TB1 output
    //            |                 |
    //            |             P6.0|<--A0
    //
    //   Bhargavi Nisarga
    //   Texas Instruments Inc.
    //   April 2009
    //   Built with CCSv4 and IAR Embedded Workbench Version: 4.21
    //******************************************************************************
    
    #include <msp430.h>
    
    unsigned int DMA_DST;						// ADC conversion result is stored in this variable 
    
    int main(void)
    {
      WDTCTL = WDTPW+WDTHOLD;                   // Hold WDT
    
      P1OUT &= ~BIT0;                           // P1.0 clear
      P1DIR |= BIT0;                            // P1.0 output
      P5SEL |= BIT7;                            // P5.7/TB1 option select
      P5DIR |= BIT7;                            // Output direction
      P6SEL |= BIT0;                            // Enable A/D channel A0  
    
      //Setup Timer B0
      TBCCR0 = 0xFFFE;
      TBCCR1 = 0x8000;
      TBCCTL1 = OUTMOD_3;                       // CCR1 set/reset mode
      TBCTL = TBSSEL_2+MC_1+TBCLR;              // SMCLK, Up-Mode
    
      // Setup ADC12
      ADC12CTL0 = ADC12SHT0_15+ADC12MSC+ADC12ON;// Sampling time, MSC, ADC12 on
      ADC12CTL1 = ADC12SHS_3+ADC12CONSEQ_2;     // Use sampling timer; ADC12MEM0
                                                // Sample-and-hold source = CCI0B =
                                                // TBCCR1 output
                                                // Repeated-single-channel
      ADC12MCTL0 = ADC12SREF_0+ADC12INCH_0;     // V+=AVcc V-=AVss, A0 channel
      ADC12CTL0 |= ADC12ENC;
    
      // Setup DMA0
      DMACTL0 = DMA0TSEL_24;                    // ADC12IFGx triggered
      DMACTL4 = DMARMWDIS;                      // Read-modify-write disable
      DMA0CTL &= ~DMAIFG;
      DMA0CTL = DMADT_4+DMAEN+DMADSTINCR_3+DMAIE; // Rpt single tranfer, inc dst, Int
      DMA0SZ = 1;                               // DMA0 size = 1
    
      __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &ADC12MEM0);
                                                // Source block address
      __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &DMA_DST);
                                                // Destination single address    
      __bis_SR_register(LPM0_bits + GIE);       // LPM0 w/ interrupts
      __no_operation();                         // used for debugging
    }
    
    //------------------------------------------------------------------------------
    // DMA Interrupt Service Routine
    //------------------------------------------------------------------------------
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=DMA_VECTOR
    __interrupt void DMA_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(DMA_VECTOR))) DMA_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch(__even_in_range(DMAIV,16))
      {
        case 0: break;
        case 2:                                 // DMA0IFG = DMA Channel 0
          P1OUT ^= BIT0;                        // Toggle P1.0 - PLACE BREAKPOINT HERE AND CHECK DMA_DST VARIABLE
          break;
        case 4: break;                          // DMA1IFG = DMA Channel 1
        case 6: break;                          // DMA2IFG = DMA Channel 2
        case 8: break;                          // DMA3IFG = DMA Channel 3
        case 10: break;                         // DMA4IFG = DMA Channel 4
        case 12: break;                         // DMA5IFG = DMA Channel 5
        case 14: break;                         // DMA6IFG = DMA Channel 6
        case 16: break;                         // DMA7IFG = DMA Channel 7
        default: break;
      }
    }
    

    Hopefully the file is attached. Sorry, I have not tried to attach a file before. When I installed the MSP430ware, I found the file at this location:

    C:\ti\msp430\MSP430ware_1_80_01_03\examples\devices\5xx_6xx\MSP430F55xx_Code_Examples\C

     

  • How do you operate the ADC12?

    The FR family users guide doesn’t really tell how ADC12 and DMA work together. You must read a lot between the lines here. The users guide seems to only talk about ADC10. But your device has an ADC12.
    The F5x family (not FR) users guide has a note about the ADC12,and chances are that the two versions of ADC12 don't differ much here:

    11.2.11 Using ADC12 With the DMA Controller
    MSP430 devices with an integrated DMA controller can automatically move data from any ADC12MEMx register to another location. DMA transfers are done without CPU intervention and independently of any low-power modes. The DMA controller increases throughput of the ADC12 module, and enhances lowpower applications allowing the CPU to remain off while data transfers occur.
    DMA transfers can be triggered from any ADC12IFG flag. When CONSEQx = {0,2}, the ADC12IFG flag for the ADC12MEMx used for the conversion can trigger a DMA transfer. When CONSEQx = {1,3}, the ADC12IFG flag for the last ADC12MEMx in the sequence can trigger a DMA transfer. Any ADC12IFG flag is automatically cleared when the DMA controller accesses the corresponding ADC12MEMx.

     IIRC, It is also important that you do NOT set the IE bit for this trigger, so either DMA or interrupt.

**Attention** This is a public forum