cancel
Showing results for 
Search instead for 
Did you mean: 

I am trying to adapt the "USART_Communication_TxRx_DMA USART Transmitter/Receiver example" to my custom hardware using a STM32F439ZIT6 processor.

svick.1
Associate II

I'm trying to get this example to work with my custom hardware. The TX works fine. I can't get the RX to work.

* This example was developed for the NUCLEO-F411RE board and my processor is an STM32F439ZIT6, not F411. Could this be the problem?

* I have traced the input RX signal all the way to the PA3 micro pin 37. The signal level and baud rate are both correct. I am using a terminal program to send the 'END' response, but the DMA1_Stream7_IRQHandler interrupt is never called.

Any help would be greatly appreciated.

10 REPLIES 10

I don't know what example are you talking about.

Read out the GPIOA registers and check in MODER if PA3 is set to AF, and in AFR if PA3 is set to the AF corresponding to given USART (check in the AF matrix table in the chip's datasheet).

Read out the USART registers and check if receiver is enabled; check if RXNE bit is set when a byte arrives (note that reading the data register clears this bit, even if the data register is read by the debugger).

If you want to use DMA, check in USART if DMA for Rx is enabled, check in RM's DMA chapter whether given stream is appropriate for the given USART's Rx (and note which channel in that stream is it assigned to); then read out the DMA registers and check whether they are properly set.

JW

svick.1
Associate II

Here's the path to the example...

C:\Users\steve\STM32Cube\Repository\STM32Cube_FW_F4_V1.24.1\Projects\STM32F411RE-Nucleo\Examples_LL\USART\USART_Communication_TxRx_DMA

Regardless, do what I've said above.

JW

svick.1
Associate II

OK, I now have the Rx interrupt working once and only once. It works the first time after starting the program, but all subsequent messages are ignored. Is there some flag that needs to be reset upon receipt of the first message?

You mean the interrupt of DMA Stream related to the Rx? And do the DMA status bits indicate Transfer completed, or something else? Or you mean some error interrupt from the USART itself?

Is the DMA set to be Circular? If not, you have to restart it. Read the DMA chapter in the RM.

JW

svick.1
Associate II

Yes, the Rx interrupt from the DMA stream. Yes transfer did complete with the first message. Can you provide sample code that shows how to restart the DMA? I tried running the Configure_DMA(); again after receiving the first message, but even that didn't fix the issue.

Piranha
Chief II

> you have to restart it. Read the DMA chapter in the RM.

> Can you provide sample code that shows how to restart the DMA?

Which part of the Jan's sentence you didn't understand?

svick.1
Associate II

Yes, thank you Piranha for your helpful comments. I did read the chapter in question. This chapter clearly states that the DMA must be restarted. While I'm sure the information I need is embedded in this text, it would still be nice to have some example code to demonstrate the concept. I don't think that's asking too much.

In order to restart from the point where the transfer was

stopped, the software has to read the DMA_SxNDTR register after disabling the stream

by writing the EN bit in DMA_SxCR register (and then checking that it is at ‘0’) to know

the number of data items already collected. Then:

– The peripheral and/or memory addresses have to be updated in order to adjust

the address pointers

– The SxNDTR register has to be updated with the remaining number of data items

to be transferred (the value read when the stream was disabled)

– The stream may then be re-enabled to restart the transfer from the point it was

stopped

Piranha
Chief II
  1. Disable DMA.
  2. Update address and number of data items.
  3. Enable DMA.

The point Nr. 2 completely depends of what you are implementing.