cancel
Showing results for 
Search instead for 
Did you mean: 

UART DMA INT is not working

asaad
Associate
Posted on June 16, 2016 at 10:30

Hi,

I'm facing a strange problem with UART DMA int in a FreeRTOS-based project. When I call the DMA setup function (below) from a given FreeRTOS task, it works just fine and the ISR is executed. However, when I call it from a different task, the DMA ISR is not executed at all. Although all DMA interrupts are enabled and the DMA channel itself is enabled.. ( I can see the registers in uVision debug mode). Below you can see register values. I don't know why the ISR is not executed. The DMA transfers only 2 bytes (instead of 10) and then stops. I double checked the DMA settings they are the same in both tasks.. 0690X00000605PtQAI.png

/* Streaming DMA 1 (port-to-port) setup */
void PortPortDMA1_Setup(UART_HandleTypeDef* huartSrc, UART_HandleTypeDef* huartDst, uint8_t num)
{
/* UART RX DMA (DMA1 Ch1) */
if (huartSrc->Instance == USART1) {
__HAL_DMA1_REMAP(HAL_DMA1_CH1_USART1_RX);
} else if (huartSrc->Instance == USART2) {
__HAL_DMA1_REMAP(HAL_DMA1_CH1_USART2_RX);
} else if (huartSrc->Instance == USART3) {
__HAL_DMA1_REMAP(HAL_DMA1_CH1_USART3_RX);
} else if (huartSrc->Instance == USART4) {
__HAL_DMA1_REMAP(HAL_DMA1_CH1_USART4_RX);
} else if (huartSrc->Instance == USART5) {
__HAL_DMA1_REMAP(HAL_DMA1_CH1_USART5_RX);
} else if (huartSrc->Instance == USART6) {
__HAL_DMA1_REMAP(HAL_DMA1_CH1_USART6_RX);
} else if (huartSrc->Instance == USART7) {
__HAL_DMA1_REMAP(HAL_DMA1_CH1_USART7_RX);
} else if (huartSrc->Instance == USART8) {
__HAL_DMA1_REMAP(HAL_DMA1_CH1_USART8_RX);
}
__HAL_LINKDMA(huartSrc,hdmarx,portPortDMA1);
/* DMA interrupt init */
HAL_NVIC_SetPriority(DMA1_Ch1_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(DMA1_Ch1_IRQn);
/* Start DMA stream */
dmaStreamDst[0] = huartDst;
huartSrc->State = HAL_UART_STATE_READY;
HAL_UART_Receive_DMA(huartSrc, (uint8_t *)(&(huartDst->Instance->TDR)), num);
/* Lock the ports */
portStatus[GetPort(huartSrc)] = STREAM;
portStatus[GetPort(huartDst)] = STREAM;
/* Initialize counter */
DMAStream1count = 0;
}

0 REPLIES 0