Hi, i'm trying to understand the function of the DMA, trying to implement a program that makes a kind of "echo", reading a data from a COM port and return it from another.
I'm trying this on a MSP430F5438.
Here is the code i'm using, based on a DMA example:
void 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
P5SEL |= 0xC0; // P3.4,5 = USCI_A0 TXD/RXD
UCA1CTL1 |= UCSWRST; // 8-bit characters
UCA1CTL1 = UCSSEL_1; // CLK = ACLK
UCA1BR0 = 0x03; // 32k/9600=3.41
UCA1BR1 = 0x00;
UCA1MCTL = UCBRS_3+UCBRF_0; // Modulation
UCA1CTL1 &= ~UCSWRST; // Release USCI state machine
//UCA1IE |= UCRXIE; // Enable USCI_A1 RX interrupt
DMACTL0 = DMA0TSEL_17; // USCI_A0 TXIFG trigger
__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) &UCA1RXBUF);
// Source block address
__data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &UCA0TXBUF);
// Destination single address
DMA0SZ = 1/*sizeof(String2)*/; // Block size
DMA0CTL = DMASRCINCR_3+DMASBDB; // Repeat, inc src
__bis_SR_register(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
UCA0IFG &= ~UCTXIFG; // Toggle TX IFG to trigger first
UCA0IFG |= UCTXIFG; // DMA transfer...
}
I open two hiperterminals connected to the COM ports, but I don't recibe anything from USCIA0