2015-05-17 12:44 AM
Hi.
I am trying to write a simple program for DMA rx transfers from UART interface. I am using the HAL drivers and HAL_DMA_Recieve.The problem I have found is very strange. DMA RX transfer from UART works only once. Then I have constant UART OR (overrun) bit set and controller does not recieve anything. The strangest thing is that there is no difference between DMA Normal mode and DMA Circular mode for DMA RX.I have no idea where I should look for the problem.2015-06-23 11:21 AM
Hi,
I've spent few hours on it, but finally I have solution. I've found mistake in ''stm32f0xx_hal_uart.c'' file. There is no condition for Circular Mode in callback function ''UART_DMAReceiveCplt'' line 1572. Working function should look like:/**
* @brief DMA UART receive process complete callback * @param hdma: DMA handle * @retval None */ static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma) { UART_HandleTypeDef* huart = ( UART_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;if((hdma->Instance->CCR & DMA_CCR_CIRC) == 0)
{ huart->RxXferCount = 0; /* Disable the DMA transfer for the receiver request by setting the DMAR bit in the UART CR3 register */ huart->Instance->CR3 &= (uint32_t)~((uint32_t)USART_CR3_DMAR); /* Check if a transmit Process is ongoing or not */ if(huart->State == HAL_UART_STATE_BUSY_TX_RX) { huart->State = HAL_UART_STATE_BUSY_TX; } else { huart->State = HAL_UART_STATE_READY; }}
HAL_UART_RxCpltCallback(huart); } I hope they'll fix it in next library version.