SAI DMA demo with DAC3120

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SAI DMA demo with DAC3120

364 Views
ryanlush
Contributor IV

I am trying to get the sai_dma_demo app to work with a DAC3120 codec. Based on the example I came up with this code

            do {               

                I2S_STATISTICS_STRUCT stats;
                
                ioctl(g_I2S_fd, IO_IOCTL_I2S_WAIT_TX_EVENT,NULL);
                ioctl(g_I2S_fd, IO_IOCTL_I2S_GET_TX_STATISTICS, &stats);
        
                phraseDataToRead = ((phraseDataLength - phraseDataPlayed) > stats.SIZE) ? stats.SIZE : (phraseDataLength - phraseDataPlayed);

                SPI1_ReadAudioFlash(temp_buffer, (phraseDataOffset + phraseDataPlayed), phraseDataToRead);
                
                memcpy(stats.IN_BUFFER, temp_buffer, phraseDataToRead);
                
                if(phraseDataPlayed == 0)
                    ioctl(g_I2S_fd, IO_IOCTL_I2S_START_TX, NULL);
                
                ioctl(g_I2S_fd, IO_IOCTL_I2S_UPDATE_TX_STATUS, &phraseDataToRead);
                
                phraseDataPlayed += phraseDataToRead;
            } while (phraseDataPlayed < phraseDataLength);

but this does not create the clean sinewave I am trying to play. It's off frequency by a factor of three and barely looks like a sine wave.

I noticed that when I inspect stats the second time through the loop,

PACKETS_PROCESSED

PACKETS_QUEUED

PACKETS_REQUESTED

are all 4096

IN_BUFFER & OUT_BUFFER both point to the same address and BUFFER_ERROR is incremented by 1. Any ideas as to what causes the DMA BUFFER_ERROR?

Labels (1)
0 Kudos
2 Replies

247 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Ryan Lush

Could you share what MCU and Drivers are you using?

Best regards

0 Kudos

247 Views
ryanlush
Contributor IV

This is the processor

MK24FN1M0VLQ12

I am using MQX 4.2 along with KSDK

On Mon, May 7, 2018 at 1:39 PM, jorge_a_vazquez <admin@community.nxp.com>

0 Kudos