cancel
Showing results for 
Search instead for 
Did you mean: 

USART receive with DMA not working on STM32F1xx

elmar
Associate II
Posted on August 19, 2015 at 19:43

The original post was too long to process during our migration. Please click on the attachment to read the original post.
11 REPLIES 11
knielsen
Associate II
Posted on August 22, 2015 at 08:48

It sounds like you got it working, which is great. Still, I am curious about this in your code:

clockInit.USART_Clock = USART_Clock_Enable;
clockInit.USART_CPOL = USART_CPOL_Low;
clockInit.USART_CPHA = USART_CPHA_1Edge;
clockInit.USART_LastBit = USART_LastBit_Disable;
USART_ClockInit (LINK_USART, &clockInit);

This should set the USART to SPI master mode. In this mode, reception is synchronous, one byte is received for every byte transmitted. This sounds very different from what you describe as your original problem, which sounds like you are receiving from a completely different source than you are sending to? Also, you are configuring the Tx DMA to send 5 bytes, but the Rx to receive just one byte. Again, this seems inconsistent with setting the USART in SPI/synchronous mode? Also, your code in

process()

checks for completion of Tx DMA. However, this only indicates that the last byte has been transfered to the USART1->DR register; you then still need to wait for the USART to complete the transmission of that byte. Well, I did not mean to come across as a vindictive school teacher :) I was just curious how your code could work like this, and maybe if you still have problems this could give you some further hints...
elmar
Associate II
Posted on August 24, 2015 at 18:52

Kristian,

yes, good point. It turns out this setting is completely obliterated by the call to  

USART_Init

(

LINK_USART

,

&

usartInit

)

;

with the desired baud rate set in the init structure, resulting in a correct setup regardless. So, that code has no effect. I had removed that from my code but neglected to post that change.