cancel
Showing results for 
Search instead for 
Did you mean: 

USART DMA no data- HAL_UART_ErrorCallback() i get huart->ErrorCode = HAL_UART_ERROR_DMA

AKart.1
Associate II

Hey,

I'm new with STM32 =)

I have STM32H743ZIT6

I'm trying to read GPS data from ublox device.

After creating a new project with STM32cubeIDE.

This is the following configuration in the IOC file:

  • USART2
  • DMA - USART2_RX with circular mode
  • global interrupt enabled
  • Baud rate = 115200, no parity, word length = 8 bits, stop bits = 1, 16 over sampling

the main.c file contains:

int main(void)

{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */

 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */

 SystemClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */

 MX_GPIO_Init();

 MX_DMA_Init();

 MX_USART2_UART_Init();

 /* USER CODE BEGIN 2 */

 HAL_StatusTypeDef status = HAL_UART_Receive_DMA(&huart2, gps_buf, CHARS_TO_READ);

 if (status != HAL_OK)

 Error_Handler();

 /* USER CODE END 2 */

 /* Infinite loop */

 /* USER CODE BEGIN WHILE */

 while (1)

 {

  /* USER CODE END WHILE */

  /* USER CODE BEGIN 3 */

 }

 /* USER CODE END 3 */

}

also in main file :

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart){

/* add global buffer*/

HAL_UART_Transmit(&huart2, (uint8_t *)gps_buf, 255, 1);

}

void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart){

while(1){

}

}

when I'm executing the code with debug mode I see that the GPS buffer is empty all the time (not accessing the HAL_UART_RxCpltCallback function at all) and after a few iterations the run stops at HAL_UART_ErrorCallback function and the huart object error status is:

huart->ErrorCode = HAL_UART_ERROR_DMA (error 16)

I'm sure that all cables are ok because I already managed to do so perfectly with STM32F767 which has the same pinout as STM32H743ZIT6.

any idea what is wrong?

thanks

A.K

3 REPLIES 3
Imen.D
ST Employee

Hello @AKart.1​ and welcome to STM32 World =)

I advise you to have a look at the example here: STM32 UART DMA RX/TX

Please consider this FAQ article: DMA is not working on STM32H7 devices, for DMA usage with STM32H7 devices in case DMA is not working, or the transmitted/received data are corrupted,

Have a look also to the STM32H7 errata sheet and check if you have the same conditions as described here:

0693W00000AO9pBQAT.jpg 

Hope my answer helped you! :smiling_face_with_smiling_eyes:

When your question is answered, please close this topic by choosing Select as Best.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

The DTCM RAM can't be used for DMA on the H7, so pay attention to the memory buffer address, and perhaps look at the bus matrix diagram to better understand the plumbing.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello,

thank you for the fast replay :)

I have this condition (DMA stream locked). Can you help me please to solve it? How to enable bit 20 of DMA_SxCR register? Maybe I use the incorrect DMA stream? Thanks.