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.
UCA0--UART DMA发送无法触发,DMA接收可以。
配置如下。不理解什么原因?
目前SPI用了通道0-1,正常 通道2用了UART接收。通道3配置如下,无法触发发送,只能使用UART_WRITE,或者UART_WRITEPOLLING。
{
DMA_initParam param = {0};
param.channelSelect = DMA_CHANNEL_3;
param.transferModeSelect = DMA_TRANSFER_SINGLE;
param.transferSize = len;
param.triggerSourceSelect = DMA_TRIGGERSOURCE_17;
param.transferUnitSelect = DMA_SIZE_SRCBYTE_DSTBYTE;
param.triggerTypeSelect = DMA_TRIGGER_HIGH;
DMA_init(¶m);
/*
* Configure DMA channel 0
* Use ADC10_A Memory Buffer as source
* Increment destination address after every transfer
*/
DMA_setSrcAddress(DMA_CHANNEL_3,
(uint32_t)buf,
DMA_DIRECTION_INCREMENT);
/*
* Base Address for the DMA Module
* Configure DMA channel 0
* Use ADC_Result[0] as destination
* Increment destination address after every transfer
*/
DMA_setDstAddress(DMA_CHANNEL_3,
USCI_A_UART_getTransmitBufferAddressForDMA (USCI_A0_BASE),
DMA_DIRECTION_UNCHANGED);
//Enable DMA channel 0 interrupt
//DMA_disableTransfers(DMA_CHANNEL_3);
//DMA_clearInterrupt(DMA_CHANNEL_3);
DMA_enableInterrupt(DMA_CHANNEL_3);
//Enable transfers on DMA channel 0
DMA_enableTransfers(DMA_CHANNEL_3);
DMA_startTransfer(DMA_CHANNEL_3);
}
li dong,
我看了MSP430F5529 code example, 一般你安装了CCS,MSPWare中就有,其对应的下列例程 “MSP430F55xx_dma_02.c”就是使用DMA-UART进行数据发送的。你可以参考一下。
MSP430F55xx_dma_01.c DMA0, Repeated Block to-from RAM, Software Trigger
MSP430F55xx_dma_02.c DMA0, Repeated Block UCA1UART 9600, TACCR2, ACLK
MSP430F55xx_dma_03.c SPI TX & RX using DMA0 & DMA1 Single Transfer in Fixed Address Mode
MSP430F55xx_dma_04.c DMA0, Single transfer using ADC12 triggered by TimerB
/* --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--*/ //****************************************************************************** // MSP430x552x Demo - DMA0, Repeated Block UCA1UART 9600, TACCR2, ACLK // // Description: DMA0 is used to transfer a string byte-by-byte as a repeating // block to UCA1TXBUF. Timer_A operates continuously at 32768Hz with CCR2IFG // triggering DMA0. "Hello World" is TX'd via 9600 baud UART1. // ACLK= TACLK 32768Hz, MCLK= SMCLK= default DCO ~ 1048576Hz // Baud rate divider with 32768hz XTAL @9600 = 32768Hz/9600 = 3.41 (000Dh 4Ah ) // //* An external watch crystal on XIN XOUT is required for ACLK *// // //* MSP430F169 Device Required *// // // MSP430x552x // ----------------- // /|\| XIN|- // | | | 32768Hz // --|RST XOUT|- // | | // | P4.4|------------> "Hello World" // | | 9600 - 8N1 // // // Bhargavi Nisarga // Texas Instruments Inc. // April 2009 // Built with CCSv4 and IAR Embedded Workbench Version: 4.21 //****************************************************************************** #include <msp430.h> static char String1[] = { "Hello World\r\n" }; int main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog //....................... P5SEL |= BIT4+BIT5; // Select XT1 UCSCTL6 &= ~(XT1OFF); // XT1 On UCSCTL6 |= XCAP_3; // Internal load cap UCSCTL3 = 0; // FLL Reference Clock = XT1 // Loop until XT1,XT2 & DCO stabilizes - In this case loop until XT1 and DCo settle do { UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG); // Clear XT2,XT1,DCO fault flags SFRIFG1 &= ~OFIFG; // Clear fault flags }while (SFRIFG1&OFIFG); // Test oscillator fault flag UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive strength UCSCTL4 |= SELA_0 + SELS_4 + SELM_4; // ACLK = LFTX1 // SMCLK = default DCO // MCLK = default DCO //................ P4SEL = BIT4+BIT5; // P4.4,5 = UART1 TXD/RXD // configure USCI_A1 UART UCA1CTL1 = UCSSEL_1; // ACLK UCA1BR0 = 0x03; // 32768Hz 9600 32k/9600=3.41 UCA1BR1 = 0x0; UCA1MCTL = UCBRS_3+UCBRF_0; // Modulation UCBRSx = 3 UCA1CTL1 &= ~UCSWRST; // **Initialize USCI state machine** // configure DMA0 DMACTL0 = DMA0TSEL_1; // 0-CCR2IFG __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) String1); // Source block address __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA1TXBUF); // Destination single address DMA0SZ = sizeof String1-1; // Block size DMA0CTL = DMADT_4 + DMASRCINCR_3 + DMASBDB + DMAEN;// Rpt, inc src, enable TA0CCR0 = 8192; // Char freq = TACLK/CCR0 TA0CCR2 = 1; // For DMA0 trigger TA0CTL = TASSEL_1 + MC_1; // ACLK, up-mode __bis_SR_register(LPM3_bits); // Enter LPM3 }