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.

Example for DMAxSA DMAxDA

Hi,

please give me an C-Statement for access to the registers.

uint8_t buf[512].

DMA0SA= buf;

This doesn' work.

regards,

Steffen

  • Hi Steffen,

    Here's a code example for the F5438A which shows how to set an address for DMAxSA:

    /* --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--*/
    //******************************************************************************
    //   MSP430F543xA Demo - DMA0, Single Transfer in Block Mode UART1 9600, ACLK
    //
    //   Description: DMA0 is used to transfer a string as a block to USCI_A0.
    //   USCIA0TXIFG WILL trigger DMA0. "Hello World" is TX'd via 9600 baud on
    //   USCI_A0. Watchdog in interval mode triggers block transfer every 1000ms.
    //   Level senstive trigger used for USCIA0TXIFG to prevent loss of inital edge
    //   sensitive triggers - USCIA0TXIFG which is set at POR.
    //   ACLK = UCLK 32768Hz, MCLK = SMCLK = default DCO 1048576Hz
    //   Baud rate divider with 32768hz XTAL @9600 = 32768Hz/9600 = 3.41 (0003h 4Ah)
    //
    //                 MSP430F5438A
    //             -----------------
    //         /|\|              XIN|-
    //          | |                 | 32768Hz
    //          --|RST          XOUT|-
    //            |                 |
    //            |             P3.4|------------> "Hello World"
    //            |                 | 9600 - 8N1
    //
    //  M. Morales
    //  Texas Instruments Inc.
    //  June 2009
    //  Built with CCE v3.1 Build 3.2.3.6.4 & IAR Embedded Workbench Version: 4.11B
    //******************************************************************************
    
    #include <msp430.h>
    
    const char String1[13] = "Hello World\r\n";
    
    int main(void)
    {
      WDTCTL = WDT_ADLY_1000;                   // WDT 1000ms, ACLK, interval timer
      SFRIE1 |= WDTIE;                          // Enable WDT interrupt
      P3SEL |= 0x30;                            // P3.4,5 = USCI_A0 TXD/RXD
      UCA0CTL1 |= UCSWRST;                      // 8-bit characters
      UCA0CTL1 = UCSSEL_1;                      // CLK = ACLK
      UCA0BR0 = 0x03;                           // 32k/9600=3.41
      UCA0BR1 = 0x00;
      UCA0MCTL = UCBRS_3+UCBRF_0;               // Modulation
      UCA0CTL1 &= ~UCSWRST;                     // Release USCI state machine
    
      DMACTL0 = DMA0TSEL_17;                    // USCI_A0 TXIFG trigger
      __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) String1);
                                                // Source block address
      __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA0TXBUF);
                                                // Destination single address
      DMA0SZ = sizeof(String1);                 // Block size
      DMA0CTL = DMASRCINCR_3+DMASBDB+DMALEVEL;  // Repeat, inc src
    
      __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ interrupts
      __no_operation();                         // Required only for debugger
    }
    
    //------------------------------------------------------------------------------
    // Trigger DMA block transfer
    //------------------------------------------------------------------------------
    #pragma vector=WDT_VECTOR
    __interrupt void WDT_ISR(void)
    {
      DMA0CTL |= DMAEN;                         // Enable
    }
    

    Try checking the code examples for your particular device, or you could also use DriverLib which includes drivers for MSP430 peripherals including DMA.

    More info here: http://www.ti.com/lsds/ti/microcontroller/16-bit_msp430/msp430_software_landing.page 

    Regards,

    Luis R

  • Hi Luis,

    this were just my tries.

    The compiler throws:

    ../sdcard/sd_raw.c", line 535: error #770: conversion from pointer to smaller integer

    I've appended the files.

    regards,

    Steffen

    /*
     *
     *
    "D:\\Programme\\TI-CCS\\ccsv5\\utils\\bin\\gmake" -j 2 sdcard/sd_raw.obj
    'Building file: ../sdcard/sd_raw.c'
    'Invoking: MSP430 Compiler'
    "D:/Programme/TI-CCS/ccsv5/tools/compiler/msp430_4.2.3/bin/cl430" -vmspx --abi=coffabi --code_model=large
     --data_model=restricted --near_data=globals -O2 --opt_for_speed=5
      --include_path="D:/Programme/TI-CCS/ccsv5/ccs_base/msp430/include"
       --include_path="P:/vhdl/medicalmove/branches/RunSaferbackup/MotionFit_With_eMPL511_Release/sdcard"
    ...
     -g --gcc --define=__MSP430F5528__ --define=LITTLE_ENDIAN --define=LOG_DEFINE --define=LIS_INT_BUG
      --define=BACKUP --define=H3LIS331DL --define=SD_CARD --define=SD_UCA0 --define=USE_DMP
       --define=MPL_LOG_NDEBUG=1 --define=NO_CONFIG_INTERFACE_USB --define=MPU9150
        --define=I2C_B0 --define=I2C_B1 --define=EMPL --define=EMPL_TARGET_MSP430
        --display_error_number --emit_warnings_as_errors --diag_suppress=10204
         --diag_suppress=179 --diag_suppress=112 --diag_wrap=off --silicon_errata=CPU21
          --silicon_errata=CPU22 --silicon_errata=CPU23 --silicon_errata=CPU40
           --printf_support=full --c_src_interlist --preproc_with_compile
            --preproc_dependency="sdcard/sd_raw.pp" --obj_directory="sdcard"  "../sdcard/sd_raw.c"
     *
     */
    
    /* Output:
     * > Compilation failure
    "../sdcard/dma_test.c", line 18: error #770: conversion from pointer to smaller integer
    "../sdcard/dma_test.c", line 20: error #770: conversion from pointer to smaller integer
    2 errors detected in the compilation of "../sdcard/dma_test.c".
    gmake: *** [sdcard/dma_test.obj] Error 1
     */
    
    #include <msp430.h>
    
    const char String1[13] = "Hello World\r\n";
    
    int main(void)
    {
      WDTCTL = WDT_ADLY_1000;                   // WDT 1000ms, ACLK, interval timer
      SFRIE1 |= WDTIE;                          // Enable WDT interrupt
      P3SEL |= 0x30;                            // P3.4,5 = USCI_A0 TXD/RXD
      UCA0CTL1 |= UCSWRST;                      // 8-bit characters
      UCA0CTL1 = UCSSEL_1;                      // CLK = ACLK
      UCA0BR0 = 0x03;                           // 32k/9600=3.41
      UCA0BR1 = 0x00;
      UCA0MCTL = UCBRS_3+UCBRF_0;               // Modulation
      UCA0CTL1 &= ~UCSWRST;                     // Release USCI state machine
    
      DMACTL0 = DMA0TSEL_17;                    // USCI_A0 TXIFG trigger
      __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) String1);
                                                // Source block address
      __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA0TXBUF);
                                                // Destination single address
      DMA0SZ = sizeof(String1);                 // Block size
      DMA0CTL = DMASRCINCR_3+DMASBDB+DMALEVEL;  // Repeat, inc src
    
      __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3 w/ interrupts
      __no_operation();                         // Required only for debugger
    }
    
    //------------------------------------------------------------------------------
    // Trigger DMA block transfer
    //------------------------------------------------------------------------------
    #pragma vector=WDT_VECTOR
    __interrupt void WDT_ISR(void)
    {
      DMA0CTL |= DMAEN;                         // Enable
    }
    

  • Hi Steffen,

    The cause of the problem is most likely because you are using the "restricted" memory model. The pointer is longer than 16-bits since you can access the whole 20-bit memory map, and so the compiler says that the pointer was converted to a smaller integer.

    This is usually a warning in CCS but you seem to have all warnings enabled as errors.

    In any case, you could try a couple of things:

    DMA0SA =  (__SFR_FARPTR) (unsigned long) &String1;

    or,

    unsigned long addr;
    addr = (unsigned long)&DMA0SA;
    __data16_write_addr((unsigned short) addr,(unsigned long) &String1);

     

    The second option is similar to the implementation in DriverLib.

     

    Regards,

    Luis R

  • Hi Luis,

    that works. I have enabled all warnings as errors.

    regards,

    Steffen

**Attention** This is a public forum