本帖最后由 Sam131208 于 2023-12-5 10:32 编辑
hc32l073 的 i2s DMA功能完全没有反应。 配置的引脚没有信号,DMA中断也没有进入。
static void start_dma(struct i2s_stream_t *stream, const void *src, uint16_t blk_size)
{
stc_dma_cfg_t stcDmaCfg;
Sysctrl_SetPeripheralGate(SysctrlPeripheralDma,TRUE); //´ò¿ªDMAʱÖÓ
DDL_ZERO_STRUCT(stcDmaCfg); //½á¹¹Ìå±äÁ¿ÖµÇåÁã
stcDmaCfg.enMode = DmaMskBlock; //Ñ¡Ôñ¿é´«Êä
stcDmaCfg.u16BlockSize = 0x01; //¿é´«Êä¸öÊý
stcDmaCfg.u16TransferCnt = blk_size; //¿é´«Êä´ÎÊý£¬Ò»´Î´«ÊäÊý¾Ý´óСΪ ¿é´«Êä¸öÊý*BUFFER_SIZE
stcDmaCfg.enTransferWidth = DmaMsk16Bit; //´«ÊäÊý¾ÝµÄ¿í¶È£¬´Ë´¦Ñ¡Ôñ×Ö(16Bit)¿í¶È
stcDmaCfg.enSrcAddrMode = DmaMskSrcAddrInc; //Ô´µØÖ·×ÔÔö
stcDmaCfg.enDstAddrMode = DmaMskDstAddrFix; //Ä¿µÄµØÖ·×ÔÔö
stcDmaCfg.enDestAddrReloadCtl = DmaMskDstAddrReloadEnable; //½ûÖ¹ÖØмÓÔØ´«ÊäÄ¿µÄµØÖ·
stcDmaCfg.enSrcAddrReloadCtl = DmaMskSrcAddrReloadEnable; //½ûÖ¹ÖØмÓÔØ´«ÊäÔ´µØÖ·
stcDmaCfg.enSrcBcTcReloadCtl = DmaMskBcTcReloadEnable; //½ûÖ¹ÖØмÓÔØBC/TCÖµ
stcDmaCfg.u32SrcAddress = (uint32_t)src; //Ö¸¶¨´«ÊäÔ´µØÖ·
stcDmaCfg.u32DstAddress = (uint32_t)(void*)&((M0P_I2S_TypeDef *) stream->dev)->DRL; //Ö¸¶¨´«ÊäÄ¿µÄµØÖ·
stcDmaCfg.enRequestNum = DmaI2S1LeftTrig; //ÉèÖÃΪÈí¼þ´¥·¢
stcDmaCfg.enTransferMode = DmaMskOneTransfer; //dma´«ÊäÒ»´Î£¬DMAC´«ÊäÍê³ÉʱÇå³ýCONFA:ENSλ
stcDmaCfg.enPriority = DmaMskPriorityFix; //¸÷ͨµÀ¹Ì¶¨ÓÅÏȼ¶£¬CH0ÓÅÏȼ¶ > CH1ÓÅÏȼ¶
Dma_InitChannel((en_dma_channel_t)stream->dma, &stcDmaCfg);
Dma_EnableChannelIrq((en_dma_channel_t)stream->dma); //´«Êä³É¹¦Íê³Éʱ²úÉúÖжÏ
EnableNvic(DMAC_IRQn,IrqLevel3,TRUE); //NVIC¶ÔÓ¦DMACÖжÏλʹÄÜ
Dma_ClrStat((en_dma_channel_t)stream->dma);
Dma_Enable(); //ʹÄÜDMA
Dma_EnableChannel((en_dma_channel_t)stream->dma); //ʹÄÜDmaCh1
I2S_Cmd((M0P_I2S_TypeDef *) stream->dev, ENABLE);
I2s_ConfDma((M0P_I2S_TypeDef *) stream->dev, I2S_LDMA_EN, ENABLE);
}
|