2015-08-19 10:43 AM
2015-08-21 11:48 PM
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...2015-08-24 09:52 AM
Kristian,
yes, good point. It turns out this setting is completely obliterated by the call toUSART_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.