0
votes

I have a setup of 2 STM32L0 MCUs on different PCBs that communicates together via I2C. I need to relay the incoming data I2C communication (RX) from one MCU as fast as possible to an UART (TX) of the other MCU, without any processing of the data itself.

Is it possible to directly connect the I2C RX with the UART-TX via DMA?

In my understanding this should be the fastest possible solution without blocking the CPU of the UART-relay-MCU. But unfortunately I found no comparable example with any peripheral, so I am afraid, this approach is either for some reasons I am not aware not the best or it is just not realizable.

1

1 Answers

3
votes

It should be possible, as the Reference Manual states that the DMA controller supports peripheral to peripheral transfer. But it doesn't say exactly how it should be configured, so I'm just guessing here a bit.

Use DMA channel 3 request 6, it's the I2C1_RX request. Set it up to do 8-bit circular peripheral to memory transfers, increment neither the peripheral nor the memory address, the peripheral address is the I2C receive register, memory address is the UART transmit data register.

Ensure that the UART can transmit faster as the I2C is receiving. I2C needs 9 bits to transmit a byte, an UART needs 10 bits, take that into account when selecting the bitrates. I2C @ 100kHz and UART @ 115200 Baud should be fine.