msp430 SD CARD-> DAC12 using DMA Transfer

Dear All, I have a small problem. I am trying to play a wave file from my SD card. I am not using FAT i am just reading raw data from the card.

I want to do this using DMA transfer.

I wrote the following code, but this does not output the wave file from the DAC.

Does anyone have any idea, what i should do?

Best Regards Kerem

#include #include #include #include #include #include //__no_init volatile unsigned long DMA0SZ @ DMA0SZ_;

unsigned long cardSize = 0; unsigned char status = 1; unsigned int timeout = 0; int i = 0; int k= 0; int kerem = 0; int filesize = 0; int* filePtr = NULL; int sector = 0;

unsigned char buffer[512];

void main(void) { WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer DCOCTL = CALDCO_16MHZ; BCSCTL1 = CALBC1_16MHZ; BCSCTL2 = SELM_0 | DIVS_2; //P1DIR |= 0x01; // Set P1.0 to output direction

P1DIR = BIT0 | BIT4; // Set P1.0 to output direction

P2DIR = BIT0 ; P5DIR = BIT4 | BIT5; P1SEL = BIT4; P2SEL = BIT0; P5SEL = BIT4 | BIT5; P6DIR = BIT6 ; P6SEL = BIT6; ADC12CTL0 = REFON; DAC12_0CTL = DAC12SREF_0 | DAC12RES | DAC12LSEL_2 | DAC12IR | DAC12AMP_7 | DAC12CALON;

while (DAC12_0CTL & DAC12CALON != 0){ } DMACTL0 =DMA0TSEL_5; DMACTL1 = 0;

DMA0CTL = DMADT_0 | DMADSTINCR_0 | DMASRCINCR_3 | DMADSTBYTE | DMASRCBYTE;

//Initialisation of the MMC/SD-card while (status != 0) // if return in not NULL an error did occur and the

// MMC/SD-card will be initialized again

{ status = mmcInit(); timeout++; if (timeout == 150) // Try 50 times till error { //printf ("No MMC/SD-card found!! %x\n", status); break; } }

while ((mmcPing() != MMC_SUCCESS)); // Wait till card is inserted

// Read the Card Size from the CSD Register cardSize = mmcReadCardSize(); mmcReadSector(sector, buffer); __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) buffer

+44);

// Source block address __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &DAC12_0DAT);

DMA0SZ = 64; TACCR0 = 1; TACCR1 = 1; TACCTL1 = OUTMOD_7; DMA0CTL = DMA0CTL | DMAEN | DMAIE; DAC12_0CTL = DAC12_0CTL | DAC12ENC | DAC12IFG ;

TACTL = TASSEL_1 | ID_0 | MC_1 | TACLR;

__enable_interrupt(); for (;;) {

P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR

i = 50000; // Delay do (i--); while (i != 0); } } #pragma vector = DMA_VECTOR __interrupt void DMA_int(void) {

sector++; mmcReadSector(sector, buffer); __data16_write_addr((unsigned short) &DMA0SA,(unsigned long) buffer); //__data16_write_addr((unsigned short) &DMA0SA,(unsigned long) wave); // Source block address __data16_write_addr((unsigned short) &DMA0DA,(unsigned long) &DAC12_0DAT);

DMA0SZ = 512; DMA0CTL |= DMAEN | DMAIE;

DAC12_0CTL = DAC12_0CTL | DAC12ENC | DAC12IFG ; }

--------------------------------------- Posted through

formatting link

Reply to
goode
Loading thread data ...

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.