cancel
Showing results for 
Search instead for 
Did you mean: 

USART TX problem in blocking and non-blocking mode in one main program

Katarzyna Bartnik
Associate II
Posted on February 28, 2017 at 22:28

Hello! I have a problem with using usart transmit function twice in main program on STM32F4/

STM32

F0. First transmition should be with DMA and after it data should be send in blocking mode without using DMA. Problem is that I have to use the same usart module for each of transmitions and there is a conflict because using DMA requires USART global interrupts to be enabled and transmition in blocking mode doesn't work properly when the interrupts are enabled. I would be very grateful if you coud give me some information or any suggestions what I couls do to resolve my problem.

#stm32f4-usart #stm32f4-discovery #stm32f4 #stm32f0-discovery #stm32f4-dma-usart #stm32f0-usart
11 REPLIES 11
Posted on March 07, 2017 at 22:39

If I properly understand your code description, I would say that starting a DMA Tx transfer and waiting for its completion (which requires an interrupt to occur), within the IRQ Handler (so while you are already treating TIM interrupt) is not recommended.

This explains why you observe the DMA bit in USART reg to be reset,but Tx Complete callback not executed.

Could you rearrange your code for having less treatments in TIM Irq Handler, allowing other interrupts to be processed ?

Regards

Guenael

Posted on March 09, 2017 at 08:56

Hi,

The problem is not only in the TIM IRQ Handler, the same happens if I place my code in main function i while(1) loop and disable timer interrupts.

At the begining I had this code in main function, and I check executing time of my code. If sended data are OK the executing time is about 300us but if sended data are wrong this time is about 1ms.