cancel
Showing results for 
Search instead for 
Did you mean: 

UART IT problem with DMA

Yasin Yelkovan
Associate III
Posted on July 26, 2017 at 14:38

Hi ,

I'm using STM32F407 Discovery kit with CubeMX version 4.21.0 and Attolic TrueStudio as an IDE. Problem is not be able to receive UART interrupts while DMA is running. In my program I can receive ADC values and UART RX messages if I do not enabled UART interrupts. (for ex: __HAL_UART_ENABLE_IT(&huart2, UART_IT_IDLE)).When I enable UART interrupts, the program is running until the UART message is received, and then the program crashes. I coulden't find the reason. 

I would be grateful if you can help.

8 REPLIES 8
Tilen MAJERLE
ST Employee
Posted on July 26, 2017 at 16:01

Hello

yelkovan.yusuf

‌,

please share some code you did so far and show us your .ioc file from CubeMX generated project.

Furthermore, what does it mean that it crashes?

Best regards,

Tilen

Yasin Yelkovan
Associate III
Posted on July 27, 2017 at 10:26

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6sx&d=%2Fa%2F0X0000000bxJ%2Flw9NwEi6bIuiVJzBHuM8a0iV4NxnRvlywfYpLEYDunQ&asPdf=false
Yasin Yelkovan
Associate III
Posted on July 27, 2017 at 10:37

Also I want to add my experience about this code. If '

__HAL_UART_ENABLE_IT(&huart2, UART_IT_RXNE); 

and

 

__HAL_UART_ENABLE_IT(&huart2, UART_IT_TC);' codes canceled, code does not crashe when uart message sent to stm32 but code does not go into the 'HAL_UART_RxCpltCallback()' function.

And crashes means that program does not go on anymore, it stops at somewhere.

Posted on July 28, 2017 at 16:02

I have added belove some information about my code and configuration.

Posted on July 29, 2017 at 15:41

I would suggest using the DMA interrupt and not the ADC interrupt to flag completion of the 3 samples.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 29, 2017 at 15:43

>>

And crashes means that program does not go on anymore, it stops at somewhere.

Break in the debugger and understand WHERE it stopped. Perhaps an infinite loop in the Hard Fault Handler, or stuck in HAL_Delay. For the former determine what faulted, for the latter look at the interrupt preemption levels.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 31, 2017 at 10:25

Hi Clive,

Thanks for your interest. 

When I break in debugger, code usually stops in HAL_UART_IRQHanler() or in HAL DMA IRQ Handler(), not at exact position. And I think the main problem is that DMA and UART Rx interrupts have mutual influence on each other's flag configurations. So isn't it a BUG. Do not somebody have to take this issue into consideration ?

Best regards,

Yusuf

Posted on October 20, 2017 at 02:24

hi

This is the ADC sample code for stm32f103c8t6 that I made.

I attach my own code because I am not competent to advise you.

________________

Attachments :

STM32ADC.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyIH&d=%2Fa%2F0X0000000b6Z%2FmrjobMMWQcEdP0hWLKDgqZbnowjfmgc9U8nnaS9xDV0&asPdf=false