|
大家好: 现在我调试dma串口时,接收的数据是重复的,发不同数据会有重复在里面,是u不是要清除buffer,百度各种方法无法实现。 void u_uart_dma_receive_idle(UART_HandleTypeDef *huart, uint8_t index) { if((__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) != RESET)) { __HAL_UART_CLEAR_IDLEFLAG(huart); UartRawPack[index-1]->len = UART_MAX_LEN - ((DMA_Stream_TypeDef*)huart->hdmarx->Instance)->NDTR; //Send Data to queue here. if(UartRawPack[index-1]->len > 0){ u_uart_dma_RxCpltCallback(huart, UartRawPack[index-1]); } HAL_UART_DMAStop(huart); //HAL_UART_Transmit_DMA(huart, UartRawPack[index-1]->Data, UartRawPack[index-1]->len); HAL_UART_Receive_DMA(huart, UartRawPack[index-1]->Data, UART_MAX_LEN); } } |
微信公众号
手机版
/* Configure the MPU attributes as Device not cacheable
for UART DMA descriptors */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x38000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_64KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER3;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
评分
查看全部评分