cancel
Showing results for 
Search instead for 
Did you mean: 

DMA transfer delay when EXTI occur

way
Associate II

My target:pic.png

I want to use the same uart lines(RX line and TX line) to achieve communication between computers and multiple devices (in other words: multiple slave devices, computer as master).

 

I use some STM32F072C8 as slave devices, and configure these slave devices as follows:

  • configure USART1 to DMA send mode
  • Disable exti interrupt at USART1 TX gpio PA9 or enable the interrupt and add some delay time in the interrupt handle function.

Total methord:

  1. I use computer to send a message through UART. The slave devices reply the message as soon as receiving the  master message by uart.
  2. Avoid slave devices sending jam.

 Test result:

  • when I disable the exti interrupt at USART1 TX gpio PA9, the slave devices will send data at the same time so the computer cannot receive correct data.
  • when I enable the exti interrupt at USART1 TX gpio PA9 and add some delay time in the interrupt handle function, the slave devices will send data one by one and the computer can receive all correct data.

Question:

I want to know whether the data transfer from SRAM to USART through DMA will be broken and transfer again when an exti interrupt occurs on USART TX pin.

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

I mean, it'll do whatever your code tells it to do. If you put in a delay, it'll wait that delay. If you restart the transfer when EXTI happens, it'll do that.

The scheme you outlined can definitely work, but the slaves need to know how long to wait in order to not talk over one another, without getting input from the master. This can be tricky to solve in practice, unless you want to hard code the slaves separately. Bus contention in general is a nontrivial problem.

Using UART for this type of communication opens a can of worms. Perhaps I2C would be better as the problem of bus contention is solved by the protocol. Still only needs 2 wires connecting all devices. Similar speeds.

If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

2 REPLIES 2
TDK
Guru

I mean, it'll do whatever your code tells it to do. If you put in a delay, it'll wait that delay. If you restart the transfer when EXTI happens, it'll do that.

The scheme you outlined can definitely work, but the slaves need to know how long to wait in order to not talk over one another, without getting input from the master. This can be tricky to solve in practice, unless you want to hard code the slaves separately. Bus contention in general is a nontrivial problem.

Using UART for this type of communication opens a can of worms. Perhaps I2C would be better as the problem of bus contention is solved by the protocol. Still only needs 2 wires connecting all devices. Similar speeds.

If you feel a post has answered your question, please click "Accept as Solution".
way
Associate II

Thank you for your answer.

After some reading and test, finally I find there is no special work about DMA transmit. MCU is just do what the code tells it.

In this question, suitable EXTI Interrupt delay can avoid slave devices UART TX sending crash by a not skillful method.

:handshake: