本帖最后由 feihongTC 于 2021-11-10 18:07 编辑
新塘单片机M031 PDMA 调试 M031BSP 提供的范例, 哪位大侠,能否使用过,是否有哪些设置不正确
/* Open Channel 1 */
PDMA_Open(PDMA, 1 << PDMA_CH);
/* Transfer count is PDMA_TEST_LENGTH, transfer width is 32 bits(one word) */
PDMA_SetTransferCnt(PDMA, PDMA_CH, PDMA_WIDTH_32, PDMA_TEST_LENGTH);
/* Set source address is au8SrcArray, destination address is au8DestArray, Source/Destination increment size is 32 bits(one word) */
PDMA_SetTransferAddr(PDMA, PDMA_CH, (uint32_t)au8SrcArray, PDMA_SAR_INC, (uint32_t)au8DestArray, PDMA_DAR_INC);
/* Request source is memory to memory */
PDMA_SetTransferMode(PDMA, PDMA_CH, PDMA_MEM, FALSE, 0);
/* Transfer type is burst transfer and burst size is 4 */
PDMA_SetBurstType(PDMA, PDMA_CH, PDMA_REQ_BURST, PDMA_BURST_4);
/* Enable interrupt */
PDMA_EnableInt(PDMA, PDMA_CH, PDMA_INT_TRANS_DONE);
/* Enable NVIC for PDMA */
NVIC_EnableIRQ(PDMA_IRQn);
g_u32IsTestOver = 0;
/* Generate a software request to trigger transfer with PDMA channel 1 */
PDMA_Trigger(PDMA, PDMA_CH);
/* Waiting for transfer done */
while (g_u32IsTestOver == 0);
/* Check transfer result */
if (g_u32IsTestOver == 1)
printf("test done...\n");
else if (g_u32IsTestOver == 2)
printf("target abort...\n");
/* Close channel 1 */
PDMA_Close(PDMA);
while (1); |