如题, 板子25M外部晶振,DSP用的是nxp的tef6635, 没用mck输出, 44.1k, 无论是音乐是64kbps还是128k, 320k效果一样,个人觉得不是解码速度慢的问题。
整体用的是原子的例程,没跑系统, 很多内存申请用的是外部ram.
请教各位高手可能是什么原因?
谢谢
const u16 I2S_PSC_TBL[][5]=
{
// fs/10, PLLI2SN, PLLI2SR, I2SDIV, ODD
{800 , 192, 2, 187, 1}, //8Khz²ÉÑùÂÊ
{1600, 192, 3, 62, 1}, //16Khz²ÉÑùÂÊ
{2205, 290, 3, 68, 1}, //22.05Khz²ÉÑùÂÊ
{3200, 256, 2, 62, 1}, //32Khz²ÉÑùÂÊ
{4410, 302, 2, 53, 1}, //44.1Khz²ÉÑùÂÊ
{4800, 192, 5, 12, 1}, //48Khz²ÉÑùÂÊ
{9600, 384, 5, 12, 1}, //96Khz²ÉÑùÂÊ
{19200,424, 3, 11, 1}, //192Khz²ÉÑùÂÊ
}
u8 I2S2_SampleRate_Set(u32 samplerate)
{
u8 i=0;
u32 tempreg=0;
samplerate/=10;//ËõС10±¶
for(i=0;i<(sizeof(I2S_PSC_TBL)/10);i++)//¿´¿´¸Ä²ÉÑùÂÊÊÇ·ñ¿ÉÒÔÖ§³Ö
{
if(samplerate==I2S_PSC_TBL[i][0])break;
}
RCC_PLLI2SCmd(DISABLE);//ÏȹرÕPLLI2S
if(i==(sizeof(I2S_PSC_TBL)/10))return 1;//ËѱéÁËÒ²ÕÒ²»µ½
RCC_PLLI2SConfig((u32)I2S_PSC_TBL[i][1],(u32)I2S_PSC_TBL[i][2]);//ÉèÖÃI2SxCLKµÄƵÂÊ(x=2) ÉèÖÃPLLI2SN PLLI2SR
RCC->CR|=1<<26; //¿ªÆôI2SʱÖÓ
while((RCC->CR&1<<27)==0); //µÈ´ýI2SʱÖÓ¿ªÆô³É¹¦.
tempreg=I2S_PSC_TBL[i][3]<<0; //ÉèÖÃI2SDIV
tempreg|=I2S_PSC_TBL[i][3]<<8; //ÉèÖÃODDλ
tempreg|=0<<9; //ʹÄÜMCKOEλ,Êä³öMCK
SPI2->I2SPR=tempreg; //ÉèÖÃI2SPR¼Ä´æÆ÷
return 0;
}
I2S2_Init(I2S_Standard_Phillips,I2S_Mode_MasterTx,I2S_CPOL_Low,I2S_DataFormat_16bextended); // 这里用I2S_DataFormat_16b的话播放就会始终有断音。
I2S2_TX_DMA_Init(p1->i2sbuf1, p1->i2sbuf2,mp3ctrl->outsamples, TRUE);//ÅäÖÃTX DMA
void I2S2_TX_DMA_Init(u8* buf0,u8 *buf1,u16 num, BOOL DoubleBuffer_Flag)
{
NVIC_InitTypeDef NVIC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1,ENABLE);//DMA1ʱÖÓʹÄÜ
DMA_DeInit(DMA1_Stream4);
while (DMA_GetCmdStatus(DMA1_Stream4) != DISABLE){}//µÈ´ýDMA1_Stream1¿ÉÅäÖÃ
/* ÅäÖÃ DMA Stream */
DMA_InitStructure.DMA_Channel = DMA_Channel_0; //ͨµÀ0 SPI2_TXͨµÀ
DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&SPI2->DR;//ÍâÉèµØַΪ:(u32)&SPI2->DR
DMA_InitStructure.DMA_Memory0BaseAddr = (u32)buf0;//DMA ´æ´¢Æ÷0µØÖ·
DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;//´æ´¢Æ÷µ½ÍâÉèģʽ
DMA_InitStructure.DMA_BufferSize = num;//Êý¾Ý´«ÊäÁ¿
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//ÍâÉè·ÇÔöÁ¿Ä£Ê½
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//´æ´¢Æ÷ÔöÁ¿Ä£Ê½
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;//ÍâÉèÊý¾Ý³¤¶È:16λ
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;//´æ´¢Æ÷Êý¾Ý³¤¶È£º16λ
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;// ʹÓÃÑ»·Ä£Ê½
DMA_InitStructure.DMA_Priority = DMA_Priority_High;//¸ßÓÅÏȼ¶
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; //²»Ê¹ÓÃFIFOģʽ
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;//ÍâÉèÍ»·¢µ¥´Î´«Êä
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;//´æ´¢Æ÷Í»·¢µ¥´Î´«Êä
DMA_Init(DMA1_Stream4, &DMA_InitStructure);//³õʼ»¯DMA Stream
if(DoubleBuffer_Flag)
{
DMA_DoubleBufferModeConfig(DMA1_Stream4,(u32)buf1,DMA_Memory_0);//Ë«»º³åģʽÅäÖÃ
DMA_DoubleBufferModeCmd(DMA1_Stream4,ENABLE);//Ë«»º³åģʽ¿ªÆô
}
DMA_ITConfig(DMA1_Stream4,DMA_IT_TC,ENABLE);//¿ªÆô´«ÊäÍê³ÉÖжÏ
NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream4_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;//ÇÀÕ¼ÓÅÏȼ¶0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;//×ÓÓÅÏȼ¶0
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ʹÄÜÍⲿÖжÏͨµÀ
NVIC_Init(&NVIC_InitStructure);//ÅäÖÃ
}
之前用的是I2S_DataFormat_16bextended, I2S2_WS是22.05kHz, 效果就是前面那种.
原子例程里用的是I2S_DataFormat_16bextended, 请问为什么会这样啊?
一周热门 更多>