|
发表于 2021-12-20 20:44:51
|
显示全部楼层
- /*##-3- Configure the DMA ##################################################*/
- /* Configure the DMA handler for Transmission process */
- hdma_tx.Instance = USARTx_TX_DMA_STREAM;
- hdma_tx.Init.Request = USARTx_TX_DMA_CHANNEL;
- hdma_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
- hdma_tx.Init.PeriphInc = DMA_PINC_DISABLE;
- hdma_tx.Init.MemInc = DMA_MINC_ENABLE;
- hdma_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
- hdma_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
- hdma_tx.Init.Mode = DMA_NORMAL;
- hdma_tx.Init.Priority = DMA_PRIORITY_LOW;
- hdma_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
- hdma_tx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
- hdma_tx.Init.MemBurst = DMA_MBURST_INC4;
- hdma_tx.Init.PeriphBurst = DMA_PBURST_INC4;
- HAL_DMA_Init(&hdma_tx);
- /* Associate the initialized DMA handle to the UART handle */
- __HAL_LINKDMA(huart, hdmatx, hdma_tx);
- /* Configure the DMA handler for reception process */
- hdma_rx.Instance = USARTx_RX_DMA_STREAM;
- hdma_rx.Init.Request = USARTx_RX_DMA_CHANNEL;
- hdma_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
- hdma_rx.Init.PeriphInc = DMA_PINC_DISABLE;
- hdma_rx.Init.MemInc = DMA_MINC_ENABLE;
- hdma_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
- hdma_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
- hdma_rx.Init.Mode = DMA_NORMAL;
- hdma_rx.Init.Priority = DMA_PRIORITY_HIGH;
- hdma_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
- hdma_rx.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
- hdma_rx.Init.MemBurst = DMA_MBURST_INC4;
- hdma_rx.Init.PeriphBurst = DMA_PBURST_INC4;
- HAL_DMA_Init(&hdma_rx);
- /* Associate the initialized DMA handle to the the UART handle */
- __HAL_LINKDMA(huart, hdmarx, hdma_rx);
复制代码
你初始化都正确不? 上面示例代码,LINK部分,你的驱动里写了吗? |
|