Hello,
I am trying to use the DMA to transceive data from the SPI of a MSP430F5659. There are several things I don't really understand, and its not working properly.
First of all I initialize the DMA2 to transmit data via USCIA1 by defining the apropriate trigger (21: USCIA1TXIF). Here's the sourcecode:
void initDMA2(void) { /* reseting DMA for correct initializing */ DMA2_RESET_STATE; /* setting USCIA1TX as a trigger for the DMA (AD7490) */ DMACTL1 = 0 | DMA2_TRIGGER_AD7490_USCIA1TX; /* configuring the DMA channel for use in AD7490 serial communication routine */ DMA2CTL = 0 | DMASRCINCR0 | DMASRCBYTE | DMADSTBYTE | DMASRCINCR1 | DMALEVEL; }
i used some macros but they are working fine when iIcheck the registers (DMA2_RESET_STATE and DMA2_TRIGGER_AD7490_USCIA1TX).
as a next step I program the DMA2SA, DMA2DA and DMA2SZ :
/* creating pointer for SA */ char command_buf[2] = {0}; command_buf[0] = command_highByte; command_buf[1] = command_lowByte; DMA2_WRITE_AD7490_SA = (__SFR_FARPTR)command_buf[0]; /* set DMA source address */ DMA2_WRITE_AD7490_DA = (__SFR_FARPTR)&UCA1TXBUF; /* set DMA destination address */ DMA2_WRITE_AD7490_SZ = sizeof(command); /* bytes per transfer */ // DMA2_WRITE_AD7490_CTL &= ~ DMAIFG; /* reset interrupt flag */ DMA2_ACTIVATE_STATE; /* start DMA */ /* wait until DMA is finished */ while (!(DMA2CTL & DMAIFG));
with this initialization it works but I send as a test two HIGH_BYTES as dummys but I don't see them on my scope. There's a differnt bit-pattern. So what is going wrong here?
Additional to my problem I don't know how to get the DMA -> USCIA1 running without using the DMALEVEL trigger, because the EDGE trigger only works with a low to high transition (user manual) but the USCIA1TXIF is set before something is written to the USCIA1TXBUF, so the trigger request is never reached except I use the DMALEVEL trigger but there the manual says it's only for external triggering via DMAE0.
For reception I tried to use another DMA channel to trigger on the USCIA1RXIF but this is also not working, clearly because my writing attempt is faulty.
could anyone help me with this?
best regards
Benni