下面这个是开启单次DMA传输
void PWM_DMA_Enable(void)
{
// while(DMA_GetCurrDataCounter(DMA2_Stream6)!=0){printf("wait=%d
",DMA_GetCurrDataCounter(DMA2_Stream6));}//等待传输完成
// while(DMA_GetCurrDataCounter(DMA2_Stream2)!=0){printf("wait=%d
",DMA_GetCurrDataCounter(DMA2_Stream2));}//等待传输完成
DMA_ClearFlag(DMA2_Stream6,DMA_FLAG_TCIF6);
DMA_ClearFlag(DMA2_Stream2,DMA_FLAG_TCIF2);
DMA_Cmd(DMA2_Stream6, DISABLE ); //关闭 指示的通道
DMA_Cmd(DMA2_Stream2, DISABLE ); //关闭 指示的通道
while (DMA_GetCmdStatus(DMA2_Stream6) != DISABLE){} //确保DMA可以被设置
while (DMA_GetCmdStatus(DMA2_Stream2) != DISABLE){} //确保DMA可以被设置
DMA_SetCurrDataCounter(DMA2_Stream6,BufferSize);//DMA通道的DMA缓存的大小
DMA_SetCurrDataCounter(DMA2_Stream2,BufferSize);//DMA通道的DMA缓存的大小
DMA_Cmd(DMA2_Stream6, ENABLE); //开启DMA传输
DMA_Cmd(DMA2_Stream2, ENABLE); //开启DMA传输
}
注释掉上面注释部分,程序运行正常,S6NDTR数值正常变化,如果加上注释掉的函数,会出现S6NDTR寄存器的值变为0xffff,
一周热门 更多>