Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
535 views
in Technique[技术] by (71.8m points)

stm32 - DMA misses some characters with usart

I wrote a program that enables DMA(USART receiving mode) when an EXTI interrupt has occurred. When the line(EXTI) is going to high again it disables the DMA. There is a good time space between the two EXTI interrupts that ensure me that the USART transmits all bytes. My program works fine until a powering on/off is occurred. After powering on, sometimes, DMA1_Channel3_IRQHandler occurs but the sequence of the input data is missing. I need to know why after disabling/enabling the DMA, it doesn't start from the first characters. If there are any bytes in the USART register, while the DMA is disabled, after enabling the DMA, does it count the last bytes? if yes, how can solve this problem?

    void DMA1_Channel3_IRQHandler(void){ // USART3_RX // Encoder    
    
        if(Buffer[0]==65 && Buffer[20]=='
')
            {
                ....
            }           
                
    
        DMA_ClearITPendingBit(DMA1_IT_TC3);
        USART_ITConfig(USART3,USART_IT_RXNE,DISABLE);
        DMA_Cmd(DMA1_Channel3, DISABLE);    
                              DMA_SetCurrDataCounter(DMA1_Channel3,sizeof(Buffer));
    }


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...