void usart2dmaprocess(void)
{
u16 i;
DMA_Cmd(DMA1_Channel6,DISABLE); // ¹Ø±ÕDMA
DMA_ClearFlag(DMA1_FLAG_GL6); // Çå³ýDMA±êÖ¾
U2INDEX=2000-DMA_GetCurrDataCounter(DMA1_Channel6); //»ñµÃÊÕµ½µÄ×Ö½Ú
DMA1_Channel6->CNDTR =2000; //ÖØи³Öµ
DMA_Cmd(DMA1_Channel6,ENABLE); // ¿ªÆôDMA
for(i=0;i<U2INDEX;i++)
{
U2SENTT[i]=U2REVICE[i];
}
U2R**=1;
}
void USART2_IRQHandler(void)
{
if(USART_GetITStatus(USART2, USART_IT_IDLE) != RESET)
{
usart2dmaprocess();
USART_ReceiveData(USART2);//Çå³ý±êÖ¾
}
}
void usart2process(void)
{
if(U2R**)
{
U2R**=0;
DMA1_Channel7->CMAR=(u32)U2SENTT;
USART_DMACmd(USART2,USART_DMAReq_Tx,ENABLE);
MYDMA_Enable(DMA1_Channel7,U2INDEX);
}
}
这个是大概的程序,串口接收USART_IT_IDLE中断,然后读数据置标志主程序读标志发回去,结果发现有数据接收的时候串口DMA是不发数据的,麻烦香水城帮忙解决一下看看那里有问题 |