高级会员

- 积分
- 714
- 金钱
- 714
- 注册时间
- 2014-10-15
- 在线时间
- 172 小时
|
1金钱
我试图用STM32L4R5ZIT6的DMA功能把存储器里的数据发往串口1
用串口可以发数据:、
比如这句:
- HAL_UART_Transmit(&huart1,buffer,1,1000);
复制代码 用这句就不行:
- HAL_UART_Transmit_DMA(&huart1, (uint8_t *)Buffer, 4);
复制代码 我的DMA配置函数如下:
- static void DMA_Config(void)
- {
- /*## -1- Enable DMA1 clock #################################################*/
- __HAL_RCC_DMA1_CLK_ENABLE();
- /*##-2- Select the DMA functional Parameters ###############################*/
- DmaHandle.Init.Direction = DMA_MEMORY_TO_PERIPH ; /* M2M transfer mode */
- DmaHandle.Init.PeriphInc = DMA_PINC_DISABLE; /* Peripheral increment mode Enable */
- //DmaHandle.Init.PeriphInc = DMA_PINC_DISABLE;
- DmaHandle.Init.MemInc = DMA_MINC_ENABLE; /* Memory increment mode Enable */
- //DmaHandle.Init.MemInc = DMA_MINC_DISABLE;
- // DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; /* Peripheral data alignment : Word */
- // DmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; /* memory data alignment : Word */
- // DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD; /* Peripheral data alignment : Word */
- //
- // DmaHandle.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD; /* memory data alignment : Word */
- DmaHandle.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE ; /* Peripheral data alignment : Word */
- DmaHandle.Init.MemDataAlignment = DMA_PDATAALIGN_BYTE ; /* memory data alignment : Word */
- DmaHandle.Init.Mode = DMA_NORMAL; /* Normal DMA mode */
- DmaHandle.Init.Priority = DMA_PRIORITY_HIGH; /* priority level : high */
- /*##-3- Select the DMA instance to be used for the transfer : DMA1_Channel1 #*/
- DmaHandle.Instance = DMA_INSTANCE;
- /*##-4- Initialize the DMA channel ##########################################*/
- if (HAL_DMA_Init(&DmaHandle) != HAL_OK)
- {
- /* Initialization Error */
- Error_Handler();
- }
-
- /*##-5- Select Callbacks functions called after Transfer complete and Transfer error */
- HAL_DMA_RegisterCallback(&DmaHandle, HAL_DMA_XFER_CPLT_CB_ID, TransferComplete);
- HAL_DMA_RegisterCallback(&DmaHandle, HAL_DMA_XFER_ERROR_CB_ID, TransferError);
- /*##-6- Configure NVIC for DMA transfer complete/error interrupts ##########*/
- /* Set Interrupt Group Priority */
- HAL_NVIC_SetPriority(DMA_INSTANCE_IRQ, 0, 0);
- /* Enable the DMA STREAM global Interrupt */
- HAL_NVIC_EnableIRQ(DMA_INSTANCE_IRQ);
- /*##-7- Start the DMA transfer using the interrupt mode ####################*/
- /* Configure the source, destination and buffer size DMA fields and Start DMA Channel transfer */
- /* Enable All the DMA interrupts */
- if (HAL_DMA_Start_IT(&DmaHandle, (uint32_t)&aSRC_Const_Buffer, (uint32_t)aDST_Buffer, 4) != HAL_OK)
- {
- /* Transfer Error */
- Error_Handler();
- }
- }
复制代码 请高手指教,如何解决?谢谢!
|
|