试听了下,杂音很大。软件修改木有i成功。硬件不敢随意修改.
现在听的头有电晕。就不详细说IIS了,先发代码。 那位大婶有空弄下杂音问题!!!
IIS为中断方式.从SD卡读取WAV文件..文件数据头部没有进行处理.SD卡程序参照之前发的笔记
IIS中断方式. 中断方式为I2S_TX_FIFO_THRESHOLD也就是当FIFO的内容少于4字节的时候就会触发中断.中断里面我们就可以加载数据了。
方式:
初始化中断---->这时候FIFO数据为0触发中断---->放入数据--->发送数据-->当数据小于等于4的时候又出发中断-->放入数据。
具体的部分自己处理......很多东西没完善、
再次希望那位大婶解决一下杂音问题..看下是我数据发送的时候出问题,还是硬件有瑕疵!!!
//extern uint32_t SystemFrequency;
/* Unlock the locked registers */
UNLOCKREG();
/* Enable 12M OSC */
DrvSYS_SetOscCtrl(E_SYS_XTL12M, 1);
/* Enable PLL */
DrvSYS_SetPLLMode(0);
Delay(1000);
DrvSYS_SelectHCLKSource(2);
Delay(100);
系统PLL初始化..一定要有
IIS初始画和回调函数
#include "PlayFrequency.h"
uint32_t PcmPlayBuff[BUFF_LEN] = {0};
uint32_t u32PlayPos_In = 0;
uint32_t u32PlaySend512Flage=1;
uint8_t DestArray[512]={0};
void Tx_thresholdCallbackfn(uint32_t status)
{
uint32_t i;
for ( i = 0; i <4 ; i++)
{
_DRVI2S_WRITE_TX_FIFO(DestArray[u32PlayPos_In++]);
}
if(u32PlayPos_In>512)
{
u32PlaySend512Flage=0;
u32PlayPos_In=0;
}
// printf("Send IIS data.\n");
}
void InitI2s()
{
S_DRVI2S_DATA_T st;
/* Tri-state for FS and BCLK of CODEC */
DrvGPIO_Open(E_GPC, 0, E_IO_OPENDRAIN);
DrvGPIO_Open(E_GPC, 1, E_IO_OPENDRAIN);
DrvGPIO_SetBit(E_GPC, 0);
DrvGPIO_SetBit(E_GPC, 1);
/* Set I2C0 I/O */
//DrvGPIO_InitFunction(E_FUNC_I2C0);
SystemCoreClock = DrvSYS_GetHCLKFreq();
/* Open I2C0, and set clock = 100Kbps */
//DrvI2C_Open(I2C_PORT0, 100000);
/* Enable I2C0 interrupt and set corresponding NVIC bit */
//DrvI2C_EnableInt(I2C_PORT0);
/* Configure I2S */
st.u32SampleRate = 32000;
st.u8WordWidth = DRVI2S_DATABIT_16;
st.u8AudioFormat = DRVI2S_MONO; //DRVI2S_MONO ,DRVI2S_STEREO
st.u8DataFormat = DRVI2S_FORMAT_MSB; //DRVI2S_FORMAT_MSB ,DRVI2S_FORMAT_I2S
st.u8Mode = DRVI2S_MODE_MASTER;
st.u8TxFIFOThreshold = DRVI2S_FIFO_LEVEL_WORD_4;
st.u8RxFIFOThreshold = DRVI2S_FIFO_LEVEL_WORD_4;
DrvI2S_Open(&st);
/* Configure CODEC */
//WAU8822_Setup();
/* Set I2S I/O */
DrvGPIO_InitFunction(E_FUNC_I2S);
/* Set MCLK and enable MCLK */
DrvI2S_SetMCLKFreq(12000000);
DrvI2S_EnableMCLK();
DrvI2S_EnableInt(I2S_TX_FIFO_THRESHOLD, Tx_thresholdCallbackfn);
DrvI2S_EnableTx();
}
|