- This topic has 0 replies, 1 voice, and was last updated 6 years, 5 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
Home › Forums › Mastering STM32 book support forum › DMA Interrupt mode: XferCpltCallback
Tagged: XferCpltCallback DMA
Hi
I use DMA in Interrupt mode to receive data from UART Periph to memory. data is transfered (my destination memory is occupied correctly)but my DMAReceiptComplete() callback function is never called.
hdma_usart1_rx.Instance = DMA1_Channel5;
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_VERY_HIGH;
hdma_usart1_rx.XferCpltCallback = &DMAReceiptComplete;
HAL_DMA_Init(&hdma_usart1_rx);
/* DMA interrupt init */
HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
HAL_DMA_Start_IT(&hdma_usart1_rx, (uint32_t)&huart1.Instance->DR, (uint32_t)buf, 2);
//Enable UART in DMA mode
huart1.Instance->CR3 |= USART_CR3_DMAR;
void DMAReceiptComplete(DMA_HandleTypeDef *hdma) {
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
if (hdma->Instance == DMA1_Channel5){
HAL_UART_Transmit_DMA(&huart2, (uint8_t*)buf, 2);
}
}
void DMA1_Channel5_IRQHandler(void){
HAL_DMA_IRQHandler(&hdma_usart1_rx);
}