最近在做关于音频的项目,项目是这样的和ath8809通信,用sai接口,时钟频率为256k,采样率为8k,stm32f767做为从设备,采用pcm短帧格式,单声道,发现通信一段时间,出现帧滞后的现象,不知道我哪配置的不对,下面是我的代码,哪位大佬可以指点我一下,谢谢啦(通过示波器抓取ath8809给我发来的数据,是一帧32位,只有前16位有效,后面全是0)
HAL_SAI_DeInit(&sai1b_handler);
sai1b_handler.Instance = SAI1_Block_B;
sai1b_handler.Init.AudioMode = SAI_MODESLAVE_RX;
sai1b_handler.Init.Synchro = SAI_SYNCHRONOUS;
sai1b_handler.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
sai1b_handler.Init.NoDivider = SAI_MASTERDIVIDER_DISABLE;
sai1b_handler.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF;
sai1b_handler.Init.MonoStereoMode = SAI_MONOMODE;
sai1b_handler.Init.Protocol = SAI_FREE_PROTOCOL;
sai1b_handler.Init.DataSize = SAI_DATASIZE_16;
sai1b_handler.Init.FirstBit = SAI_FIRSTBIT_MSB;
sai1b_handler.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE;
sai1b_handler.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_8K;
sai1b_handler.FrameInit.FrameLength = 32;
sai1b_handler.FrameInit.ActiveFrameLength = 1;
sai1b_handler.FrameInit.FSDefinition = SAI_FS_STARTFRAME;
sai1b_handler.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH;
sai1b_handler.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT;
sai1b_handler.SlotInit.FirstBitOffset = 0;
sai1b_handler.SlotInit.SlotSize = SAI_SLOTSIZE_16B;
sai1b_handler.SlotInit.SlotNumber = 2;
sai1b_handler.SlotInit.SlotActive = SAI_SLOTACTIVE_0|SAI_SLOTACTIVE_1;
HAL_SAI_Init(&sai1b_handler);
saib_dma_enable();
// __HAL_SAI_CLEAR_FLAG(&sai1b_handler,SAI_FLAG_AFSDET);
// __HAL_SAI_CLEAR_FLAG(&sai1b_handler,SAI_FLAG_LFSDET);
HAL_SAI_DeInit(&sai1a_handler);
sai1a_handler.Instance = SAI1_Block_A;
sai1a_handler.Init.AudioMode = SAI_MODESLAVE_TX;
sai1a_handler.Init.Synchro = SAI_ASYNCHRONOUS;
sai1a_handler.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
sai1a_handler.Init.NoDivider = SAI_MASTERDIVIDER_DISABLE;
sai1a_handler.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_1QF;
sai1a_handler.Init.MonoStereoMode = SAI_MONOMODE;
sai1a_handler.Init.Protocol = SAI_FREE_PROTOCOL;
sai1a_handler.Init.DataSize = SAI_DATASIZE_16;
sai1a_handler.Init.FirstBit = SAI_FIRSTBIT_MSB;
sai1a_handler.Init.ClockStrobing = SAI_CLOCKSTROBING_RISINGEDGE;
sai1a_handler.Init.AudioFrequency = SAI_AUDIO_FREQUENCY_8K;
sai1a_handler.FrameInit.FrameLength = 32;
sai1a_handler.FrameInit.ActiveFrameLength = 1;
sai1a_handler.FrameInit.FSDefinition = SAI_FS_STARTFRAME;
sai1a_handler.FrameInit.FSPolarity = SAI_FS_ACTIVE_HIGH;
sai1a_handler.FrameInit.FSOffset = SAI_FS_BEFOREFIRSTBIT;
sai1a_handler.SlotInit.FirstBitOffset = 0;
sai1a_handler.SlotInit.SlotSize = SAI_SLOTSIZE_16B
sai1a_handler.SlotInit.SlotNumber = 2;
sai1a_handler.SlotInit.SlotActive = SAI_SLOTACTIVE_0|SAI_SLOTACTIVE_1;
HAL_SAI_Init(&sai1a_handler);
saia_dma_enable();
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>