SAI DMA demo with DAC3120

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SAI DMA demo with DAC3120

1,335 次查看
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?

标签 (1)
0 项奖励
回复
2 回复数

1,218 次查看
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Ryan Lush

Could you share what MCU and Drivers are you using?

Best regards

0 项奖励
回复

1,218 次查看
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 <[email protected]>

0 项奖励
回复