AnsweredAssumed Answered

SAI DMA demo with DAC3120

Question asked by Ryan Lush on Apr 25, 2018
Latest reply on May 7, 2018 by Ryan Lush

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?

Outcomes