1
我在使用STM32F4 DMA时遇到问题。 我已经建立了我的DMA配置如下的循环模式:STM32F4 DMA似乎正在溢出
hdma_usart1_rx.Instance = DMA2_Stream2;
hdma_usart1_rx.Init.Channel = DMA_CHANNEL_4;
hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_usart1_rx.Init.Mode = DMA_CIRCULAR;
hdma_usart1_rx.Init.Priority = DMA_PRIORITY_HIGH;
hdma_usart1_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
HAL_DMA_Init(&hdma_usart1_rx);
__HAL_LINKDMA(huart,hdmarx,hdma_usart1_rx);
这是UART DMA电话:
HAL_UART_Receive_DMA(&huart1,uartRxMsgBuffer, 40);
每个程序循环我集中检查NDTR值,如果它发生了变化,如果是这样,那么我知道有一些字节被接收并可用于处理。 由于某些原因,当我开发我的代码时,我发现DMA Rx缓冲区uartRxMsgBuffer
在向其发送超过40个字节的数据时被破坏。
我得到了一种迷失不知道从这一点去哪里,因为我检查了我的程序,我不直接写入这个缓冲区,有些它被覆盖。我还注意到,当我从我的代码删除以下行的DMA工作:
uartm->msgProcessingBuffer[uartm->currentMsgProcessingBufferPointer][uartm->msgProcessingBufferCharPointer] = uartm->uartRxMsgBuffer[uartm->RxMsgPointerStart];
我试图取代上面的代码,相当于一个波纹管,它仍然没有工作:
strncpy(&uartm->msgProcessingBuffer[uartm->currentMsgProcessingBufferPointer][uartm->msgProcessingBufferCharPointer],&uartm->uartRxMsgBuffer[uartm->RxMsgPointerStart],1);
有损坏之前和之后的2个DMA缓冲区图片(请参阅pRxBuffPtr
阵列)。我发送123456789\r\n
流,当我发送第四次缓冲区被损坏。
我猜我有点为这个节目的东西哑巴,我不知道如何你得出了这个结论,但你是对的,由于某种原因,调试器不知道发生了什么.........谢谢你的帮助,你为我节省了很多调试时间。 –